Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
marl-flatland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
manavsinghal157
marl-flatland
Commits
c1583677
Commit
c1583677
authored
4 years ago
by
Egli Adrian (IT-SCI-API-PFI)
Browse files
Options
Downloads
Patches
Plain Diff
FastTreeObs (fix) -> 0.8157
parent
64fff052
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
utils/fast_tree_obs.py
+13
-10
13 additions, 10 deletions
utils/fast_tree_obs.py
with
13 additions
and
10 deletions
utils/fast_tree_obs.py
+
13
−
10
View file @
c1583677
...
...
@@ -161,12 +161,12 @@ class FastTreeObs(ObservationBuilder):
def
_explore
(
self
,
handle
,
new_position
,
new_direction
,
depth
=
0
):
has_opp_agent
=
0
has_same_agent
=
0
has_
switch
=
0
has_
target
=
0
visited
=
[]
# stop exploring (max_depth reached)
if
depth
>=
self
.
max_depth
:
return
has_opp_agent
,
has_same_agent
,
has_
switch
,
visited
return
has_opp_agent
,
has_same_agent
,
has_
target
,
visited
# max_explore_steps = 100 -> just to ensure that the exploration ends
cnt
=
0
...
...
@@ -179,7 +179,7 @@ class FastTreeObs(ObservationBuilder):
if
self
.
env
.
agents
[
opp_a
].
direction
!=
new_direction
:
# opp agent found -> stop exploring. This would be a strong signal.
has_opp_agent
=
1
return
has_opp_agent
,
has_same_agent
,
has_
switch
,
visited
return
has_opp_agent
,
has_same_agent
,
has_
target
,
visited
else
:
# same agent found
# the agent can follow the agent, because this agent is still moving ahead and there shouldn't
...
...
@@ -199,7 +199,10 @@ class FastTreeObs(ObservationBuilder):
if
agents_near_to_switch
:
# The exploration was walking on a path where the agent can not decide
# Best option would be MOVE_FORWARD -> Skip exploring - just walking
return
has_opp_agent
,
has_same_agent
,
has_switch
,
visited
return
has_opp_agent
,
has_same_agent
,
has_target
,
visited
if
self
.
env
.
agents
[
handle
].
target
==
new_position
:
has_target
=
1
possible_transitions
=
self
.
env
.
rail
.
get_transitions
(
*
new_position
,
new_direction
)
if
agents_on_switch
:
...
...
@@ -212,20 +215,20 @@ class FastTreeObs(ObservationBuilder):
# --- OPEN RESEARCH QUESTION ---> is this good or shall we use full detailed information as
# we did in the TreeObservation (FLATLAND) ?
if
possible_transitions
[
dir_loop
]
==
1
:
hoa
,
hsa
,
h
s
,
v
=
self
.
_explore
(
handle
,
hoa
,
hsa
,
h
t
,
v
=
self
.
_explore
(
handle
,
get_new_position
(
new_position
,
dir_loop
),
dir_loop
,
depth
+
1
)
visited
.
append
(
v
)
has_opp_agent
=
max
(
has_opp_agent
,
hoa
)
has_same_agent
=
max
(
has_same_agent
,
hsa
)
has_
switch
=
max
(
has_
switch
,
h
s
)
return
has_opp_agent
,
has_same_agent
,
has_
switch
,
visited
has_
target
=
max
(
has_
target
,
h
t
)
return
has_opp_agent
,
has_same_agent
,
has_
target
,
visited
else
:
new_direction
=
fast_argmax
(
possible_transitions
)
new_position
=
get_new_position
(
new_position
,
new_direction
)
return
has_opp_agent
,
has_same_agent
,
has_
switch
,
visited
return
has_opp_agent
,
has_same_agent
,
has_
target
,
visited
def
get
(
self
,
handle
):
# all values are [0,1]
...
...
@@ -296,13 +299,13 @@ class FastTreeObs(ObservationBuilder):
if
not
(
np
.
math
.
isinf
(
new_cell_dist
)
and
np
.
math
.
isinf
(
current_cell_dist
)):
observation
[
dir_loop
]
=
int
(
new_cell_dist
<
current_cell_dist
)
has_opp_agent
,
has_same_agent
,
has_
switch
,
v
=
self
.
_explore
(
handle
,
new_position
,
branch_direction
)
has_opp_agent
,
has_same_agent
,
has_
target
,
v
=
self
.
_explore
(
handle
,
new_position
,
branch_direction
)
visited
.
append
(
v
)
observation
[
10
+
dir_loop
]
=
int
(
not
np
.
math
.
isinf
(
new_cell_dist
))
observation
[
14
+
dir_loop
]
=
has_opp_agent
observation
[
18
+
dir_loop
]
=
has_same_agent
observation
[
22
+
dir_loop
]
=
has_
switch
observation
[
22
+
dir_loop
]
=
has_
target
agents_on_switch
,
\
agents_near_to_switch
,
\
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment