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
b604cad1
Commit
b604cad1
authored
May 06, 2019
by
Erik Nygren
Browse files
code cleanup in step function
parent
404d650a
Pipeline
#486
failed with stage
in 1 minute and 54 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
examples/training_navigation.py
View file @
b604cad1
...
...
@@ -35,13 +35,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/circle
.npy']),
[
'../
notebooks/testing_11
.npy'
]),
number_of_agents
=
1
)
"""
env_renderer
=
RenderTool
(
env
,
gl
=
"QT"
)
handle
=
env
.
get_agent_handles
()
...
...
@@ -61,7 +61,7 @@ action_prob = [0] * 4
agent
=
Agent
(
state_size
,
action_size
,
"FC"
,
0
)
agent
.
qnetwork_local
.
load_state_dict
(
torch
.
load
(
'../flatland/baselines/Nets/avoid_checkpoint14900.pth'
))
demo
=
Fals
e
demo
=
Tru
e
def
max_lt
(
seq
,
val
):
...
...
flatland/envs/rail_env.py
View file @
b604cad1
...
...
@@ -366,13 +366,9 @@ class RailEnv(Environment):
is_deadend
=
True
if
np
.
sum
(
possible_transitions
)
==
1
:
# Checking for curves
curv_dir
=
np
.
argmax
(
possible_transitions
)
# valid_transition = self.rail.get_transition(
# (pos[0], pos[1], direction),
# movement)
# Take only available transition
movement
=
np
.
argmax
(
possible_transitions
)
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
...
...
flatland/utils/rendertools.py
View file @
b604cad1
...
...
@@ -208,7 +208,7 @@ class RenderTool(object):
xyDir
=
np
.
matmul
(
rcDir
,
rt
.
grc2xy
)
# agent direction in xy
xyPos
=
np
.
matmul
(
rcPos
-
rcDir
/
2
,
rt
.
grc2xy
)
+
rt
.
xyHalf
print
(
"Agent:"
,
rcPos
,
iDir
,
rcDir
,
xyDir
,
xyPos
)
#
print("Agent:", rcPos, iDir, rcDir, xyDir, xyPos)
self
.
gl
.
scatter
(
*
xyPos
,
color
=
color
,
marker
=
"o"
,
s
=
100
)
# agent location
xyDirLine
=
array
([
xyPos
,
xyPos
+
xyDir
/
2
]).
T
# line for agent orient.
...
...
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