Commit b17b090b authored by K20014's avatar K20014
Browse files

調整前コミット

parent 3a6f78e0
#!/bin/sh
./gradlew clean
#!/bin/sh
cd `dirname $0`
rm -rf build
mkdir build
chmod +x gradlew
./gradlew build
...@@ -7,8 +7,7 @@ DefaultTacticsAmbulanceTeam.CommandExecutorAmbulance : adf.impl.centralized.Defa ...@@ -7,8 +7,7 @@ DefaultTacticsAmbulanceTeam.CommandExecutorAmbulance : adf.impl.centralized.Defa
DefaultTacticsAmbulanceTeam.CommandExecutorScout : adf.impl.centralized.DefaultCommandExecutorScout DefaultTacticsAmbulanceTeam.CommandExecutorScout : adf.impl.centralized.DefaultCommandExecutorScout
## DefaultTacticsFireBrigade ## DefaultTacticsFireBrigade
## DefaultTacticsFireBrigade.HumanDetector : sample_team.module.complex.SampleHumanDetector DefaultTacticsFireBrigade.HumanDetector : sample_team.module.complex.SampleHumanDetector
DefaultTacticsFireBrigade.HumanDetector : autumn_2023.module.complex.SampleHumanDetector
DefaultTacticsFireBrigade.Search : sample_team.module.complex.SampleSearch DefaultTacticsFireBrigade.Search : sample_team.module.complex.SampleSearch
DefaultTacticsFireBrigade.ExtActionFireRescue : adf.impl.extaction.DefaultExtActionFireRescue DefaultTacticsFireBrigade.ExtActionFireRescue : adf.impl.extaction.DefaultExtActionFireRescue
DefaultTacticsFireBrigade.ExtActionMove : adf.impl.extaction.DefaultExtActionMove DefaultTacticsFireBrigade.ExtActionMove : adf.impl.extaction.DefaultExtActionMove
...@@ -44,7 +43,6 @@ SampleSearch.PathPlanning.Police : adf.impl.module.algorithm.DijkstraPathPlannin ...@@ -44,7 +43,6 @@ SampleSearch.PathPlanning.Police : adf.impl.module.algorithm.DijkstraPathPlannin
SampleSearch.Clustering.Police : autumn_2023.module.algorithm.KmeansPPClustering SampleSearch.Clustering.Police : autumn_2023.module.algorithm.KmeansPPClustering
## SampleBuildDetector ## SampleBuildDetector
#SampleBuildingDetector.Clustering : adf.impl.module.algorithm.KMeansClustering
SampleBuildingDetector.Clustering : autumn_2023.module.algorithm.KmeansPPClustering SampleBuildingDetector.Clustering : autumn_2023.module.algorithm.KmeansPPClustering
## SampleRoadDetector ## SampleRoadDetector
...@@ -53,8 +51,6 @@ SampleRoadDetector.PathPlanning : adf.impl.module.algorithm.DijkstraPathPlanning ...@@ -53,8 +51,6 @@ SampleRoadDetector.PathPlanning : adf.impl.module.algorithm.DijkstraPathPlanning
## SampleHumanDetector ## SampleHumanDetector
SampleHumanDetector.Clustering : autumn_2023.module.algorithm.KmeansPPClustering SampleHumanDetector.Clustering : autumn_2023.module.algorithm.KmeansPPClustering
# 追加
SampleHumanDetector.PathPlanning : adf.impl.module.algorithm.DijkstraPathPlanning
## DefaultExtActionClear ## DefaultExtActionClear
DefaultExtActionClear.PathPlanning : adf.impl.module.algorithm.DijkstraPathPlanning DefaultExtActionClear.PathPlanning : adf.impl.module.algorithm.DijkstraPathPlanning
...@@ -78,7 +74,7 @@ DefaultCommandExecutorAmbulance.ExtActionMove : adf.impl.extaction.DefaultExtAct ...@@ -78,7 +74,7 @@ DefaultCommandExecutorAmbulance.ExtActionMove : adf.impl.extaction.DefaultExtAct
## DefaultCommandExecutorFire ## DefaultCommandExecutorFire
DefaultCommandExecutorFire.PathPlanning : adf.impl.module.algorithm.DijkstraPathPlanning DefaultCommandExecutorFire.PathPlanning : adf.impl.module.algorithm.DijkstraPathPlanning
DefaultCommandExecutorFire.EtxActionFireRescue : adf.impl.extaction.DefaultExtActionFireRescue DefaultCommandExecutorFire.ExtActionFireRescue : adf.impl.extaction.DefaultExtActionFireRescue
DefaultCommandExecutorFire.ExtActionFireFighting : adf.impl.extaction.DefaultExtActionFireFighting DefaultCommandExecutorFire.ExtActionFireFighting : adf.impl.extaction.DefaultExtActionFireFighting
DefaultCommandExecutorFire.ExtActionMove : adf.impl.extaction.DefaultExtActionMove DefaultCommandExecutorFire.ExtActionMove : adf.impl.extaction.DefaultExtActionMove
...@@ -102,3 +98,12 @@ MessageManager.CenterMessageCoordinator : adf.impl.module.comm.DefaultMessageCoo ...@@ -102,3 +98,12 @@ MessageManager.CenterMessageCoordinator : adf.impl.module.comm.DefaultMessageCoo
## VisualDebug ## VisualDebug
VisualDebug : true VisualDebug : true
## オークション追加
DefaultTacticsFireBrigade.HumanDetector : autumn_2023.module.complex.AuctionFBHumanDetector
DefaultTacticsFireBrigade.Search : autumn_2023.module.complex.AuctionFBSearch
DefaultTacticsFireBrigade.CommandExecutorFire : autumn_2023.centralized.AuctionCommandExecutorFire
DefaultTacticsFireStation.TargetAllocator : autumn_2023.module.complex.AuctionFireTargetAllocator
DefaultTacticsFireStation.CommandPicker : autumn_2023.centralized.AuctionCommandPickerFire
MessageManager.PlatoonMessageCoordinator : autumn_2023.module.comm.DefaultMessageCoordinator
MessageManager.CenterMessageCoordinator : autumn_2023.module.comm.DefaultMessageCoordinator
\ No newline at end of file
#!/bin/sh
LOADER="adf.impl.DefaultLoader"
PARAMS=$*
cd `dirname $0`
if [ ! -z "$1" ]; then
./gradlew launch --args="${LOADER} ${PARAMS} -pre 1"
else
echo "Options:"
echo "-tn Team name"
echo "-t [FB],[FS],[PF],[PO],[AT],[AC] Number of agents"
echo "-fb [FB] Number of FireBrigade"
echo "-fs [FS] Number of FireStation"
echo "-pf [PF] Number of PoliceForce"
echo "-po [PO] Number of PoliceOffice"
echo "-at [AT] Number of AmbulanceTeam"
echo "-ac [AC] Number of AmbulanceCentre"
echo "-s [HOST]:[PORT] RCRS server host and port"
echo "-h [HOST] RCRS server host (port:27931)"
echo "-pre [0|1] Precompute flag"
echo "-d [0|1] Debug flag"
echo "-dev [0|1] Development mode"
echo "-mc [FILE] ModuleConfig file name"
echo "-md [JSON] ModuleConfig JSON"
echo "-df [FILE] DevelopData JSON file"
echo "-dd [JSON] DevelopData JSON"
echo "-all [alias] -t -1,-1,-1,-1,-1,-1"
echo "-allp [alias] -t 1,0,1,0,1,0,"
echo "-local [alias] -h localhost"
echo "-precompute [alias] -pre 1"
echo "-debug [alias] -d 1"
echo "-develop [alias] -dev 1"
fi
...@@ -3,7 +3,6 @@ package autumn_2023.centralized; ...@@ -3,7 +3,6 @@ package autumn_2023.centralized;
import adf.core.agent.action.common.ActionMove; import adf.core.agent.action.common.ActionMove;
import adf.core.agent.action.common.ActionRest; import adf.core.agent.action.common.ActionRest;
import adf.core.agent.communication.MessageManager; import adf.core.agent.communication.MessageManager;
import adf.core.agent.communication.standard.bundle.StandardMessagePriority;
import adf.core.agent.communication.standard.bundle.centralized.CommandFire; import adf.core.agent.communication.standard.bundle.centralized.CommandFire;
import adf.core.agent.communication.standard.bundle.information.MessageCivilian; import adf.core.agent.communication.standard.bundle.information.MessageCivilian;
import adf.core.agent.develop.DevelopData; import adf.core.agent.develop.DevelopData;
...@@ -55,7 +54,7 @@ public class AuctionCommandExecutorFire extends CommandExecutor<CommandFire> { ...@@ -55,7 +54,7 @@ public class AuctionCommandExecutorFire extends CommandExecutor<CommandFire> {
case PRECOMPUTED: case PRECOMPUTED:
case NON_PRECOMPUTE: case NON_PRECOMPUTE:
this.pathPlanning = moduleManager.getModule( this.pathPlanning = moduleManager.getModule(
"AuctionCommandExecutorFire.PathPlanning", "DefaultCommandExecutorFire.PathPlanning",
"adf.impl.module.algorithm.DijkstraPathPlanning"); "adf.impl.module.algorithm.DijkstraPathPlanning");
this.actionFireRescue = moduleManager.getExtAction( this.actionFireRescue = moduleManager.getExtAction(
"DefaultCommandExecutorFire.ExtActionFireRescue", "DefaultCommandExecutorFire.ExtActionFireRescue",
...@@ -93,10 +92,10 @@ public class AuctionCommandExecutorFire extends CommandExecutor<CommandFire> { ...@@ -93,10 +92,10 @@ public class AuctionCommandExecutorFire extends CommandExecutor<CommandFire> {
.collect(Collectors.toSet()); .collect(Collectors.toSet());
// 新規メッセージクラスを用いてタスク実行時のコストを救急司令所に送信 // 新規メッセージクラスを用いてタスク実行時のコストを救急司令所に送信
if (this.result == null) if (this.commandType == -1)
{ {
receivedCentreCivilians.parallelStream() receivedCentreCivilians.parallelStream()
.map(e -> new MessageCost(true, StandardMessagePriority.HIGH, e, CalculationCost(e))) .map(e -> new MessageCost(true, e, CalculationCost(e)))
.forEach(messageManager::addMessage); .forEach(messageManager::addMessage);
} }
...@@ -106,7 +105,7 @@ public class AuctionCommandExecutorFire extends CommandExecutor<CommandFire> { ...@@ -106,7 +105,7 @@ public class AuctionCommandExecutorFire extends CommandExecutor<CommandFire> {
.map(this.worldInfo::getEntity) .map(this.worldInfo::getEntity)
.filter(Civilian.class::isInstance) .filter(Civilian.class::isInstance)
.map(Civilian.class::cast) .map(Civilian.class::cast)
.map(e -> new MessageCivilian(true, StandardMessagePriority.HIGH, e)) .map(e -> new MessageCivilian(true, e))
.forEach(messageManager::addMessage); .forEach(messageManager::addMessage);
this.bidCentreCivilians.addAll(receivedCentreCivilians); this.bidCentreCivilians.addAll(receivedCentreCivilians);
......
...@@ -23,6 +23,7 @@ import autumn_2023.module.comm.infomation.MessageCost; ...@@ -23,6 +23,7 @@ import autumn_2023.module.comm.infomation.MessageCost;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import rescuecore2.standard.entities.StandardEntityURN; import rescuecore2.standard.entities.StandardEntityURN;
public class AuctionMessageCoordinator extends MessageCoordinator{ public class AuctionMessageCoordinator extends MessageCoordinator{
...@@ -42,61 +43,80 @@ public class AuctionMessageCoordinator extends MessageCoordinator{ ...@@ -42,61 +43,80 @@ public class AuctionMessageCoordinator extends MessageCoordinator{
StandardEntityURN agentType = getAgentType(agentInfo, worldInfo); StandardEntityURN agentType = getAgentType(agentInfo, worldInfo);
for (CommunicationMessage msg : sendMessageList) { for (CommunicationMessage msg : sendMessageList) {
if (msg instanceof StandardMessage if (msg instanceof StandardMessage && !((StandardMessage) msg).isRadio())
&& !((StandardMessage) msg).isRadio()) { {
voiceMessages.add(msg); voiceMessages.add(msg);
} else { } else {
if (msg instanceof MessageBuilding) { if (msg instanceof MessageBuilding)
{
fireBrigadeMessages.add(msg); fireBrigadeMessages.add(msg);
} else if (msg instanceof MessageCivilian) { } else if (msg instanceof MessageCivilian)
{
ambulanceMessages.add(msg); ambulanceMessages.add(msg);
// 追加 // 追加
fireBrigadeMessages.add(msg); fireBrigadeMessages.add(msg);
} else if (msg instanceof MessageRoad) { } else if (msg instanceof MessageRoad)
{
fireBrigadeMessages.add(msg); fireBrigadeMessages.add(msg);
ambulanceMessages.add(msg); ambulanceMessages.add(msg);
policeMessages.add(msg); policeMessages.add(msg);
} else if (msg instanceof CommandAmbulance) { } else if (msg instanceof CommandAmbulance)
{
ambulanceMessages.add(msg); ambulanceMessages.add(msg);
} else if (msg instanceof CommandFire) { } else if (msg instanceof CommandFire)
{
fireBrigadeMessages.add(msg); fireBrigadeMessages.add(msg);
} else if (msg instanceof CommandPolice) { } else if (msg instanceof CommandPolice)
{
policeMessages.add(msg); policeMessages.add(msg);
} else if (msg instanceof CommandScout) { } else if (msg instanceof CommandScout)
if (agentType == StandardEntityURN.FIRE_STATION) { {
if (agentType == StandardEntityURN.FIRE_STATION)
{
fireBrigadeMessages.add(msg); fireBrigadeMessages.add(msg);
} else if (agentType == StandardEntityURN.POLICE_OFFICE) { } else if (agentType == StandardEntityURN.POLICE_OFFICE)
{
policeMessages.add(msg); policeMessages.add(msg);
} else if (agentType == StandardEntityURN.AMBULANCE_CENTRE) { } else if (agentType == StandardEntityURN.AMBULANCE_CENTRE)
{
ambulanceMessages.add(msg); ambulanceMessages.add(msg);
} }
} else if (msg instanceof MessageReport) { } else if (msg instanceof MessageReport)
if (agentType == StandardEntityURN.FIRE_BRIGADE) { {
if (agentType == StandardEntityURN.FIRE_BRIGADE)
{
fireBrigadeMessages.add(msg); fireBrigadeMessages.add(msg);
} else if (agentType == StandardEntityURN.POLICE_FORCE) { } else if (agentType == StandardEntityURN.POLICE_FORCE)
{
policeMessages.add(msg); policeMessages.add(msg);
} else if (agentType == StandardEntityURN.AMBULANCE_TEAM) { } else if (agentType == StandardEntityURN.AMBULANCE_TEAM)
{
ambulanceMessages.add(msg); ambulanceMessages.add(msg);
} }
} else if (msg instanceof MessageFireBrigade) { } else if (msg instanceof MessageFireBrigade)
{
fireBrigadeMessages.add(msg); fireBrigadeMessages.add(msg);
ambulanceMessages.add(msg); ambulanceMessages.add(msg);
policeMessages.add(msg); policeMessages.add(msg);
} else if (msg instanceof MessagePoliceForce) { } else if (msg instanceof MessagePoliceForce)
{
ambulanceMessages.add(msg); ambulanceMessages.add(msg);
policeMessages.add(msg); policeMessages.add(msg);
} else if (msg instanceof MessageAmbulanceTeam) { } else if (msg instanceof MessageAmbulanceTeam)
{
ambulanceMessages.add(msg); ambulanceMessages.add(msg);
policeMessages.add(msg); policeMessages.add(msg);
// 新規メッセージクラス // 新規メッセージクラス
} else if (msg instanceof MessageCost) { } else if (msg instanceof MessageCost)
{
ambulanceMessages.add(msg); ambulanceMessages.add(msg);
fireBrigadeMessages.add(msg); fireBrigadeMessages.add(msg);
} }
} }
} }
if (scenarioInfo.getCommsChannelsCount() > 1) { if (scenarioInfo.getCommsChannelsCount() > 1)
{
// send radio messages if there are more than one communication channel // send radio messages if there are more than one communication channel
int[] channelSize = new int[scenarioInfo.getCommsChannelsCount() - 1]; int[] channelSize = new int[scenarioInfo.getCommsChannelsCount() - 1];
...@@ -144,26 +164,29 @@ public class AuctionMessageCoordinator extends MessageCoordinator{ ...@@ -144,26 +164,29 @@ public class AuctionMessageCoordinator extends MessageCoordinator{
// channel // channel
int maxChannelCount = 0; int maxChannelCount = 0;
boolean isPlatoon = isPlatoonAgent(agentInfo, worldInfo); boolean isPlatoon = isPlatoonAgent(agentInfo, worldInfo);
if (isPlatoon) { if (isPlatoon)
{
maxChannelCount = scenarioInfo.getCommsChannelsMaxPlatoon(); maxChannelCount = scenarioInfo.getCommsChannelsMaxPlatoon();
} else { } else {
maxChannelCount = scenarioInfo.getCommsChannelsMaxOffice(); maxChannelCount = scenarioInfo.getCommsChannelsMaxOffice();
} }
int[] channels = new int[maxChannelCount]; int[] channels = new int[maxChannelCount];
for (int i = 0; i < maxChannelCount; i++) { for (int i = 0; i < maxChannelCount; i++)
channels[i] = AuctionChannelSubscriber.getChannelNumber(agentType, i, {
numChannels); channels[i] = AuctionChannelSubscriber.getChannelNumber(agentType, i, numChannels);
} }
return channels; return channels;
} }
protected boolean isPlatoonAgent(AgentInfo agentInfo, WorldInfo worldInfo) { protected boolean isPlatoonAgent(AgentInfo agentInfo, WorldInfo worldInfo)
{
StandardEntityURN agentType = getAgentType(agentInfo, worldInfo); StandardEntityURN agentType = getAgentType(agentInfo, worldInfo);
if (agentType == StandardEntityURN.FIRE_BRIGADE if (agentType == StandardEntityURN.FIRE_BRIGADE
|| agentType == StandardEntityURN.POLICE_FORCE || agentType == StandardEntityURN.POLICE_FORCE
|| agentType == StandardEntityURN.AMBULANCE_TEAM) { || agentType == StandardEntityURN.AMBULANCE_TEAM)
{
return true; return true;
} }
return false; return false;
......
package autumn_2023.module.comm.infomation; package autumn_2023.module.comm.infomation;
import javax.annotation.Nonnull;
import adf.core.agent.communication.standard.bundle.StandardMessage; import adf.core.agent.communication.standard.bundle.StandardMessage;
import adf.core.agent.communication.standard.bundle.StandardMessagePriority; import adf.core.agent.communication.standard.bundle.StandardMessagePriority;
import adf.core.component.communication.util.BitOutputStream; import adf.core.component.communication.util.BitOutputStream;
...@@ -30,7 +28,7 @@ public class MessageCost extends StandardMessage{ ...@@ -30,7 +28,7 @@ public class MessageCost extends StandardMessage{
this.cost = cost; this.cost = cost;
} }
public MessageCost(boolean isRadio, int from, int ttl, @Nonnull BitStreamReader bitStreamReader) public MessageCost(boolean isRadio, int from, int ttl, BitStreamReader bitStreamReader)
{ {
super(isRadio, from, ttl, bitStreamReader); super(isRadio, from, ttl, bitStreamReader);
this.targetId = new EntityID(bitStreamReader.getBits(SIZE_TARGET)); this.targetId = new EntityID(bitStreamReader.getBits(SIZE_TARGET));
......
...@@ -2,7 +2,6 @@ package autumn_2023.module.complex; ...@@ -2,7 +2,6 @@ package autumn_2023.module.complex;
import adf.core.agent.communication.MessageManager; import adf.core.agent.communication.MessageManager;
import adf.core.agent.communication.standard.bundle.MessageUtil; import adf.core.agent.communication.standard.bundle.MessageUtil;
import adf.core.agent.communication.standard.bundle.StandardMessagePriority;
import adf.core.agent.communication.standard.bundle.information.MessageCivilian; import adf.core.agent.communication.standard.bundle.information.MessageCivilian;
import adf.core.agent.develop.DevelopData; import adf.core.agent.develop.DevelopData;
import adf.core.agent.info.AgentInfo; import adf.core.agent.info.AgentInfo;
...@@ -150,7 +149,7 @@ public class AuctionFireTargetAllocator extends FireTargetAllocator{ ...@@ -150,7 +149,7 @@ public class AuctionFireTargetAllocator extends FireTargetAllocator{
// 埋没している市民の情報の送信 // 埋没している市民の情報の送信
for(EntityID res : this.receivedAgentCivilians) for(EntityID res : this.receivedAgentCivilians)
{ {
messageManager.addMessage(new MessageCivilian(true, StandardMessagePriority.HIGH, (Civilian)this.worldInfo.getEntity(res))); messageManager.addMessage(new MessageCivilian(true, (Civilian)this.worldInfo.getEntity(res)));
this.finishreceivedCivilians.add(res); this.finishreceivedCivilians.add(res);
} }
this.receivedAgentCivilians.clear(); this.receivedAgentCivilians.clear();
......
package autumn_2023.module.complex;
import static rescuecore2.standard.entities.StandardEntityURN.AMBULANCE_TEAM;
import static rescuecore2.standard.entities.StandardEntityURN.CIVILIAN;
import static rescuecore2.standard.entities.StandardEntityURN.REFUGE;
import adf.core.agent.communication.MessageManager;
import adf.core.agent.communication.standard.bundle.MessageUtil;
import adf.core.agent.communication.standard.bundle.StandardMessagePriority;
import adf.core.agent.communication.standard.bundle.information.MessageCivilian;
import adf.core.agent.develop.DevelopData;
import adf.core.agent.info.AgentInfo;
import adf.core.agent.info.ScenarioInfo;
import adf.core.agent.info.WorldInfo;
import adf.core.agent.module.ModuleManager;
import adf.core.component.communication.CommunicationMessage;
import adf.core.component.module.algorithm.Clustering;
import adf.core.component.module.algorithm.PathPlanning;
import adf.core.component.module.complex.HumanDetector;
import adf.core.debug.DefaultLogger;
import autumn_2023.module.comm.infomation.MessageCost;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.log4j.Logger;
import rescuecore2.standard.entities.AmbulanceCentre;
import rescuecore2.standard.entities.Civilian;
import rescuecore2.standard.entities.Human;
import rescuecore2.standard.entities.StandardEntity;
import rescuecore2.standard.entities.StandardEntityURN;
import rescuecore2.worldmodel.EntityID;
public class SampleHumanDetector extends HumanDetector {
private Clustering clustering;
private EntityID result;
private Logger logger;
// 救急司令所からの埋没市民のメッセージリスト
private List<EntityID> receivedCentreCivilians = new ArrayList<>();
// コスト計算用パスプランニング
private PathPlanning pathplanning;
public SampleHumanDetector(AgentInfo ai, WorldInfo wi, ScenarioInfo si, ModuleManager moduleManager, DevelopData developData) {
super(ai, wi, si, moduleManager, developData);
logger = DefaultLogger.getLogger(agentInfo.me());
this.clustering = moduleManager.getModule("SampleHumanDetector.Clustering",
"adf.impl.module.algorithm.KMeansClustering");
// 追加
this.pathplanning = moduleManager.getModule("SampleHumanDetector.PathPlanning", "adf.impl.module.algorithm.DijkstraPathPlanning");
registerModule(this.clustering);
}
@Override
public HumanDetector updateInfo(MessageManager messageManager) {
logger.debug("Time:" + agentInfo.getTime());
super.updateInfo(messageManager);
this.pathplanning.updateInfo(messageManager);
// そのステップで受信した(前ステップで送信された)メッセージ一覧
List<CommunicationMessage> messages = messageManager.getReceivedMessageList();
for(CommunicationMessage ms : messages)
{
// msが市民の情報であれば
if (ms instanceof MessageCivilian)
{
MessageCivilian msCiv = (MessageCivilian) ms;
MessageUtil.reflectMessage(this.worldInfo, msCiv);
if (this.worldInfo.getEntity(msCiv.getSenderID()) instanceof AmbulanceCentre)
{
if(!receivedCentreCivilians.contains(msCiv.getAgentID()))
{
receivedCentreCivilians.add(msCiv.getAgentID());
}
}
}
}
for(EntityID receive : receivedCentreCivilians)
{
int taskcost = CalculationCost(receive);
// 新規メッセージクラスを用いて救急司令所に送信
CommunicationMessage costmes = new MessageCost(true, StandardMessagePriority.HIGH, receive, taskcost);
messageManager.addMessage(costmes);
}
// このステップ内で知覚したエンティティのうち,救助対象の市民リストを作成
Set<EntityID> changed = this.worldInfo.getChanged().getChangedEntities();
List<EntityID> changedRescueTargets = filterRescueTargets((Collection)changed);
// 司令所に送るメッセージを作成・送信(現状:救急司令所のみ)
// 市民の情報を送信
for(EntityID change : changedRescueTargets)
{
Civilian changeCivilian = (Civilian)this.worldInfo.getEntity(change);
CommunicationMessage message = new MessageCivilian(true, StandardMessagePriority.HIGH, changeCivilian);
messageManager.addMessage(message);
}
return this;
}
@Override
public HumanDetector calc() {
Human transportHuman = this.agentInfo.someoneOnBoard();
if (transportHuman != null) {
logger.debug("someoneOnBoard:" + transportHuman);
this.result = transportHuman.getID();
return this;
}
if (this.result != null) {
Human target = (Human) this.worldInfo.getEntity(this.result);
if (!isValidHuman(target)) {
logger.debug("Invalid Human:" + target + " ==>reset target");
this.result = null;
}
}
if (this.result == null) {
this.result = calcTarget();
}
return this;
}
private EntityID calcTarget() {
List<Human> rescueTargets = filterRescueTargets(
this.worldInfo.getEntitiesOfType(CIVILIAN));
List<Human> rescueTargetsInCluster = filterInCluster(rescueTargets);
List<Human> targets = rescueTargetsInCluster;
if (targets.isEmpty())
targets = rescueTargets;
logger.debug("Targets:" + targets);
if (!targets.isEmpty()) {
targets.sort(new DistanceSorter(this.worldInfo, this.agentInfo.me()));
Human selected = targets.get(0);
logger.debug("Selected:" + selected);
return selected.getID();
}
return null;
}
@Override
public EntityID getTarget() {
return this.result;
}
private List<Human>
filterRescueTargets(Collection<? extends StandardEntity> list) {
List<Human> rescueTargets = new ArrayList<>();
for (StandardEntity next : list) {
if (!(next instanceof Human))
continue;
Human h = (Human) next;
if (!isValidHuman(h))
continue;
if (h.getBuriedness() == 0)
continue;
rescueTargets.add(h);
}
return rescueTargets;
}
private List<Human>
filterInCluster(Collection<? extends StandardEntity> entities) {
int clusterIndex = clustering.getClusterIndex(this.agentInfo.getID());
List<Human> filter = new ArrayList<>();
HashSet<StandardEntity> inCluster = new HashSet<>(
clustering.getClusterEntities(clusterIndex));
for (StandardEntity next : entities) {
if (!(next instanceof Human))
continue;
Human h = (Human) next;
if (!h.isPositionDefined())
continue;
StandardEntity position = this.worldInfo.getPosition(h);
if (position == null)
continue;
if (!inCluster.contains(position))
continue;
filter.add(h);
}
return filter;
}
private class DistanceSorter implements Comparator<StandardEntity> {
private StandardEntity reference;
private WorldInfo worldInfo;
DistanceSorter(WorldInfo wi, StandardEntity reference) {
this.reference = reference;
this.worldInfo = wi;
}
public int compare(StandardEntity a, StandardEntity b) {
int d1 = this.worldInfo.getDistance(this.reference, a);
int d2 = this.worldInfo.getDistance(this.reference, b);
return d1 - d2;
}
}
private boolean isValidHuman(StandardEntity entity) {
if (entity == null)
return false;
if (!(entity instanceof Human))
return false;
Human target = (Human) entity;
if (!target.isHPDefined() || target.getHP() == 0)
return false;
if (!target.isPositionDefined())
return false;
if (!target.isDamageDefined() || target.getDamage() == 0)
return false;
if (!target.isBuriednessDefined())
return false;
StandardEntity position = worldInfo.getPosition(target);
if (position == null)
return false;
StandardEntityURN positionURN = position.getStandardURN();
if (positionURN == REFUGE || positionURN == AMBULANCE_TEAM)
return false;
return true;
}
// cost計算
private int CalculationCost(EntityID target){
double targetDistance = this.pathplanning.getDistance(this.agentInfo.getID(), target);
return (int)(Math.ceil(targetDistance / 40000));
}
}
\ No newline at end of file
#!/bin/sh
LOADER="adf.impl.DefaultLoader"
PARAMS=$*
cd `dirname $0`
if [ ! -z "$1" ]; then
./gradlew launch --args="${LOADER} ${PARAMS} -pre 0"
else
echo "Options:"
echo "-tn Team name"
echo "-t [FB],[FS],[PF],[PO],[AT],[AC] Number of agents"
echo "-fb [FB] Number of FireBrigade"
echo "-fs [FS] Number of FireStation"
echo "-pf [PF] Number of PoliceForce"
echo "-po [PO] Number of PoliceOffice"
echo "-at [AT] Number of AmbulanceTeam"
echo "-ac [AC] Number of AmbulanceCentre"
echo "-s [HOST]:[PORT] RCRS server host and port"
echo "-h [HOST] RCRS server host (port:27931)"
echo "-pre [0|1] Precompute flag"
echo "-d [0|1] Debug flag"
echo "-dev [0|1] Development mode"
echo "-mc [FILE] ModuleConfig file name"
echo "-md [JSON] ModuleConfig JSON"
echo "-df [FILE] DevelopData JSON file"
echo "-dd [JSON] DevelopData JSON"
echo "-all [alias] -t -1,-1,-1,-1,-1,-1"
echo "-allp [alias] -t 1,0,1,0,1,0,"
echo "-local [alias] -h localhost"
echo "-precompute [alias] -pre 1"
echo "-debug [alias] -d 1"
echo "-develop [alias] -dev 1"
fi
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment