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