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
sfwatergit
Flatland
Commits
5d1de868
Commit
5d1de868
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
fixed reward function bug where taking illegal actions at split switch were rewarded!
parent
62dbb589
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
-1
3 additions, 1 deletion
flatland/envs/rail_env.py
with
3 additions
and
1 deletion
flatland/envs/rail_env.py
+
3
−
1
View file @
5d1de868
...
@@ -231,7 +231,7 @@ class RailEnv(Environment):
...
@@ -231,7 +231,7 @@ class RailEnv(Environment):
self
.
rewards_dict
[
iAgent
]
+=
stop_penalty
self
.
rewards_dict
[
iAgent
]
+=
stop_penalty
if
not
agent
.
moving
and
not
(
action
==
RailEnvActions
.
DO_NOTHING
or
action
==
RailEnvActions
.
STOP_MOVING
):
if
not
agent
.
moving
and
not
(
action
==
RailEnvActions
.
DO_NOTHING
or
action
==
RailEnvActions
.
STOP_MOVING
):
#
Only a
llow agent to start
moving by pressing forward.
#
A
llow agent to start
with any forward or direction action
agent
.
moving
=
True
agent
.
moving
=
True
self
.
rewards_dict
[
iAgent
]
+=
start_penalty
self
.
rewards_dict
[
iAgent
]
+=
start_penalty
...
@@ -270,6 +270,7 @@ class RailEnv(Environment):
...
@@ -270,6 +270,7 @@ class RailEnv(Environment):
else
:
else
:
# TODO: an invalid action was chosen after entering the cell. The agent cannot move.
# TODO: an invalid action was chosen after entering the cell. The agent cannot move.
self
.
rewards_dict
[
iAgent
]
+=
invalid_action_penalty
self
.
rewards_dict
[
iAgent
]
+=
invalid_action_penalty
self
.
rewards_dict
[
iAgent
]
+=
step_penalty
*
agent
.
speed_data
[
'
speed
'
]
agent
.
moving
=
False
agent
.
moving
=
False
self
.
rewards_dict
[
iAgent
]
+=
stop_penalty
self
.
rewards_dict
[
iAgent
]
+=
stop_penalty
...
@@ -277,6 +278,7 @@ class RailEnv(Environment):
...
@@ -277,6 +278,7 @@ class RailEnv(Environment):
else
:
else
:
# TODO: an invalid action was chosen after entering the cell. The agent cannot move.
# TODO: an invalid action was chosen after entering the cell. The agent cannot move.
self
.
rewards_dict
[
iAgent
]
+=
invalid_action_penalty
self
.
rewards_dict
[
iAgent
]
+=
invalid_action_penalty
self
.
rewards_dict
[
iAgent
]
+=
step_penalty
*
agent
.
speed_data
[
'
speed
'
]
agent
.
moving
=
False
agent
.
moving
=
False
self
.
rewards_dict
[
iAgent
]
+=
stop_penalty
self
.
rewards_dict
[
iAgent
]
+=
stop_penalty
...
...
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