Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
neurips2020-flatland-baselines
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Flatland
neurips2020-flatland-baselines
Commits
14926487
Commit
14926487
authored
May 02, 2020
by
nilabha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
action mapping
parent
7effaf44
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
envs/flatland/observations/local_conflict_obs.py
envs/flatland/observations/local_conflict_obs.py
+45
-0
No files found.
envs/flatland/observations/local_conflict_obs.py
View file @
14926487
...
...
@@ -449,3 +449,48 @@ def action_required(agent):
agent
.
status
==
RailAgentStatus
.
ACTIVE
and
np
.
isclose
(
agent
.
speed_data
[
'position_fraction'
],
0.0
,
rtol
=
1e-03
)))
def
strategy_action_map
(
action
,
observation_shortest
,
observation_next_shortest
):
"""
convert action space from 0-2 to 0-4
observation_shortest and observation_next_shortest represent a
3-size vector for the actions L,F and R.
If no alternate path exists both of the values would be same
E.g. observation_shortest = [0, 1, 0] refers to Forward (F) shortest path
observation_next_shortest = [0, 0, 1] refers to taking action
Right (R) for an alternate route
"""
if
action
==
2
:
return
4
elif
action
==
0
:
return
np
.
argmax
(
observation_shortest
)
+
1
elif
action
==
1
:
return
np
.
argmax
(
observation_next_shortest
)
+
1
def
action_strategy_map
(
action
,
observation_shortest
,
observation_next_shortest
,
moving
):
"""
convert action space from 0-4 to 0-2 representing shortest path, deviate
and stop
Refer to the strategy_action_map method for observation arguments
"""
if
action
==
np
.
argmax
(
observation_shortest
)
+
1
:
return
0
elif
action
==
np
.
argmax
(
observation_next_shortest
)
+
1
:
return
1
elif
action
==
0
:
if
moving
:
if
np
.
argmax
(
observation_shortest
)
==
1
:
return
0
elif
np
.
argmax
(
observation_shortest
)
==
1
:
return
1
else
:
return
2
elif
action
==
4
:
return
2
else
:
return
0
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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