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
dceceb86
Commit
dceceb86
authored
Apr 29, 2019
by
Erik Nygren
Browse files
added curves to rail_env.py step function
parent
0ad69215
Changes
2
Hide whitespace changes
Inline
Side-by-side
examples/training_navigation.py
View file @
dceceb86
...
...
@@ -30,13 +30,13 @@ env = RailEnv(width=20,
rail_generator
=
complex_rail_generator
(
nr_start_goal
=
20
,
min_dist
=
10
,
max_dist
=
99999
,
seed
=
0
),
number_of_agents
=
5
)
"""
env
=
RailEnv
(
width
=
20
,
height
=
20
,
rail_generator
=
rail_from_list_of_saved_GridTransitionMap_generator
(
['../env-data/tests/t
est_rail
.npy']),
[
'../env-data/tests/t
rain_simple
.npy'
]),
number_of_agents
=
1
)
"""
env_renderer
=
RenderTool
(
env
,
gl
=
"QT"
)
handle
=
env
.
get_agent_handles
()
...
...
flatland/envs/rail_env.py
View file @
dceceb86
...
...
@@ -1053,6 +1053,21 @@ class RailEnv(Environment):
direction
=
reverse_direction
movement
=
reverse_direction
is_deadend
=
True
if
nbits
==
2
:
# straigt or curve
valid_transition
=
self
.
rail
.
get_transition
(
(
pos
[
0
],
pos
[
1
],
direction
),
movement
)
reverse_direction
=
(
direction
+
2
)
%
4
curv_dir
=
(
movement
+
1
)
%
4
while
not
valid_transition
:
if
curv_dir
!=
reverse_direction
:
valid_transition
=
self
.
rail
.
get_transition
(
(
pos
[
0
],
pos
[
1
],
direction
),
curv_dir
)
curv_dir
=
(
curv_dir
+
1
)
%
4
if
valid_transition
:
movement
=
curv_dir
new_position
=
self
.
_new_position
(
pos
,
movement
)
# Is it a legal move? 1) transition allows the movement in the
# cell, 2) the new cell is not empty (case 0), 3) the cell is
...
...
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