Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
autumn_rrs
autumn_agent_2023
Commits
a90fecd6
Commit
a90fecd6
authored
Nov 08, 2023
by
k20066
Browse files
quick start rescue
parent
b6aaede1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/autumn_2023/module/complex/CentralizedControlFBHumanDetector.java
View file @
a90fecd6
...
@@ -16,6 +16,7 @@ import adf.core.agent.info.AgentInfo;
...
@@ -16,6 +16,7 @@ import adf.core.agent.info.AgentInfo;
import
adf.core.agent.info.ScenarioInfo
;
import
adf.core.agent.info.ScenarioInfo
;
import
adf.core.agent.info.WorldInfo
;
import
adf.core.agent.info.WorldInfo
;
import
adf.core.agent.module.ModuleManager
;
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.Clustering
;
import
adf.core.component.module.complex.HumanDetector
;
import
adf.core.component.module.complex.HumanDetector
;
import
adf.core.debug.DefaultLogger
;
import
adf.core.debug.DefaultLogger
;
...
@@ -25,7 +26,9 @@ import java.util.Collection;
...
@@ -25,7 +26,9 @@ import java.util.Collection;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
org.apache.log4j.Logger
;
import
org.apache.log4j.Logger
;
...
@@ -95,7 +98,31 @@ public class CentralizedControlFBHumanDetector extends HumanDetector {
...
@@ -95,7 +98,31 @@ public class CentralizedControlFBHumanDetector extends HumanDetector {
public
HumanDetector
calc
()
{
public
HumanDetector
calc
()
{
if
(
this
.
agentInfo
.
getTime
()
<
scenarioInfo
.
getKernelAgentsIgnoreuntil
())
return
this
;
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
;
return
this
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment