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
d4a48e1f
Commit
d4a48e1f
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
Updated step function in envs/rail_env.py
parent
9464e58c
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
+6
-5
6 additions, 5 deletions
flatland/envs/rail_env.py
with
6 additions
and
5 deletions
flatland/envs/rail_env.py
+
6
−
5
View file @
d4a48e1f
...
@@ -226,10 +226,11 @@ class RailEnv(Environment):
...
@@ -226,10 +226,11 @@ class RailEnv(Environment):
agent
.
moving
=
False
agent
.
moving
=
False
self
.
rewards_dict
[
iAgent
]
+=
stop_penalty
self
.
rewards_dict
[
iAgent
]
+=
stop_penalty
if
not
agent
.
moving
and
\
if
not
agent
.
moving
and
action
==
RailEnvActions
.
MOVE_FORWARD
:
(
action
==
RailEnvActions
.
MOVE_LEFT
or
# Only allow agent to start moving by pressing forward.
action
==
RailEnvActions
.
MOVE_FORWARD
or
#(action == RailEnvActions.MOVE_LEFT or
action
==
RailEnvActions
.
MOVE_RIGHT
):
# action == RailEnvActions.MOVE_FORWARD or
# action == RailEnvActions.MOVE_RIGHT):
agent
.
moving
=
True
agent
.
moving
=
True
self
.
rewards_dict
[
iAgent
]
+=
start_penalty
self
.
rewards_dict
[
iAgent
]
+=
start_penalty
...
@@ -244,7 +245,7 @@ class RailEnv(Environment):
...
@@ -244,7 +245,7 @@ class RailEnv(Environment):
else
:
else
:
# Logic: if the chosen action is invalid,
# Logic: if the chosen action is invalid,
# and it was LEFT or RIGHT, and the agent was moving, then keep moving FORWARD.
# and it was LEFT or RIGHT, and the agent was moving, then keep moving FORWARD.
if
action
==
RailEnvActions
.
MOVE_LEFT
or
action
==
RailEnvActions
.
MOVE_RIGHT
and
agent
.
moving
:
if
(
action
==
RailEnvActions
.
MOVE_LEFT
or
action
==
RailEnvActions
.
MOVE_RIGHT
)
and
agent
.
moving
:
cell_isFree
,
new_cell_isValid
,
new_direction
,
new_position
,
transition_isValid
=
\
cell_isFree
,
new_cell_isValid
,
new_direction
,
new_position
,
transition_isValid
=
\
self
.
_check_action_on_agent
(
RailEnvActions
.
MOVE_FORWARD
,
agent
)
self
.
_check_action_on_agent
(
RailEnvActions
.
MOVE_FORWARD
,
agent
)
...
...
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