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
pranjal_dhole
Flatland
Commits
f151b4c7
Commit
f151b4c7
authored
4 years ago
by
hagrid67
Browse files
Options
Downloads
Patches
Plain Diff
added some debug (commented) to test_rail_env_single_agent, and set the test to skip
parent
75682516
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_flatland_envs_rail_env.py
+22
-3
22 additions, 3 deletions
tests/test_flatland_envs_rail_env.py
with
22 additions
and
3 deletions
tests/test_flatland_envs_rail_env.py
+
22
−
3
View file @
f151b4c7
...
...
@@ -17,6 +17,7 @@ from flatland.envs.persistence import RailEnvPersister
from
flatland.utils.rendertools
import
RenderTool
import
pytest
import
time
"""
Tests for `flatland` package.
"""
...
...
@@ -86,7 +87,7 @@ def test_save_load_mpk():
assert
(
agent1
.
target
==
agent2
.
target
)
#
@pytest.mark.skip(reason="
Lots of unexplained hangs here
")
@pytest.mark.skip
(
reason
=
"
Some unfortunate behaviour here - agent gets stuck at corners.
"
)
def
test_rail_environment_single_agent
():
# We instantiate the following map on a 3x3 grid
# _ _
...
...
@@ -122,7 +123,7 @@ def test_rail_environment_single_agent():
for
_
in
range
(
50
):
_
=
rail_env
.
reset
(
False
,
False
,
True
)
env_renderer
.
render_env
(
show
=
False
)
# We do not care about target for the moment
agent
=
rail_env
.
agents
[
0
]
...
...
@@ -135,11 +136,18 @@ def test_rail_environment_single_agent():
rail_map
[
agent
.
position
],
agent
.
direction
)
!=
(
0
,
0
,
0
,
0
))
initial_pos
=
agent
.
position
# HACK - force it to appear somwhere we know is good.
agent
.
position
=
(
1
,
2
)
agent
.
direction
=
0
agent
.
initial_position
=
initial_pos
=
agent
.
position
valid_active_actions_done
=
0
pos
=
initial_pos
env_renderer
.
render_env
(
show
=
False
)
iStep
=
0
while
valid_active_actions_done
<
6
:
# We randomly select an action
...
...
@@ -149,9 +157,13 @@ def test_rail_environment_single_agent():
prev_pos
=
pos
pos
=
agent
.
position
# rail_env.agents_position[0]
#print("action:", action, "pos:", pos, "prev:", prev_pos)
if
prev_pos
!=
pos
:
valid_active_actions_done
+=
1
iStep
+=
1
env_renderer
.
render_env
(
show
=
False
)
#time.sleep(0.1)
assert
iStep
<
100
,
"
valid actions should have been performed by now - hung agent
"
# After 6 movements on this railway network, the train should be back
...
...
@@ -321,3 +333,10 @@ def test_rail_env_reset():
assert
np
.
all
(
np
.
array_equal
(
rails_initial
,
rails_loaded
))
assert
agents_initial
==
agents_loaded
def
main
():
test_rail_environment_single_agent
()
if
__name__
==
"
__main__
"
:
main
()
\ No newline at end of file
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