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
dcc279a2
Commit
dcc279a2
authored
May 01, 2019
by
Erik Nygren
Browse files
added TODO: Tree Observation needs to be adjusted to new transition possibilities.
parent
653c291d
Pipeline
#471
failed with stage
in 1 minute and 48 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
examples/training_navigation.py
View file @
dcc279a2
...
@@ -30,13 +30,13 @@ env = RailEnv(width=20,
...
@@ -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),
rail_generator=complex_rail_generator(nr_start_goal=20, min_dist=10, max_dist=99999, seed=0),
number_of_agents=5)
number_of_agents=5)
"""
env = RailEnv(width=20,
env = RailEnv(width=20,
height=20,
height=20,
rail_generator=rail_from_list_of_saved_GridTransitionMap_generator(
rail_generator=rail_from_list_of_saved_GridTransitionMap_generator(
['../env-data/tests/circle.npy']),
['../env-data/tests/circle.npy']),
number_of_agents=1)
number_of_agents=1)
"""
env_renderer
=
RenderTool
(
env
,
gl
=
"QT"
)
env_renderer
=
RenderTool
(
env
,
gl
=
"QT"
)
handle
=
env
.
get_agent_handles
()
handle
=
env
.
get_agent_handles
()
...
@@ -109,7 +109,7 @@ for trials in range(1, n_trials + 1):
...
@@ -109,7 +109,7 @@ for trials in range(1, n_trials + 1):
for
a
in
range
(
env
.
number_of_agents
):
for
a
in
range
(
env
.
number_of_agents
):
if
demo
:
if
demo
:
eps
=
0
eps
=
0
action
=
2
#
agent.act(np.array(obs[a]), eps=eps)
action
=
agent
.
act
(
np
.
array
(
obs
[
a
]),
eps
=
eps
)
action_prob
[
action
]
+=
1
action_prob
[
action
]
+=
1
action_dict
.
update
({
a
:
action
})
action_dict
.
update
({
a
:
action
})
#env.obs_builder.util_print_obs_subtree(tree=obs[a], num_features_per_node=5)
#env.obs_builder.util_print_obs_subtree(tree=obs[a], num_features_per_node=5)
...
...
flatland/core/env_observation_builder.py
View file @
dcc279a2
...
@@ -243,6 +243,7 @@ class TreeObsForRailEnv(ObservationBuilder):
...
@@ -243,6 +243,7 @@ class TreeObsForRailEnv(ObservationBuilder):
# Start from the current orientation, and see which transitions are available;
# Start from the current orientation, and see which transitions are available;
# organize them as [left, forward, right, back], relative to the current orientation
# organize them as [left, forward, right, back], relative to the current orientation
# TODO: Adjust this to the novel movement dynamics --> Only Forward present when one transition is possible.
for
branch_direction
in
[(
orientation
+
4
+
i
)
%
4
for
i
in
range
(
-
1
,
3
)]:
for
branch_direction
in
[(
orientation
+
4
+
i
)
%
4
for
i
in
range
(
-
1
,
3
)]:
if
self
.
env
.
rail
.
get_transition
((
position
[
0
],
position
[
1
],
orientation
),
branch_direction
):
if
self
.
env
.
rail
.
get_transition
((
position
[
0
],
position
[
1
],
orientation
),
branch_direction
):
new_cell
=
self
.
_new_position
(
position
,
branch_direction
)
new_cell
=
self
.
_new_position
(
position
,
branch_direction
)
...
@@ -342,8 +343,8 @@ class TreeObsForRailEnv(ObservationBuilder):
...
@@ -342,8 +343,8 @@ class TreeObsForRailEnv(ObservationBuilder):
elif
num_transitions
==
0
:
elif
num_transitions
==
0
:
# Wrong cell type, but let's cover it and treat it as a dead-end, just in case
# Wrong cell type, but let's cover it and treat it as a dead-end, just in case
#
print("WRONG CELL TYPE detected in tree-search (0 transitions possible) at cell", position[0],
print
(
"WRONG CELL TYPE detected in tree-search (0 transitions possible) at cell"
,
position
[
0
],
#
position[1], direction)
position
[
1
],
direction
)
last_isTerminal
=
True
last_isTerminal
=
True
break
break
...
...
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