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
9db318cf
Commit
9db318cf
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
minor code cleanup
parent
4b45e8e8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
flatland/envs/rail_env.py
+5
-5
5 additions, 5 deletions
flatland/envs/rail_env.py
with
5 additions
and
5 deletions
flatland/envs/rail_env.py
+
5
−
5
View file @
9db318cf
...
...
@@ -353,7 +353,7 @@ class RailEnv(Environment):
# If counter has come to zero --> Agent has malfunction
# set next malfunction time and duration of current malfunction
if
agent
.
malfunction_data
[
'
malfunction_rate
'
]
>
0
>=
agent
.
malfunction_data
[
'
malfunction
'
]
and
\
agent
.
malfunction_data
[
'
next_malfunction
'
]
<=
0
:
agent
.
malfunction_data
[
'
next_malfunction
'
]
<=
0
:
# Increase number of malfunctions
agent
.
malfunction_data
[
'
nr_malfunctions
'
]
+=
1
...
...
@@ -364,7 +364,7 @@ class RailEnv(Environment):
# Duration of current malfunction
num_broken_steps
=
self
.
np_random
.
randint
(
self
.
min_number_of_steps_broken
,
self
.
max_number_of_steps_broken
+
1
)
+
1
self
.
max_number_of_steps_broken
+
1
)
+
1
agent
.
malfunction_data
[
'
malfunction
'
]
=
num_broken_steps
agent
.
malfunction_data
[
'
moving_before_malfunction
'
]
=
agent
.
moving
...
...
@@ -499,7 +499,7 @@ class RailEnv(Environment):
self
.
rewards_dict
[
i_agent
]
+=
self
.
stop_penalty
if
not
agent
.
moving
and
not
(
action
==
RailEnvActions
.
DO_NOTHING
or
action
==
RailEnvActions
.
STOP_MOVING
):
action
==
RailEnvActions
.
DO_NOTHING
or
action
==
RailEnvActions
.
STOP_MOVING
):
# Allow agent to start with any forward or direction action
agent
.
moving
=
True
self
.
rewards_dict
[
i_agent
]
+=
self
.
start_penalty
...
...
@@ -725,7 +725,7 @@ class RailEnv(Environment):
return
msgpack
.
packb
(
msg_data
,
use_bin_type
=
True
)
def
save
(
self
,
filename
,
save_distance_maps
=
False
):
def
save
(
self
,
filename
,
save_distance_maps
=
False
):
if
save_distance_maps
==
True
:
if
self
.
distance_map
.
get
()
is
not
None
:
if
len
(
self
.
distance_map
.
get
())
>
0
:
...
...
@@ -738,7 +738,7 @@ class RailEnv(Environment):
print
(
"
[WARNING] Unable to save the distance map for this environment, as none was found !
"
)
else
:
with
open
(
filename
,
"
wb
"
)
as
file_out
:
with
open
(
filename
,
"
wb
"
)
as
file_out
:
file_out
.
write
(
self
.
get_full_state_msg
())
def
load
(
self
,
filename
):
...
...
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