Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Flatland
Flatland
Commits
1f6b1505
Commit
1f6b1505
authored
Aug 14, 2021
by
Dipam Chakraborty
Browse files
fix distance map tests
parent
58b08468
Changes
4
Hide whitespace changes
Inline
Side-by-side
flatland/envs/rail_env.py
View file @
1f6b1505
...
...
@@ -562,7 +562,7 @@ class RailEnv(Environment):
for
i_agent
,
agent
in
enumerate
(
self
.
agents
):
# agent done? (arrival_time is not None)
if
(
self
.
dones
[
i_agent
])
:
if
agent
.
status
==
RailAgentStatus
.
DONE
or
agent
.
status
==
RailAgentStatus
.
DONE_REMOVED
:
# if agent arrived earlier or on time = 0
# if agent arrived later = -ve reward based on how late
...
...
tests/test_distance_map.py
View file @
1f6b1505
...
...
@@ -53,9 +53,9 @@ def test_walker():
env
.
agents
[
0
].
position
=
(
0
,
1
)
env
.
agents
[
0
].
direction
=
1
env
.
agents
[
0
].
target
=
(
0
,
0
)
# reset to set agents from agents_static
env
.
reset
(
False
,
False
)
# env.reset(False, False)
env
.
distance_map
.
_compute
(
env
.
agents
,
env
.
rail
)
print
(
env
.
distance_map
.
get
()[(
0
,
*
[
0
,
1
],
1
)])
assert
env
.
distance_map
.
get
()[(
0
,
*
[
0
,
1
],
1
)]
==
3
...
...
tests/test_flatland_envs_predictions.py
View file @
1f6b1505
...
...
@@ -133,6 +133,11 @@ def test_shortest_path_predictor(rendering=False):
agent
.
status
=
RailAgentStatus
.
ACTIVE
env
.
reset
(
False
,
False
)
env
.
distance_map
.
_compute
(
env
.
agents
,
env
.
rail
)
# Perform DO_NOTHING actions until all trains get to READY_TO_DEPART
for
_
in
range
(
max
([
agent
.
earliest_departure
for
agent
in
env
.
agents
])):
env
.
step
({})
# DO_NOTHING for all agents
if
rendering
:
renderer
=
RenderTool
(
env
,
gl
=
"PILSVG"
)
...
...
tests/test_flatland_malfunction.py
View file @
1f6b1505
...
...
@@ -90,6 +90,9 @@ def test_malfunction_process():
# Move target to unreachable position in order to not interfere with test
env
.
agents
[
0
].
target
=
(
0
,
0
)
# Add in max episode steps because scheudule generator sets it to 0 for dummy data
env
.
_max_episode_steps
=
200
for
step
in
range
(
100
):
actions
=
{}
...
...
@@ -111,9 +114,9 @@ def test_malfunction_process():
agent_old_position
=
env
.
agents
[
0
].
position
total_down_time
+=
env
.
agents
[
0
].
malfunction_data
[
'malfunction'
]
# Check that the appropriate number of malfunctions is achieved
assert
env
.
agents
[
0
].
malfunction_data
[
'nr_malfunctions'
]
==
23
,
"Actual {}"
.
format
(
# Dipam: The number of malfunctions varies by seed
assert
env
.
agents
[
0
].
malfunction_data
[
'nr_malfunctions'
]
==
21
,
"Actual {}"
.
format
(
env
.
agents
[
0
].
malfunction_data
[
'nr_malfunctions'
])
# Check that malfunctioning data was standing around
...
...
@@ -176,7 +179,7 @@ def test_malfunction_before_entry():
)
rail
,
rail_map
,
optionals
=
make_simple_rail2
()
env
=
RailEnv
(
width
=
25
,
height
=
30
,
rail_generator
=
rail_from_grid_transition_map
(
rail
,
optionals
),
...
...
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