Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flatland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
yoogottamk
Flatland
Commits
71864675
Commit
71864675
authored
5 years ago
by
u214892
Browse files
Options
Downloads
Patches
Plain Diff
#178 pass action instead of action_dict to step_agent
parent
49bd8ff6
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
flatland/envs/rail_env.py
+3
-5
3 additions, 5 deletions
flatland/envs/rail_env.py
with
3 additions
and
5 deletions
flatland/envs/rail_env.py
+
3
−
5
View file @
71864675
...
...
@@ -356,7 +356,7 @@ class RailEnv(Environment):
# Perform step on all agents
for
i_agent
in
range
(
self
.
get_num_agents
()):
self
.
_step_agent
(
i_agent
,
action_dict_
)
self
.
_step_agent
(
i_agent
,
action_dict_
.
get
(
i_agent
)
)
# Check for end of episode + set global reward to all rewards!
if
np
.
all
([
np
.
array_equal
(
agent
.
position
,
agent
.
target
)
for
agent
in
self
.
agents
]):
...
...
@@ -384,7 +384,7 @@ class RailEnv(Environment):
return
self
.
_get_observations
(),
self
.
rewards_dict
,
self
.
dones
,
info_dict
def
_step_agent
(
self
,
i_agent
,
action
_dict_
:
Dict
[
int
,
RailEnvActions
]):
def
_step_agent
(
self
,
i_agent
,
action
:
Optional
[
RailEnvActions
]
=
None
):
"""
Performs a step and step, start and stop penalty on a single agent in the following sub steps:
- malfunction
...
...
@@ -416,10 +416,8 @@ class RailEnv(Environment):
# Is the agent at the beginning of the cell? Then, it can take an action.
if
agent
.
speed_data
[
'
position_fraction
'
]
==
0.0
:
# No action has been supplied for this agent -> set DO_NOTHING as default
if
i_agent
not
in
action_dict_
:
if
action
is
None
:
action
=
RailEnvActions
.
DO_NOTHING
else
:
action
=
action_dict_
[
i_agent
]
if
action
<
0
or
action
>
len
(
RailEnvActions
):
print
(
'
ERROR: illegal action=
'
,
action
,
...
...
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