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
808887c9
Commit
808887c9
authored
Aug 29, 2019
by
u214892
Browse files
bugfix #141: check_path_exists and tests
parent
6e367dd6
Pipeline
#1847
failed with stages
in 5 minutes and 15 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
flatland/core/transition_map.py
View file @
808887c9
...
...
@@ -312,7 +312,7 @@ class GridTransitionMap(TransitionMap):
tmp
=
tmp
>>
1
return
nbits
==
1
def
_path_exists
(
self
,
start
,
direction
,
end
):
def
check
_path_exists
(
self
,
start
,
direction
,
end
):
# print("_path_exists({},{},{}".format(start, direction, end))
# BFS - Check if a path exists between the 2 nodes
...
...
flatland/envs/schedule_generators.py
View file @
808887c9
...
...
@@ -183,8 +183,8 @@ def random_schedule_generator(speed_ratio_map: Mapping[float, float] = None) ->
valid_starting_directions
=
[]
for
m
in
valid_movements
:
new_position
=
get_new_position
(
agents_position
[
i
],
m
[
1
])
if
m
[
0
]
not
in
valid_starting_directions
and
rail
.
_path_exists
(
new_position
,
m
[
0
],
agents_target
[
i
]):
if
m
[
0
]
not
in
valid_starting_directions
and
rail
.
check
_path_exists
(
new_position
,
m
[
0
],
agents_target
[
i
]):
valid_starting_directions
.
append
(
m
[
0
])
if
len
(
valid_starting_directions
)
==
0
:
...
...
tests/test_flatland_core_transition_map.py
View file @
808887c9
...
...
@@ -63,7 +63,7 @@ def check_path(env, rail, position, direction, target, expected, rendering=False
renderer
=
RenderTool
(
env
,
gl
=
"PILSVG"
)
renderer
.
render_env
(
show
=
True
,
show_observations
=
False
)
input
(
"Continue?"
)
assert
rail
.
_path_exists
(
agent
.
position
,
agent
.
direction
,
agent
.
target
)
==
expected
assert
rail
.
check
_path_exists
(
agent
.
position
,
agent
.
direction
,
agent
.
target
)
==
expected
def
test_path_exists
(
rendering
=
False
):
...
...
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