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
yoogottamk
Flatland
Commits
b604cad1
Commit
b604cad1
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
code cleanup in step function
parent
404d650a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/training_navigation.py
+4
-4
4 additions, 4 deletions
examples/training_navigation.py
flatland/envs/rail_env.py
+2
-6
2 additions, 6 deletions
flatland/envs/rail_env.py
flatland/utils/rendertools.py
+1
-1
1 addition, 1 deletion
flatland/utils/rendertools.py
with
7 additions
and
11 deletions
examples/training_navigation.py
+
4
−
4
View file @
b604cad1
...
@@ -35,13 +35,13 @@ env = RailEnv(width=20,
...
@@ -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),
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
'
]),
[
'
../
notebooks/testing_11
.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
()
...
@@ -61,7 +61,7 @@ action_prob = [0] * 4
...
@@ -61,7 +61,7 @@ action_prob = [0] * 4
agent
=
Agent
(
state_size
,
action_size
,
"
FC
"
,
0
)
agent
=
Agent
(
state_size
,
action_size
,
"
FC
"
,
0
)
agent
.
qnetwork_local
.
load_state_dict
(
torch
.
load
(
'
../flatland/baselines/Nets/avoid_checkpoint14900.pth
'
))
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
):
def
max_lt
(
seq
,
val
):
...
...
This diff is collapsed.
Click to expand it.
flatland/envs/rail_env.py
+
2
−
6
View file @
b604cad1
...
@@ -366,13 +366,9 @@ class RailEnv(Environment):
...
@@ -366,13 +366,9 @@ class RailEnv(Environment):
is_deadend
=
True
is_deadend
=
True
if
np
.
sum
(
possible_transitions
)
==
1
:
if
np
.
sum
(
possible_transitions
)
==
1
:
# Checking for curves
# Take only available transition
curv_dir
=
np
.
argmax
(
possible_transitions
)
movement
=
np
.
argmax
(
possible_transitions
)
# valid_transition = self.rail.get_transition(
# (pos[0], pos[1], direction),
# movement)
movement
=
curv_dir
new_position
=
self
.
_new_position
(
pos
,
movement
)
new_position
=
self
.
_new_position
(
pos
,
movement
)
# Is it a legal move? 1) transition allows the movement in the
# 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
# cell, 2) the new cell is not empty (case 0), 3) the cell is
...
...
This diff is collapsed.
Click to expand it.
flatland/utils/rendertools.py
+
1
−
1
View file @
b604cad1
...
@@ -208,7 +208,7 @@ class RenderTool(object):
...
@@ -208,7 +208,7 @@ class RenderTool(object):
xyDir
=
np
.
matmul
(
rcDir
,
rt
.
grc2xy
)
# agent direction in xy
xyDir
=
np
.
matmul
(
rcDir
,
rt
.
grc2xy
)
# agent direction in xy
xyPos
=
np
.
matmul
(
rcPos
-
rcDir
/
2
,
rt
.
grc2xy
)
+
rt
.
xyHalf
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
self
.
gl
.
scatter
(
*
xyPos
,
color
=
color
,
marker
=
"
o
"
,
s
=
100
)
# agent location
xyDirLine
=
array
([
xyPos
,
xyPos
+
xyDir
/
2
]).
T
# line for agent orient.
xyDirLine
=
array
([
xyPos
,
xyPos
+
xyDir
/
2
]).
T
# line for agent orient.
...
...
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