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
088d09de
Commit
088d09de
authored
Nov 04, 2023
by
k20066
Browse files
finished
parent
68c5b1e6
Changes
9
Show whitespace changes
Inline
Side-by-side
config/module.cfg
View file @
088d09de
## DefaultTacticsAmbulanceTeam
DefaultTacticsAmbulanceTeam.HumanDetector : autumn_2023.module.complex.CentralizedControlATHumanDetector
DefaultTacticsAmbulanceTeam.Search :
sample_team
.module.complex.SampleSearch
DefaultTacticsAmbulanceTeam.Search :
autumn_2023
.module.complex.SampleSearch
DefaultTacticsAmbulanceTeam.ExtActionTransport : adf.impl.extaction.DefaultExtActionTransport
DefaultTacticsAmbulanceTeam.ExtActionMove : adf.impl.extaction.DefaultExtActionMove
DefaultTacticsAmbulanceTeam.CommandExecutorAmbulance : adf.impl.centralized.DefaultCommandExecutorAmbulance
DefaultTacticsAmbulanceTeam.CommandExecutorAmbulance : autumn_2023.centralized.CentralizedControlCommandExecutorA
DefaultTacticsAmbulanceTeam.CommandExecutorScout : adf.impl.centralized.DefaultCommandExecutorScout
## DefaultTacticsFireBrigade
DefaultTacticsFireBrigade.HumanDetector : autumn_2023.module.complex.CentralizedControlFBHumanDetector
DefaultTacticsFireBrigade.Search :
sample_team
.module.complex.SampleSearch
DefaultTacticsFireBrigade.Search :
autumn_2023
.module.complex.SampleSearch
DefaultTacticsFireBrigade.ExtActionFireRescue : autumn_2023.extaction.ComplimentTacticsExtActionFireRescue
DefaultTacticsFireBrigade.ExtActionMove : adf.impl.extaction.DefaultExtActionMove
DefaultTacticsFireBrigade.CommandExecutorFire : autumn_2023.centralized.CentralizedControlCommandExecutorF
DefaultTacticsFireBrigade.CommandExecutorFire : autumn_2023.centralized.CentralizedControlCommandExecutorF
ire
DefaultTacticsFireBrigade.CommandExecutorScout : adf.impl.centralized.DefaultCommandExecutorScout
## DefaultTacticsPoliceForce
...
...
@@ -28,7 +27,7 @@ DefaultTacticsAmbulanceCentre.TargetAllocator : sample_team.module.complex.Sampl
DefaultTacticsAmbulanceCentre.CommandPicker : adf.impl.centralized.DefaultCommandPickerAmbulance
## DefaultTacticsFireStation
DefaultTacticsFireStation.CommandPicker : a
df.impl
.centralized.
Default
CommandPickerFire
DefaultTacticsFireStation.CommandPicker : a
utumn_2023
.centralized.
CentralizedControl
CommandPickerFire
TacticsFireStation.TargetAllocator : autumn_2023.module.complex.CentralizedControlFBAllocator
## DefaultTacticsPoliceOffice
...
...
@@ -93,8 +92,8 @@ DefaultCommandExecutorScoutPolice.PathPlanning : adf.impl.module.algorithm.Dijks
DefaultCommandExecutorScoutPolice.ExtActionClear : adf.impl.extaction.DefaultExtActionClear
## MessageManager
MessageManager.PlatoonChannelSubscriber : a
df.impl
.module.comm.
Default
ChannelSubscriber
MessageManager.CenterChannelSubscriber : a
df.impl
.module.comm.
Default
ChannelSubscriber
MessageManager.PlatoonChannelSubscriber : a
utumn_2023
.module.comm.
CentralizedControl
ChannelSubscriber
MessageManager.CenterChannelSubscriber : a
utumn_2023
.module.comm.
CentralizedControl
ChannelSubscriber
MessageManager.PlatoonMessageCoordinator : autumn_2023.module.comm.CentralizedControlMessageCoordinator
MessageManager.CenterMessageCoordinator : autumn_2023.module.comm.CentralizedControlMessageCoordinator
...
...
src/main/java/autumn_2023/centralized/CentralizedControlCommandExecutorF.java
→
src/main/java/autumn_2023/centralized/CentralizedControlCommandExecutorF
ire
.java
View file @
088d09de
...
...
@@ -26,7 +26,7 @@ import rescuecore2.standard.entities.Human;
import
rescuecore2.standard.entities.StandardEntity
;
import
rescuecore2.worldmodel.EntityID
;
public
class
CentralizedControlCommandExecutorF
extends
CommandExecutor
<
CommandFire
>
{
public
class
CentralizedControlCommandExecutorF
ire
extends
CommandExecutor
<
CommandFire
>
{
private
static
final
int
ACTION_UNKNOWN
=
-
1
;
private
static
final
int
ACTION_REST
=
CommandFire
.
ACTION_REST
;
...
...
@@ -45,7 +45,7 @@ public class CentralizedControlCommandExecutorF extends CommandExecutor<CommandF
private
boolean
commandCompleted
;
public
CentralizedControlCommandExecutorF
(
AgentInfo
ai
,
WorldInfo
wi
,
ScenarioInfo
si
,
ModuleManager
moduleManager
,
DevelopData
developData
)
{
public
CentralizedControlCommandExecutorF
ire
(
AgentInfo
ai
,
WorldInfo
wi
,
ScenarioInfo
si
,
ModuleManager
moduleManager
,
DevelopData
developData
)
{
super
(
ai
,
wi
,
si
,
moduleManager
,
developData
);
this
.
commandType
=
ACTION_UNKNOWN
;
this
.
target
=
null
;
...
...
@@ -67,21 +67,26 @@ public class CentralizedControlCommandExecutorF extends CommandExecutor<CommandF
}
}
/**
* 受信した司令を入力するためのメソッド
* @param command 受信した司令
*/
@Override
public
CommandExecutor
setCommand
(
CommandFire
command
)
{
EntityID
agentID
=
this
.
agentInfo
.
getID
();
if
(!
this
.
commandCompleted
)
return
this
;
if
(
command
.
isToIDDefined
()
&&
Objects
.
requireNonNull
(
command
.
getToID
())
.
getValue
()
==
agentID
.
getValue
())
{
this
.
commandType
=
command
.
getAction
();
this
.
target
=
command
.
getTargetID
();
this
.
commanderID
=
command
.
getSenderID
();
if
(
command
.
isToIDDefined
()
&&
Objects
.
requireNonNull
(
command
.
getToID
()).
getValue
()
==
agentID
.
getValue
())
{
this
.
commandType
=
command
.
getAction
();
// 司令で出された行動内容
this
.
target
=
command
.
getTargetID
();
// タスクとなる対象のID
this
.
commanderID
=
command
.
getSenderID
();
// 司令を出した司令所のID
}
return
this
;
}
/**
* 現在実行している司令が完了しているかを判定する
* 完了しているなら,消防司令所へ救助完了の報告を送る
*/
@Override
public
CommandExecutor
updateInfo
(
MessageManager
messageManager
)
{
super
.
updateInfo
(
messageManager
);
...
...
@@ -95,8 +100,7 @@ public class CentralizedControlCommandExecutorF extends CommandExecutor<CommandF
this
.
commandCompleted
=
this
.
isCommandCompleted
(
this
.
commandType
);
if
(
this
.
commandCompleted
)
{
if
(
this
.
commandType
!=
ACTION_UNKNOWN
)
{
messageManager
.
addMessage
(
new
MessageReport
(
true
,
true
,
false
,
this
.
target
));
messageManager
.
addMessage
(
new
MessageReport
(
true
,
true
,
false
,
this
.
target
));
this
.
commandType
=
ACTION_UNKNOWN
;
this
.
target
=
null
;
...
...
@@ -145,7 +149,12 @@ public class CentralizedControlCommandExecutorF extends CommandExecutor<CommandF
return
this
;
}
/**
* 受け取った司令を元に行動を決定・実行するためのメソッド
*
* 司令で出された行動内容によって救助活動を決定する
* ※実装では司令で出される行動内容はACTION_AUTONOMYになっている
*/
@Override
public
CommandExecutor
calc
()
{
this
.
result
=
null
;
...
...
@@ -153,8 +162,7 @@ public class CentralizedControlCommandExecutorF extends CommandExecutor<CommandF
case
ACTION_REST:
EntityID
position
=
this
.
agentInfo
.
getPosition
();
if
(
this
.
target
==
null
)
{
Collection
<
EntityID
>
refuges
=
this
.
worldInfo
.
getEntityIDsOfType
(
REFUGE
);
Collection
<
EntityID
>
refuges
=
this
.
worldInfo
.
getEntityIDsOfType
(
REFUGE
);
if
(
refuges
.
contains
(
position
))
{
this
.
result
=
new
ActionRest
();
}
else
{
...
...
@@ -181,14 +189,12 @@ public class CentralizedControlCommandExecutorF extends CommandExecutor<CommandF
return
this
;
case
ACTION_MOVE:
if
(
this
.
target
!=
null
)
{
this
.
result
=
this
.
actionExtMove
.
setTarget
(
this
.
target
).
calc
()
.
getAction
();
this
.
result
=
this
.
actionExtMove
.
setTarget
(
this
.
target
).
calc
().
getAction
();
}
return
this
;
case
ACTION_RESCUE:
if
(
this
.
target
!=
null
)
{
this
.
result
=
this
.
actionFireRescue
.
setTarget
(
this
.
target
).
calc
()
.
getAction
();
this
.
result
=
this
.
actionFireRescue
.
setTarget
(
this
.
target
).
calc
().
getAction
();
}
return
this
;
case
ACTION_AUTONOMY:
...
...
@@ -197,16 +203,20 @@ public class CentralizedControlCommandExecutorF extends CommandExecutor<CommandF
}
StandardEntity
targetEntity
=
this
.
worldInfo
.
getEntity
(
this
.
target
);
if
(
targetEntity
instanceof
Area
)
{
this
.
result
=
this
.
actionExtMove
.
setTarget
(
this
.
target
).
calc
()
.
getAction
();
this
.
result
=
this
.
actionExtMove
.
setTarget
(
this
.
target
).
calc
().
getAction
();
}
else
if
(
targetEntity
instanceof
Human
)
{
this
.
result
=
this
.
actionFireRescue
.
setTarget
(
this
.
target
).
calc
()
.
getAction
();
this
.
result
=
this
.
actionFireRescue
.
setTarget
(
this
.
target
).
calc
().
getAction
();
}
}
return
this
;
}
/**
* 司令が完了したかを判定するメソッド
*
* @param commandType 司令の種類
* @return true : 完了 false : 実行中
*/
private
boolean
isCommandCompleted
(
int
commandType
)
{
Human
agent
=
(
Human
)
this
.
agentInfo
.
me
();
switch
(
commandType
)
{
...
...
@@ -228,10 +238,10 @@ public class CentralizedControlCommandExecutorF extends CommandExecutor<CommandF
if
(
this
.
target
==
null
)
{
return
true
;
}
Human
human
=
(
Human
)
Objects
.
requireNonNull
(
this
.
worldInfo
.
getEntity
(
this
.
target
));
Human
human
=
(
Human
)
Objects
.
requireNonNull
(
this
.
worldInfo
.
getEntity
(
this
.
target
));
return
human
.
isBuriednessDefined
()
&&
human
.
getBuriedness
()
==
0
||
(
human
.
isHPDefined
()
&&
human
.
getHP
()
==
0
);
case
ACTION_AUTONOMY:
if
(
this
.
target
!=
null
)
{
StandardEntity
targetEntity
=
this
.
worldInfo
.
getEntity
(
this
.
target
);
...
...
src/main/java/autumn_2023/centralized/CentralizedControlCommandPickerFire.java
0 → 100644
View file @
088d09de
package
autumn_2023.centralized
;
import
adf.core.agent.communication.standard.bundle.centralized.CommandFire
;
import
adf.core.agent.communication.standard.bundle.centralized.CommandScout
;
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.centralized.CommandPicker
;
import
adf.core.component.communication.CommunicationMessage
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Map
;
import
rescuecore2.standard.entities.Area
;
import
rescuecore2.standard.entities.Human
;
import
rescuecore2.standard.entities.StandardEntity
;
import
rescuecore2.standard.entities.StandardEntityURN
;
import
rescuecore2.worldmodel.EntityID
;
public
class
CentralizedControlCommandPickerFire
extends
CommandPicker
{
private
int
scoutDistance
;
private
Collection
<
CommunicationMessage
>
messages
;
private
Map
<
EntityID
,
EntityID
>
allocationData
;
public
CentralizedControlCommandPickerFire
(
AgentInfo
ai
,
WorldInfo
wi
,
ScenarioInfo
si
,
ModuleManager
moduleManager
,
DevelopData
developData
)
{
super
(
ai
,
wi
,
si
,
moduleManager
,
developData
);
this
.
messages
=
new
ArrayList
<>();
this
.
allocationData
=
null
;
this
.
scoutDistance
=
developData
.
getInteger
(
"adf.impl.centralized.DefaultCommandPickerFire.scoutDistance"
,
40000
);
}
/**
* TargetAllocatorの計算結果を入力するためのメソッド
*
* @param allocationData TargetAllocatorのgetResultメソッドの戻り値
*/
@Override
public
CommandPicker
setAllocatorResult
(
Map
<
EntityID
,
EntityID
>
allocationData
)
{
this
.
allocationData
=
allocationData
;
return
this
;
}
/**
* 司令を生成・リスト化するためのメソッド
* 司令はTargetAllocatorから受け取った司令内容をもとに生成される
*/
@Override
public
CommandPicker
calc
()
{
this
.
messages
.
clear
();
if
(
this
.
allocationData
==
null
)
{
return
this
;
}
for
(
EntityID
agentID
:
this
.
allocationData
.
keySet
())
{
StandardEntity
agent
=
this
.
worldInfo
.
getEntity
(
agentID
);
if
(
agent
!=
null
&&
agent
.
getStandardURN
()
==
StandardEntityURN
.
FIRE_BRIGADE
)
{
StandardEntity
target
=
this
.
worldInfo
.
getEntity
(
this
.
allocationData
.
get
(
agentID
));
if
(
target
!=
null
)
{
if
(
target
instanceof
Human
)
{
CommandFire
command
=
new
CommandFire
(
true
,
agentID
,
target
.
getID
(),
CommandFire
.
ACTION_AUTONOMY
);
this
.
messages
.
add
(
command
);
}
}
}
}
return
this
;
}
/**
* calcメソッドで生成した司令リストを取得するためのメソッド
* @return 司令リスト
*/
@Override
public
Collection
<
CommunicationMessage
>
getResult
()
{
return
this
.
messages
;
}
}
\ No newline at end of file
src/main/java/autumn_2023/extaction/ComplimentTacticsExtActionFireRescue.java
View file @
088d09de
...
...
@@ -24,6 +24,7 @@ import rescuecore2.standard.entities.Human;
import
rescuecore2.standard.entities.StandardEntity
;
import
rescuecore2.worldmodel.EntityID
;
// ADFのDefaultTacticsFireBrigadeの修正用プログラム 無視してよい
public
class
ComplimentTacticsExtActionFireRescue
extends
ExtAction
{
private
MessageManager
mm
;
...
...
src/main/java/autumn_2023/module/comm/CentralizedControlChannelSubscriber.java
0 → 100644
View file @
088d09de
package
autumn_2023.module.comm
;
import
adf.core.agent.communication.MessageManager
;
import
adf.core.agent.info.AgentInfo
;
import
adf.core.agent.info.ScenarioInfo
;
import
adf.core.agent.info.WorldInfo
;
import
adf.core.component.communication.ChannelSubscriber
;
import
rescuecore2.standard.entities.StandardEntityURN
;
public
class
CentralizedControlChannelSubscriber
extends
ChannelSubscriber
{
@Override
public
void
subscribe
(
AgentInfo
agentInfo
,
WorldInfo
worldInfo
,
ScenarioInfo
scenarioInfo
,
MessageManager
messageManager
)
{
// subscribe only once at the beginning
if
(
agentInfo
.
getTime
()
==
1
)
{
int
numChannels
=
scenarioInfo
.
getCommsChannelsCount
()
-
1
;
// 0th channel
// is the
// voice
// channel
int
maxChannelCount
=
0
;
boolean
isPlatoon
=
isPlatoonAgent
(
agentInfo
,
worldInfo
);
if
(
isPlatoon
)
{
maxChannelCount
=
scenarioInfo
.
getCommsChannelsMaxPlatoon
();
}
else
{
maxChannelCount
=
scenarioInfo
.
getCommsChannelsMaxOffice
();
}
StandardEntityURN
agentType
=
getAgentType
(
agentInfo
,
worldInfo
);
int
[]
channels
=
new
int
[
maxChannelCount
];
for
(
int
i
=
0
;
i
<
maxChannelCount
;
i
++)
{
channels
[
i
]
=
getChannelNumber
(
agentType
,
i
,
numChannels
);
}
messageManager
.
subscribeToChannels
(
channels
);
}
}
protected
boolean
isPlatoonAgent
(
AgentInfo
agentInfo
,
WorldInfo
worldInfo
)
{
StandardEntityURN
agentType
=
getAgentType
(
agentInfo
,
worldInfo
);
if
(
agentType
==
StandardEntityURN
.
FIRE_BRIGADE
||
agentType
==
StandardEntityURN
.
POLICE_FORCE
||
agentType
==
StandardEntityURN
.
AMBULANCE_TEAM
)
{
return
true
;
}
return
false
;
}
protected
StandardEntityURN
getAgentType
(
AgentInfo
agentInfo
,
WorldInfo
worldInfo
)
{
StandardEntityURN
agentType
=
worldInfo
.
getEntity
(
agentInfo
.
getID
())
.
getStandardURN
();
return
agentType
;
}
public
static
int
getChannelNumber
(
StandardEntityURN
agentType
,
int
channelIndex
,
int
numChannels
)
{
int
agentIndex
=
0
;
if
(
agentType
==
StandardEntityURN
.
FIRE_BRIGADE
||
agentType
==
StandardEntityURN
.
FIRE_STATION
)
{
agentIndex
=
1
;
}
else
if
(
agentType
==
StandardEntityURN
.
POLICE_FORCE
||
agentType
==
StandardEntityURN
.
POLICE_OFFICE
)
{
agentIndex
=
2
;
}
else
if
(
agentType
==
StandardEntityURN
.
AMBULANCE_TEAM
||
agentType
==
StandardEntityURN
.
AMBULANCE_CENTRE
)
{
agentIndex
=
3
;
}
int
index
=
(
3
*
channelIndex
)
+
agentIndex
;
if
((
index
%
numChannels
)
==
0
)
{
index
=
numChannels
;
}
else
{
index
=
index
%
numChannels
;
}
return
index
;
}
public
static
void
main
(
String
[]
args
)
{
int
numChannels
=
6
;
int
maxChannels
=
2
;
for
(
int
i
=
0
;
i
<
maxChannels
;
i
++)
{
System
.
out
.
println
(
"FIREBRIGADE-"
+
i
+
":"
+
getChannelNumber
(
StandardEntityURN
.
FIRE_BRIGADE
,
i
,
numChannels
));
}
for
(
int
i
=
0
;
i
<
maxChannels
;
i
++)
{
System
.
out
.
println
(
"POLICE-"
+
i
+
":"
+
getChannelNumber
(
StandardEntityURN
.
POLICE_OFFICE
,
i
,
numChannels
));
}
for
(
int
i
=
0
;
i
<
maxChannels
;
i
++)
{
System
.
out
.
println
(
"AMB-"
+
i
+
":"
+
getChannelNumber
(
StandardEntityURN
.
AMBULANCE_CENTRE
,
i
,
numChannels
));
}
}
}
\ No newline at end of file
src/main/java/autumn_2023/module/complex/CentralizedControlATHumanDetector.java
View file @
088d09de
...
...
@@ -52,7 +52,11 @@ public class CentralizedControlATHumanDetector extends HumanDetector {
registerModule
(
this
.
clustering
);
}
/**
* 新しく受信したメッセージから情報を取得するためのメソッド
*
* 現在のステップで知覚した埋没市民を送信する
*/
@Override
public
HumanDetector
updateInfo
(
MessageManager
messageManager
)
{
logger
.
debug
(
"Time:"
+
agentInfo
.
getTime
());
...
...
@@ -76,7 +80,9 @@ public class CentralizedControlATHumanDetector extends HumanDetector {
return
this
;
}
/**
* 搬送対象のIDを求めるメソッド
*/
@Override
public
HumanDetector
calc
()
{
Human
transportHuman
=
this
.
agentInfo
.
someoneOnBoard
();
...
...
@@ -118,7 +124,9 @@ public class CentralizedControlATHumanDetector extends HumanDetector {
return
null
;
}
/**
* 救助対象IDを返すメソッド
*/
@Override
public
EntityID
getTarget
()
{
return
this
.
result
;
...
...
src/main/java/autumn_2023/module/complex/CentralizedControlFBAllocator.java
View file @
088d09de
...
...
@@ -80,12 +80,22 @@ public class CentralizedControlFBAllocator extends FireTargetAllocator {
return
this
;
}
/**
* calcメソッドで算出した司令内容を返すためのメソッド
*/
@Override
public
Map
<
EntityID
,
EntityID
>
getResult
()
{
return
this
.
convert
(
this
.
fireBrigadeInfoMap
);
}
/**
* 消防隊情報を
* key:命令対象のエージェントのID
* value:やるべきタスク(市民)のID
* のMapに変換するメソッド
* @param map 消防隊IDと消防隊情報に関連するMap
* @return 司令情報となるMap
*/
private
Map
<
EntityID
,
EntityID
>
convert
(
Map
<
EntityID
,
FireBrigadeInfo
>
map
)
{
Map
<
EntityID
,
EntityID
>
result
=
new
HashMap
<>();
for
(
EntityID
id
:
map
.
keySet
())
{
...
...
@@ -97,6 +107,11 @@ public class CentralizedControlFBAllocator extends FireTargetAllocator {
return
result
;
}
/**
* 分散エージェントへの司令内容を算出するためのメソッド
*
* ハンガリアンアルゴリズムを利用して消防隊に担当させるタスクを決定する
*/
@Override
public
FireTargetAllocator
calc
()
{
if
(
this
.
agentInfo
.
getTime
()
<
scenarioInfo
.
getKernelAgentsIgnoreuntil
())
return
this
;
...
...
@@ -154,7 +169,13 @@ public class CentralizedControlFBAllocator extends FireTargetAllocator {
return
this
;
}
/**
* 新しく受信したメッセージから情報を取得するためのメソッド
*
* 埋没市民Setを更新
* 消防隊情報Setを更新
* 消防隊から司令完了を受けたときタスク完了リストを更新
*/
@Override
public
FireTargetAllocator
updateInfo
(
MessageManager
messageManager
)
{
super
.
updateInfo
(
messageManager
);
...
...
@@ -194,6 +215,12 @@ public class CentralizedControlFBAllocator extends FireTargetAllocator {
return
this
;
}
/**
* ある市民について消防隊による救助が必要かを判定するメソッド
*
* @param entity エンティティ
* @return true : 救助必要 false : 救助不必要
*/
private
boolean
isNeedRescueHuman
(
StandardEntity
entity
){
if
(
entity
==
null
)
return
false
;
...
...
@@ -219,6 +246,13 @@ public class CentralizedControlFBAllocator extends FireTargetAllocator {
return
true
;
}
/**
* ハンガリアンアルゴリズムの割当結果をみるためのメソッド
* @param allocate 消防隊に対応するタスク割当結果配列
* @param rowlist 消防隊IDリスト
* @param collist 埋没市民IDリスト
* @param row 消防隊の数
*/
private
void
printAllocate
(
int
[]
allocate
,
List
<
EntityID
>
rowlist
,
List
<
EntityID
>
collist
,
int
row
){
String
str
=
" allocate"
;
for
(
int
i
=
0
;
i
<
row
;
i
++){
...
...
@@ -228,6 +262,9 @@ public class CentralizedControlFBAllocator extends FireTargetAllocator {
System
.
out
.
println
(
"[FBCenter] time:"
+
this
.
agentInfo
.
getTime
()+
" id:"
+
this
.
agentInfo
.
getID
()+
str
);
}
/**
* 消防隊情報クラス
*/
private
class
FireBrigadeInfo
{
EntityID
agentID
;
...
...
@@ -247,6 +284,9 @@ public class CentralizedControlFBAllocator extends FireTargetAllocator {
canNewAction
=
true
;
commandTime
=
-
1
;
}
/**
* 消防隊に関する情報をセットするメソッド
*/
public
void
setInfo
(
EntityID
prevtarget
,
EntityID
position
,
int
buriedness
,
boolean
canNewAction
,
int
commandTime
){
this
.
prevtarget
=
prevtarget
;
this
.
position
=
position
;
...
...
src/main/java/autumn_2023/module/complex/CentralizedControlFBHumanDetector.java
View file @
088d09de
...
...
@@ -56,6 +56,12 @@ public class CentralizedControlFBHumanDetector extends HumanDetector {
}
/**
* 新しく受信したメッセージから情報を取得するためのメソッド
*
* 現在のステップで知覚した埋没市民の情報を送信する
* ※ここに消防隊の情報を送信する記述はないが,Tacticsの方で常に送信しているので記述しなくてもいい
*/
@Override
public
HumanDetector
updateInfo
(
MessageManager
messageManager
)
{
logger
.
debug
(
"Time:"
+
agentInfo
.
getTime
());
...
...
@@ -80,7 +86,11 @@ public class CentralizedControlFBHumanDetector extends HumanDetector {
return
this
;
}
/**
* 救助対象のIDを求めるメソッド
*
* 司令所の司令で行動するため,救助対象を決定しないようにしている
*/
@Override
public
HumanDetector
calc
()
{
if
(
this
.
agentInfo
.
getTime
()
<
scenarioInfo
.
getKernelAgentsIgnoreuntil
())
return
this
;
...
...
@@ -110,7 +120,9 @@ public class CentralizedControlFBHumanDetector extends HumanDetector {
return
null
;
}
/**
* 救助対象IDを返すメソッド
*/
@Override
public
EntityID
getTarget
()
{
return
this
.
result
;
...
...
src/main/java/autumn_2023/module/complex/SampleSearch.java
0 → 100644
View file @
088d09de
package
autumn_2023.module.complex
;
import
adf.core.agent.communication.MessageManager
;
import
adf.core.agent.communication.standard.bundle.StandardMessagePriority
;
import
adf.core.agent.communication.standard.bundle.centralized.CommandAmbulance
;
import
adf.core.agent.communication.standard.bundle.information.MessageCivilian
;
import
adf.core.agent.info.*
;
import
adf.core.agent.precompute.PrecomputeData
;
import
adf.core.component.communication.CommunicationMessage
;
import
adf.core.component.module.complex.Search
;
import
adf.core.component.module.algorithm.Clustering
;
import
adf.core.agent.module.ModuleManager
;
import
adf.core.agent.develop.DevelopData
;
import
rescuecore2.standard.entities.*
;
import
rescuecore2.worldmodel.EntityID
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
static
java
.
lang
.
Double
.
POSITIVE_INFINITY
;
import
static
rescuecore2
.
standard
.
entities
.
StandardEntityURN
.
AMBULANCE_TEAM
;
public
class
SampleSearch
extends
Search
{
private
EntityID
result
;
private
Clustering
clustering
;
private
Set
<
EntityID
>
searchedSet
=
new
HashSet
<>();
private
List
<
EntityID
>
list
;
private
MessageManager
messageManager
;
private
static
final
int
ACTION_LOAD
=
CommandAmbulance
.
ACTION_LOAD
;
public
SampleSearch
(
AgentInfo
ai
,
WorldInfo
wi
,
ScenarioInfo
si
,
ModuleManager
mm
,
DevelopData
dd
)
{
super
(
ai
,
wi
,
si
,
mm
,
dd
);
String
clusteringKey
=
"SampleSearch.Clustering.Ambulance"
;
this
.
clustering
=
mm
.
getModule
(
clusteringKey
,
"adf.sample.module.algorithm.SampleKMeans"
);
this
.
registerModule
(
this
.
clustering
);
}
@Override
public
EntityID
getTarget
()
{
return
this
.
result
;
}
@Override
public
Search
updateInfo
(
MessageManager
mm
)
{
super
.
updateInfo
(
mm
);
if
(
this
.
getCountUpdateInfo
()
>
1
)
return
this
;
// そのステップで受信した(前ステップで送信された)メッセージ一覧
List
<
CommunicationMessage
>
messages
=
mm
.
getReceivedMessageList
();
this
.
messageManager
=
mm
;
// エージェントが現在位置する建物や道路のIDを取得する
EntityID
position
=
this
.
agentInfo
.
getPosition
();
// 探索済みの (辿り着いたことがある) 対象を候補から除外する
this
.
searchedSet
.
add
(
position
);
return
this
;
}
@Override
public
Search
calc
()
{
EntityID
me
=
this
.
agentInfo
.
getID
();
int
idx
=
this
.
clustering
.
getClusterIndex
(
me
);
if
(
idx
==
-
1
)
{
return
this
;
}
//System.out.println("time:"+this.agentInfo.getTime()+" id:"+me+" target:"+this.getTarget());
Collection
<
EntityID
>
cluster
=
this
.
clustering
.
getClusterEntityIDs
(
idx
);
if
(
cluster
==
null
)
{
return
this
;
}
// Listに変換
if
(
this
.
result
==
null
){
list
=
new
ArrayList
<>(
cluster
);
//System.out.println(list);
}
// エージェントが現在位置する建物や道路のIDを取得する
EntityID
position
=
this
.
agentInfo
.
getPosition
();
if
(
this
.
getTarget
()
!=
null
&&
!
position
.
equals
(
this
.
getTarget
()))
{
return
this
;
}
// 探索済みの (辿り着いたことがある) 対象を候補から除外する
list
.
removeAll
(
this
.
searchedSet
);
// すべての対象が探索済みの場合,候補をリセットする
if
(
list
.
size
()
<=
0
)
{
this
.
searchedSet
.
clear
();
list
=
new
ArrayList
<>(
cluster
);
}
double
near
=
Double
.
MAX_VALUE
;
for
(
EntityID
lists
:
this
.
list
)
{
StandardEntity
test
=
this
.
worldInfo
.
getEntity
(
lists
);
if
(
test
instanceof
Building
)
{
double
distance
=
this
.
worldInfo
.
getDistance
(
position
,
lists
);
if
(
distance
<
near
){
near
=
distance
;
this
.
result
=
lists
;
}
}
}
return
this
;
}
}
\ No newline at end of file
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