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
8a7cc810
Commit
8a7cc810
authored
Nov 02, 2023
by
Joe Fujisawa
Browse files
add FBDetectorにcalcとgetResultを追加
parent
80107203
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main/java/autumn_2023/module/complex/AuctionFBHumanDetector.java
View file @
8a7cc810
package
autumn_2023.module.complex
;
package
autumn_2023.module.complex
;
public
class
AuctionFBHumanDetector
{
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.module.complex.HumanDetector
;
import
rescuecore2.standard.entities.Civilian
;
import
rescuecore2.standard.entities.Human
;
import
rescuecore2.standard.entities.StandardEntity
;
import
rescuecore2.worldmodel.EntityID
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
public
class
AuctionFBHumanDetector
extends
HumanDetector
{
private
EntityID
result
=
null
;
public
AuctionFBHumanDetector
(
AgentInfo
ai
,
WorldInfo
wi
,
ScenarioInfo
si
,
ModuleManager
moduleManager
,
DevelopData
developData
)
{
super
(
ai
,
wi
,
si
,
moduleManager
,
developData
);
}
@Override
public
EntityID
getTarget
()
{
return
this
.
result
;
}
@Override
public
HumanDetector
calc
()
{
final
Set
<
EntityID
>
rescueTargetInSamePosition
=
this
.
worldInfo
.
getChanged
().
getChangedEntities
().
parallelStream
()
.
map
(
this
.
worldInfo
::
getEntity
)
.
filter
(
Civilian
.
class
::
isInstance
)
.
map
(
Civilian
.
class
::
cast
)
.
filter
(
e
->
this
.
agentInfo
.
getPosition
().
equals
(
e
.
getPosition
()))
.
filter
(
Human:
:
isHPDefined
)
.
filter
(
e
->
e
.
getHP
()
>
0
)
.
filter
(
Human:
:
isBuriednessDefined
)
.
filter
(
e
->
e
.
getBuriedness
()
>
0
)
.
map
(
StandardEntity:
:
getID
)
.
collect
(
Collectors
.
toSet
());
if
(
rescueTargetInSamePosition
.
isEmpty
())
{
this
.
result
=
null
;
return
this
;
}
if
(
rescueTargetInSamePosition
.
contains
(
this
.
result
))
{
return
this
;
}
this
.
result
=
rescueTargetInSamePosition
.
stream
().
findAny
().
orElse
(
null
);
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