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
576715cb
Commit
576715cb
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
updated rendering method for debugging
parent
c528e652
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/training_navigation.py
+3
-12
3 additions, 12 deletions
examples/training_navigation.py
flatland/utils/rendertools.py
+6
-3
6 additions, 3 deletions
flatland/utils/rendertools.py
with
9 additions
and
15 deletions
examples/training_navigation.py
+
3
−
12
View file @
576715cb
...
...
@@ -8,16 +8,7 @@ import torch,random
random
.
seed
(
1
)
np
.
random
.
seed
(
1
)
"""
transition_probability = [1.0, # empty cell - Case 0
3.0, # Case 1 - straight
1.0, # Case 2 - simple switch
3.0, # Case 3 - diamond drossing
2.0, # Case 4 - single slip
1.0, # Case 5 - double slip
1.0, # Case 6 - symmetrical
1.0] # Case 7 - dead end
"""
# Example generate a rail given a manual specification,
# a map of tuples (cell_type, rotation)
transition_probability
=
[
1.0
,
# empty cell - Case 0
...
...
@@ -63,6 +54,7 @@ for trials in range(1, n_trials + 1):
# Run episode
for
step
in
range
(
100
):
#env_renderer.renderEnv(show=True)
# Action
for
a
in
range
(
env
.
number_of_agents
):
...
...
@@ -73,7 +65,6 @@ for trials in range(1, n_trials + 1):
next_obs
,
all_rewards
,
done
,
_
=
env
.
step
(
action_dict
)
# Update replay buffer and train agent
for
a
in
range
(
env
.
number_of_agents
):
agent
.
step
(
obs
[
a
],
action_dict
[
a
],
all_rewards
[
a
],
next_obs
[
a
],
done
[
a
])
...
...
@@ -81,7 +72,7 @@ for trials in range(1, n_trials + 1):
obs
=
next_obs
.
copy
()
if
all
(
done
)
:
if
done
[
'
__all__
'
]
:
env_done
=
1
break
# Epsioln decay
...
...
This diff is collapsed.
Click to expand it.
flatland/utils/rendertools.py
+
6
−
3
View file @
576715cb
...
...
@@ -403,10 +403,9 @@ class RenderTool(object):
# cell_size is a bit pointless with matplotlib - it does not relate to pixels,
# so for now I've changed it to 1 (from 10)
cell_size
=
1
plt
.
clf
()
# if oFigure is None:
# oFigure = plt.figure()
def
drawTrans
(
oFrom
,
oTo
,
sColor
=
"
gray
"
):
plt
.
plot
(
[
oFrom
[
0
],
oTo
[
0
]],
# x
...
...
@@ -551,7 +550,11 @@ class RenderTool(object):
plt
.
xlim
([
0
,
env
.
width
*
cell_size
])
plt
.
ylim
([
-
env
.
height
*
cell_size
,
0
])
if
show
:
plt
.
show
()
plt
.
show
(
block
=
False
)
plt
.
pause
(
0.00001
)
return
def
_draw_square
(
self
,
center
,
size
,
color
):
x0
=
center
[
0
]
-
size
/
2
...
...
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