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
af8744d9
Commit
af8744d9
authored
Nov 07, 2023
by
k20066
Browse files
search modify
parent
f9f134f9
Changes
3
Show whitespace changes
Inline
Side-by-side
src/main/java/autumn_2023/centralized/CentralizedControlCommandExecutorFire.java
View file @
af8744d9
...
...
@@ -74,7 +74,6 @@ public class CentralizedControlCommandExecutorFire extends CommandExecutor<Comma
@Override
public
CommandExecutor
setCommand
(
CommandFire
command
)
{
EntityID
agentID
=
this
.
agentInfo
.
getID
();
System
.
out
.
println
(
"time:"
+
this
.
agentInfo
.
getTime
()+
" fbid:"
+
this
.
agentInfo
.
getID
()+
" commandAction:"
+
command
.
getAction
()+
" commandTarget:"
+
command
.
getTargetID
()+
" commanderID:"
+
command
.
getSenderID
());
if
(!
this
.
commandCompleted
)
return
this
;
if
(
command
.
isToIDDefined
()
&&
Objects
.
requireNonNull
(
command
.
getToID
()).
getValue
()
==
agentID
.
getValue
())
{
this
.
commandType
=
command
.
getAction
();
// 司令で出された行動内容
...
...
src/main/java/autumn_2023/module/complex/CentralizedControlFBAllocator.java
View file @
af8744d9
...
...
@@ -165,7 +165,7 @@ public class CentralizedControlFBAllocator extends FireTargetAllocator {
if
(
allocate
[
i
]
==
-
1
)
continue
;
this
.
fireBrigadeInfoMap
.
get
(
rowlist
.
get
(
i
)).
target
=
collist
.
get
(
allocate
[
i
]);
}
this
.
printAllocate
(
allocate
,
rowlist
,
collist
,
row
);
//
this.printAllocate(allocate, rowlist, collist, row);
return
this
;
}
...
...
@@ -191,7 +191,6 @@ public class CentralizedControlFBAllocator extends FireTargetAllocator {
.
filter
(
e
->
!(
finishEntityIDs
.
contains
(
e
)))
.
collect
(
Collectors
.
toSet
());
System
.
out
.
println
(
"time:"
+
this
.
agentInfo
.
getTime
()+
" centerid:"
+
this
.
agentInfo
.
getID
()+
" recievetasks:"
+
recievetasks
);
this
.
taskSet
.
addAll
(
recievetasks
);
// 消防隊の情報をリセット
...
...
@@ -210,7 +209,6 @@ public class CentralizedControlFBAllocator extends FireTargetAllocator {
fbi
.
setInfo
(
mesfb
.
getTargetID
(),
mesfb
.
getPosition
(),
mesfb
.
getBuriedness
(),
(
mesfb
.
getAction
()
==
MessageFireBrigade
.
ACTION_RESCUE
)
?
false
:
true
,
this
.
agentInfo
.
getTime
());
}
System
.
out
.
println
(
"time:"
+
this
.
agentInfo
.
getTime
()+
" centerid:"
+
this
.
agentInfo
.
getID
()+
" fblist:"
+
fblist
);
List
<
EntityID
>
reportlist
=
messageManager
.
getReceivedMessageList
(
MessageReport
.
class
).
stream
()
.
map
(
MessageReport
.
class
::
cast
)
...
...
src/main/java/autumn_2023/module/complex/SampleSearch.java
View file @
af8744d9
...
...
@@ -14,6 +14,7 @@ import adf.core.agent.develop.DevelopData;
import
rescuecore2.standard.entities.*
;
import
rescuecore2.worldmodel.EntityID
;
import
java.util.*
;
import
java.util.stream.Collector
;
import
java.util.stream.Collectors
;
import
static
java
.
lang
.
Double
.
POSITIVE_INFINITY
;
...
...
@@ -57,11 +58,39 @@ public class SampleSearch extends Search
List
<
CommunicationMessage
>
messages
=
mm
.
getReceivedMessageList
();
this
.
messageManager
=
mm
;
int
idx
=
this
.
clustering
.
getClusterIndex
(
this
.
agentInfo
.
me
());
Collection
<
EntityID
>
cluster
=
this
.
clustering
.
getClusterEntityIDs
(
idx
);
if
(
cluster
==
null
)
return
this
;
// エージェントが動けるステップではないなら
if
(
this
.
agentInfo
.
getTime
()
<
this
.
scenarioInfo
.
getKernelAgentsIgnoreuntil
())
return
this
;
// エージェントが動けるステップのはじめに
if
(
this
.
agentInfo
.
getTime
()
==
this
.
scenarioInfo
.
getKernelAgentsIgnoreuntil
()){
this
.
list
=
new
ArrayList
<>(
cluster
);
}
// エージェントが現在位置する建物や道路のIDを取得する
EntityID
position
=
this
.
agentInfo
.
getPosition
();
// 探索済みの (辿り着いたことがある) 対象を候補から除外する
this
.
searchedSet
.
add
(
position
);
// 探索済みの (辿り着いたことがある) 対象を候補から除外する
list
.
removeAll
(
this
.
searchedSet
);
// クラスタ内の建物や道路のIDリストから建物のIDリストを取得
List
<
EntityID
>
buildinglist
=
this
.
list
.
stream
()
// listのストリームを取得
.
map
(
this
.
worldInfo
::
getEntity
)
// EntityIDをStandardEntityに変換
.
filter
(
e
->
(
e
instanceof
Building
))
// StandardEntityオブジェクトのうちBuildingクラスのものだけ抽出
.
map
(
StandardEntity:
:
getID
)
// StandardEntityをEntityIDに変換
.
collect
(
Collectors
.
toList
());
// ストリームをリストにして取得
// すべての対象が探索済みの場合,探索済みリストをリセット候補をリセットする
if
(
buildinglist
.
isEmpty
()){
this
.
searchedSet
.
clear
();
this
.
list
=
new
ArrayList
<>(
cluster
);
}
return
this
;
}
...
...
@@ -69,24 +98,17 @@ public class SampleSearch extends Search
@Override
public
Search
calc
()
{
// エージェントが動けるステップではないなら
if
(
this
.
agentInfo
.
getTime
()
<
this
.
scenarioInfo
.
getKernelAgentsIgnoreuntil
())
return
this
;
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());
if
(
idx
==
-
1
)
return
this
;
Collection
<
EntityID
>
cluster
=
this
.
clustering
.
getClusterEntityIDs
(
idx
);
if
(
cluster
==
null
)
{
return
this
;
}
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);
}
//System.out.println("time:"+this.agentInfo.getTime()+" id:"+me+" target:"+this.getTarget());
// エージェントが現在位置する建物や道路のIDを取得する
EntityID
position
=
this
.
agentInfo
.
getPosition
();
...
...
@@ -95,26 +117,21 @@ public class SampleSearch extends Search
return
this
;
}
// 探索済みの (辿り着いたことがある) 対象を候補から除外する
list
.
removeAll
(
this
.
searchedSet
);
// すべての対象が探索済みの場合,候補をリセットする
if
(
list
.
size
()
<=
0
)
{
this
.
searchedSet
.
clear
();
list
=
new
ArrayList
<>(
cluster
);
}
// クラスタ内の建物や道路のIDリストから建物のIDリストを取得
List
<
EntityID
>
buildinglist
=
list
.
stream
()
// listのストリームを取得
.
map
(
this
.
worldInfo
::
getEntity
)
// EntityIDをStandardEntityに変換
.
filter
(
e
->
(
e
instanceof
Building
))
// StandardEntityオブジェクトのうちBuildingクラスのものだけ抽出
.
map
(
StandardEntity:
:
getID
)
// StandardEntityをEntityIDに変換
.
collect
(
Collectors
.
toList
());
// ストリームをリストにして取得
double
near
=
Double
.
MAX_VALUE
;
for
(
EntityID
lists
:
this
.
list
)
{
StandardEntity
test
=
this
.
worldInfo
.
getEntity
(
lists
);
if
(
test
instanceof
Building
)
{
for
(
EntityID
lists
:
buildinglist
)
{
double
distance
=
this
.
worldInfo
.
getDistance
(
position
,
lists
);
if
(
distance
<
near
){
near
=
distance
;
this
.
result
=
lists
;
}
}
}
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