Commit a90fecd6 authored by k20066's avatar k20066
Browse files

quick start rescue

parent b6aaede1
......@@ -16,6 +16,7 @@ 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.complex.HumanDetector;
import adf.core.debug.DefaultLogger;
......@@ -25,7 +26,9 @@ import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.log4j.Logger;
......@@ -95,7 +98,31 @@ public class CentralizedControlFBHumanDetector extends HumanDetector {
public HumanDetector calc() {
if(this.agentInfo.getTime() < scenarioInfo.getKernelAgentsIgnoreuntil()) return this;
this.result = null;
Set<EntityID> mescivs = this.mm.getReceivedMessageList(MessageCivilian.class).stream()
.map(MessageCivilian.class::cast)
.map(MessageCivilian::getAgentID)
.collect(Collectors.toSet());
Set<EntityID> changecivs = this.agentInfo.getChanged().getChangedEntities().stream()
.map(this.worldInfo::getEntity)
.filter(e -> (e instanceof Civilian))
.map(Civilian.class::cast)
.filter(Civilian::isBuriednessDefined)
.filter(e -> e.getBuriedness() != 0)
.map(Civilian::getID)
.collect(Collectors.toSet());
changecivs.removeAll(mescivs);
EntityID myid = this.agentInfo.getID();
Optional<EntityID> minID = changecivs.stream()
.min((e1,e2) -> {
return(this.worldInfo.getDistance(myid, e1) - this.worldInfo.getDistance(myid, e2));
});
if(minID.isEmpty()) return this;
this.result = minID.get();;
return this;
}
......
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