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
d05a34e6
Commit
d05a34e6
authored
5 years ago
by
Egli Adrian (IT-SCI-API-PFI)
Browse files
Options
Downloads
Patches
Plain Diff
restart agents
parent
96bf75d0
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
flatland/utils/editor.py
+32
-26
32 additions, 26 deletions
flatland/utils/editor.py
notebooks/Editor2.ipynb
+31
-80
31 additions, 80 deletions
notebooks/Editor2.ipynb
with
63 additions
and
106 deletions
flatland/utils/editor.py
+
32
−
26
View file @
d05a34e6
...
@@ -134,19 +134,19 @@ class View(object):
...
@@ -134,19 +134,19 @@ class View(object):
# abbreviated description of buttons and the methods they call
# abbreviated description of buttons and the methods they call
ldButtons
=
[
ldButtons
=
[
dict
(
name
=
"
Refresh
"
,
method
=
self
.
controller
.
refresh
,
tip
=
"
Redraw only
"
),
dict
(
name
=
"
Refresh
"
,
method
=
self
.
controller
.
refresh
,
tip
=
"
Redraw only
"
),
dict
(
name
=
"
Clear
"
,
method
=
self
.
controller
.
clear
,
tip
=
"
Clear rails and agents
"
),
dict
(
name
=
"
Clear
"
,
method
=
self
.
controller
.
clear
,
tip
=
"
Clear rails and agents
"
),
dict
(
name
=
"
Reset
"
,
method
=
self
.
controller
.
reset
,
dict
(
name
=
"
Reset
"
,
method
=
self
.
controller
.
reset
,
tip
=
"
Standard env reset, including regen rail + agents
"
),
tip
=
"
Standard env reset, including regen rail + agents
"
),
dict
(
name
=
"
Rotate Agent
"
,
method
=
self
.
controller
.
rotate_agent
,
tip
=
"
Rotate selected agent
"
),
dict
(
name
=
"
Rotate Agent
"
,
method
=
self
.
controller
.
rotate_agent
,
tip
=
"
Rotate selected agent
"
),
dict
(
name
=
"
Restart Agents
"
,
method
=
self
.
controller
.
restartAgents
,
dict
(
name
=
"
Restart Agents
"
,
method
=
self
.
controller
.
restartAgents
,
tip
=
"
Move agents back to start positions
"
),
tip
=
"
Move agents back to start positions
"
),
dict
(
name
=
"
Regenerate
"
,
method
=
self
.
controller
.
regenerate
,
dict
(
name
=
"
Regenerate
"
,
method
=
self
.
controller
.
regenerate
,
tip
=
"
Regenerate the rails using the method selected below
"
),
tip
=
"
Regenerate the rails using the method selected below
"
),
dict
(
name
=
"
Load
"
,
method
=
self
.
controller
.
load
),
dict
(
name
=
"
Load
"
,
method
=
self
.
controller
.
load
),
dict
(
name
=
"
Save
"
,
method
=
self
.
controller
.
save
),
dict
(
name
=
"
Save
"
,
method
=
self
.
controller
.
save
),
dict
(
name
=
"
Step
"
,
method
=
self
.
controller
.
step
)
,
dict
(
name
=
"
Step
"
,
method
=
self
.
controller
.
step
)
dict
(
name
=
"
Run Steps
"
,
method
=
self
.
controller
.
start_run
)
]
]
self
.
lwButtons
=
[]
self
.
lwButtons
=
[]
for
dButton
in
ldButtons
:
for
dButton
in
ldButtons
:
...
@@ -361,7 +361,17 @@ class Controller(object):
...
@@ -361,7 +361,17 @@ class Controller(object):
def
restartAgents
(
self
,
event
):
def
restartAgents
(
self
,
event
):
self
.
log
(
"
Restart Agents - nAgents:
"
,
self
.
view
.
wRegenNAgents
.
value
)
self
.
log
(
"
Restart Agents - nAgents:
"
,
self
.
view
.
wRegenNAgents
.
value
)
self
.
model
.
restartAgents
()
if
self
.
model
.
init_agents_static
is
not
None
:
print
(
"
Restart Agents ...................
"
)
print
(
self
.
model
.
env
.
agents_static
)
self
.
model
.
env
.
agents_static
=
[
EnvAgentStatic
(
d
[
0
],
d
[
1
],
d
[
2
])
for
d
in
self
.
model
.
init_agents_static
]
print
(
self
.
model
.
env
.
agents_static
)
self
.
model
.
env
.
agents
=
None
self
.
model
.
init_agents_static
=
None
self
.
player
=
None
self
.
model
.
env
.
restart_agents
()
self
.
model
.
env
.
reset
(
False
,
False
)
self
.
refresh
(
event
)
def
regenerate
(
self
,
event
):
def
regenerate
(
self
,
event
):
method
=
self
.
view
.
wRegenMethod
.
value
method
=
self
.
view
.
wRegenMethod
.
value
...
@@ -383,8 +393,6 @@ class Controller(object):
...
@@ -383,8 +393,6 @@ class Controller(object):
def
step
(
self
,
event
):
def
step
(
self
,
event
):
self
.
model
.
step
()
self
.
model
.
step
()
def
start_run
(
self
,
event
):
self
.
model
.
start_run
()
def
log
(
self
,
*
args
,
**
kwargs
):
def
log
(
self
,
*
args
,
**
kwargs
):
if
self
.
view
is
None
:
if
self
.
view
is
None
:
...
@@ -415,6 +423,7 @@ class EditorModel(object):
...
@@ -415,6 +423,7 @@ class EditorModel(object):
self
.
set_env
(
env
)
self
.
set_env
(
env
)
self
.
iSelectedAgent
=
None
self
.
iSelectedAgent
=
None
self
.
player
=
None
self
.
player
=
None
self
.
init_agents_static
=
None
self
.
thread
=
None
self
.
thread
=
None
def
set_env
(
self
,
env
):
def
set_env
(
self
,
env
):
...
@@ -641,12 +650,12 @@ class EditorModel(object):
...
@@ -641,12 +650,12 @@ class EditorModel(object):
# if replace_agents:
# if replace_agents:
# self.env.agents_handles = range(nAgents)
# self.env.agents_handles = range(nAgents)
self
.
env
.
reset
(
regen_rail
=
True
,
replace_agents
=
replace_agents
)
self
.
env
.
reset
(
regen_rail
=
True
,
replace_agents
=
replace_agents
)
self
.
player
=
Player
(
self
.
env
)
self
.
player
=
None
self
.
redraw
()
self
.
redraw
()
def
restartAgents
(
self
):
def
restartAgents
(
self
):
self
.
env
.
agents
=
EnvAgent
.
list_from_static
(
self
.
env
.
agents_static
)
self
.
env
.
agents
=
EnvAgent
.
list_from_static
(
self
.
env
.
agents_static
)
self
.
player
=
Player
(
self
.
env
)
self
.
player
=
None
self
.
redraw
()
self
.
redraw
()
def
setFilename
(
self
,
filename
):
def
setFilename
(
self
,
filename
):
...
@@ -666,7 +675,7 @@ class EditorModel(object):
...
@@ -666,7 +675,7 @@ class EditorModel(object):
self
.
env
.
restart_agents
()
self
.
env
.
restart_agents
()
self
.
env
.
reset
(
False
,
False
)
self
.
env
.
reset
(
False
,
False
)
self
.
init_agents_static
=
None
self
.
fix_env
()
self
.
fix_env
()
self
.
set_env
(
self
.
env
)
self
.
set_env
(
self
.
env
)
self
.
redraw
()
self
.
redraw
()
...
@@ -707,7 +716,7 @@ class EditorModel(object):
...
@@ -707,7 +716,7 @@ class EditorModel(object):
self
.
env
.
reset
(
regen_rail
=
True
)
self
.
env
.
reset
(
regen_rail
=
True
)
self
.
fix_env
()
self
.
fix_env
()
self
.
set_env
(
self
.
env
)
self
.
set_env
(
self
.
env
)
self
.
player
=
Player
(
self
.
env
)
self
.
player
=
None
self
.
view
.
new_env
()
self
.
view
.
new_env
()
# self.view.init_canvas() # Can't do init_canvas - need to keep the same canvas widget!
# self.view.init_canvas() # Can't do init_canvas - need to keep the same canvas widget!
self
.
redraw
()
self
.
redraw
()
...
@@ -761,21 +770,18 @@ class EditorModel(object):
...
@@ -761,21 +770,18 @@ class EditorModel(object):
def
add_target
(
self
,
rcCell
):
def
add_target
(
self
,
rcCell
):
if
self
.
iSelectedAgent
is
not
None
:
if
self
.
iSelectedAgent
is
not
None
:
self
.
env
.
agents_static
[
self
.
iSelectedAgent
].
target
=
rcCell
self
.
env
.
agents_static
[
self
.
iSelectedAgent
].
target
=
rcCell
self
.
init_agents_static
=
None
self
.
redraw
()
self
.
redraw
()
def
step
(
self
):
def
step
(
self
):
if
self
.
init_agents_static
is
None
:
self
.
init_agents_static
=
[
agent
.
to_list
()
for
agent
in
self
.
env
.
agents_static
]
if
self
.
player
is
None
:
if
self
.
player
is
None
:
self
.
player
=
Player
(
self
.
env
)
self
.
player
=
Player
(
self
.
env
)
self
.
env
.
reset
(
regen_rail
=
False
,
replace_agents
=
False
)
self
.
env
.
reset
(
regen_rail
=
False
,
replace_agents
=
False
)
self
.
player
.
step
()
self
.
player
.
step
()
self
.
redraw
()
self
.
redraw
()
def
start_run
(
self
):
if
self
.
thread
is
None
:
self
.
thread
=
threading
.
Thread
(
target
=
self
.
bg_updater
,
args
=
(
self
.
view
.
wProg_steps
,))
self
.
thread
.
start
()
else
:
self
.
log
(
"
thread already present
"
)
def
bg_updater
(
self
,
wProg_steps
):
def
bg_updater
(
self
,
wProg_steps
):
try
:
try
:
...
...
This diff is collapsed.
Click to expand it.
notebooks/Editor2.ipynb
+
31
−
80
View file @
d05a34e6
...
@@ -9,18 +9,9 @@
...
@@ -9,18 +9,9 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
9
,
"execution_count":
1
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"source": [
"source": [
"%load_ext autoreload\n",
"%load_ext autoreload\n",
"%autoreload 2"
"%autoreload 2"
...
@@ -28,7 +19,7 @@
...
@@ -28,7 +19,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
10
,
"execution_count":
2
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -41,7 +32,7 @@
...
@@ -41,7 +32,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
11
,
"execution_count":
3
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -63,50 +54,32 @@
...
@@ -63,50 +54,32 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
12
,
"execution_count":
4
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cairo installed: OK\n"
]
}
],
"source": [
"source": [
"from flatland.utils.editor import EditorMVC, EditorModel, View, Controller"
"from flatland.utils.editor import EditorMVC, EditorModel, View, Controller"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
13
,
"execution_count":
5
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"<flatland.utils.graphics_pil.PILSVG object at 0x000002
0D4CDD2E10
> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"<flatland.utils.graphics_pil.PILSVG object at 0x000002
1AB01F0198
> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n",
"<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n",
" 0000000000000000 Background_#91D1DD.svg\n",
"WE 0000000000000100 Gleis_Deadend.svg\n",
"WW EE NN SS 1000010000100001 Gleis_Diamond_Crossing.svg\n",
"WW EE 0000010000000001 Gleis_horizontal.svg\n",
"EN SW 0000100000010000 Gleis_Kurve_oben_links.svg\n",
"WN SE 0000000001001000 Gleis_Kurve_oben_rechts.svg\n",
"ES NW 0001001000000000 Gleis_Kurve_unten_links.svg\n",
"NE WS 0100000000000010 Gleis_Kurve_unten_rechts.svg\n",
"NN SS 1000000000100000 Gleis_vertikal.svg\n",
"NN SS EE WW ES NW SE WN 1001011001101001 Weiche_Double_Slip.svg\n",
"EE WW EN SW 0000110000010001 Weiche_horizontal_oben_links.svg\n",
"EE WW SE WN 0000010001001001 Weiche_horizontal_oben_rechts.svg\n",
"EE WW ES NW 0001011000000001 Weiche_horizontal_unten_links.svg\n",
"EE WW NE WS 0100010000000011 Weiche_horizontal_unten_rechts.svg\n",
"NN SS EE WW NW ES 1001011000100001 Weiche_Single_Slip.svg\n",
"NE NW ES WS 0101001000000010 Weiche_Symetrical.svg\n",
"NN SS EN SW 1000100000110000 Weiche_vertikal_oben_links.svg\n",
"NN SS SE WN 1000000001101000 Weiche_vertikal_oben_rechts.svg\n",
"NN SS NW ES 1001001000100000 Weiche_vertikal_unten_links.svg\n",
"NN SS NE WS 1100000000100010 Weiche_vertikal_unten_rechts.svg\n",
"EW 0000000100000000 Bahnhof_#d50000_Deadend_links.svg\n",
"NS 0010000000000000 Bahnhof_#d50000_Deadend_oben.svg\n",
"WE 0000000000000100 Bahnhof_#d50000_Deadend_rechts.svg\n",
"SN 0000000010000000 Bahnhof_#d50000_Deadend_unten.svg\n",
"EE WW 0000010000000001 Bahnhof_#d50000_Gleis_horizontal.svg\n",
"NN SS 1000000000100000 Bahnhof_#d50000_Gleis_vertikal.svg\n",
"Clear rails\n"
"Clear rails\n"
]
]
},
},
...
@@ -142,7 +115,7 @@
...
@@ -142,7 +115,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
14
,
"execution_count":
6
,
"metadata": {
"metadata": {
"scrolled": false
"scrolled": false
},
},
...
@@ -150,7 +123,7 @@
...
@@ -150,7 +123,7 @@
{
{
"data": {
"data": {
"application/vnd.jupyter.widget-view+json": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
4c81e4d508834d7f93d104fd2642bc3
a",
"model_id": "
0f3ff6aff8954f3cb369b80b053f9f1
a",
"version_major": 2,
"version_major": 2,
"version_minor": 0
"version_minor": 0
},
},
...
@@ -162,37 +135,15 @@
...
@@ -162,37 +135,15 @@
"output_type": "display_data"
"output_type": "display_data"
},
},
{
{
"name": "stdout",
"ename": "AttributeError",
"output_type": "stream",
"evalue": "'EditorModel' object has no attribute 'model'",
"text": [
"output_type": "error",
"<flatland.utils.graphics_pil.PILSVG object at 0x0000020D4CF49D30> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"traceback": [
"<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n",
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
" 0000000000000000 Background_#91D1DD.svg\n",
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
"WE 0000000000000100 Gleis_Deadend.svg\n",
"\u001b[1;32mc:\\users\\u216993\\appdata\\local\\programs\\python\\python36\\lib\\site-packages\\flatland_rl-0.1.1-py3.6.egg\\flatland\\utils\\editor.py\u001b[0m in \u001b[0;36mstep\u001b[1;34m(self, event)\u001b[0m\n\u001b[0;32m 386\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 387\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mstep\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mevent\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 388\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmodel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstep\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 389\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 390\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mstart_run\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mevent\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"WW EE NN SS 1000010000100001 Gleis_Diamond_Crossing.svg\n",
"\u001b[1;32mc:\\users\\u216993\\appdata\\local\\programs\\python\\python36\\lib\\site-packages\\flatland_rl-0.1.1-py3.6.egg\\flatland\\utils\\editor.py\u001b[0m in \u001b[0;36mstep\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 771\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mstep\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 772\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mplayer\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 773\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmodel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minit_agents_static\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0menv\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0magents_static\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcopy\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 774\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mplayer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mPlayer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0menv\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 775\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0menv\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreset\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mregen_rail\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mFalse\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mreplace_agents\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mFalse\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"WW EE 0000010000000001 Gleis_horizontal.svg\n",
"\u001b[1;31mAttributeError\u001b[0m: 'EditorModel' object has no attribute 'model'"
"EN SW 0000100000010000 Gleis_Kurve_oben_links.svg\n",
"WN SE 0000000001001000 Gleis_Kurve_oben_rechts.svg\n",
"ES NW 0001001000000000 Gleis_Kurve_unten_links.svg\n",
"NE WS 0100000000000010 Gleis_Kurve_unten_rechts.svg\n",
"NN SS 1000000000100000 Gleis_vertikal.svg\n",
"NN SS EE WW ES NW SE WN 1001011001101001 Weiche_Double_Slip.svg\n",
"EE WW EN SW 0000110000010001 Weiche_horizontal_oben_links.svg\n",
"EE WW SE WN 0000010001001001 Weiche_horizontal_oben_rechts.svg\n",
"EE WW ES NW 0001011000000001 Weiche_horizontal_unten_links.svg\n",
"EE WW NE WS 0100010000000011 Weiche_horizontal_unten_rechts.svg\n",
"NN SS EE WW NW ES 1001011000100001 Weiche_Single_Slip.svg\n",
"NE NW ES WS 0101001000000010 Weiche_Symetrical.svg\n",
"NN SS EN SW 1000100000110000 Weiche_vertikal_oben_links.svg\n",
"NN SS SE WN 1000000001101000 Weiche_vertikal_oben_rechts.svg\n",
"NN SS NW ES 1001001000100000 Weiche_vertikal_unten_links.svg\n",
"NN SS NE WS 1100000000100010 Weiche_vertikal_unten_rechts.svg\n",
"EW 0000000100000000 Bahnhof_#d50000_Deadend_links.svg\n",
"NS 0010000000000000 Bahnhof_#d50000_Deadend_oben.svg\n",
"WE 0000000000000100 Bahnhof_#d50000_Deadend_rechts.svg\n",
"SN 0000000010000000 Bahnhof_#d50000_Deadend_unten.svg\n",
"EE WW 0000010000000001 Bahnhof_#d50000_Gleis_horizontal.svg\n",
"NN SS 1000000000100000 Bahnhof_#d50000_Gleis_vertikal.svg\n"
]
]
}
}
],
],
...
@@ -202,7 +153,7 @@
...
@@ -202,7 +153,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
15
,
"execution_count":
7
,
"metadata": {
"metadata": {
"scrolled": false
"scrolled": false
},
},
...
@@ -210,7 +161,7 @@
...
@@ -210,7 +161,7 @@
{
{
"data": {
"data": {
"application/vnd.jupyter.widget-view+json": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8
3b942888352481995b35116bb2237d9
",
"model_id": "8
df099a612d94e34bc64abd0263ae21f
",
"version_major": 2,
"version_major": 2,
"version_minor": 0
"version_minor": 0
},
},
...
@@ -229,7 +180,7 @@
...
@@ -229,7 +180,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
16
,
"execution_count":
8
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -238,7 +189,7 @@
...
@@ -238,7 +189,7 @@
"(0, 0)"
"(0, 0)"
]
]
},
},
"execution_count":
16
,
"execution_count":
8
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
...
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
# Rail Editor v0.2
# Rail Editor v0.2
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
%
load_ext
autoreload
%
load_ext
autoreload
%
autoreload
2
%
autoreload
2
```
```
%% Output
The autoreload extension is already loaded. To reload it, use:
%reload_ext autoreload
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
import
numpy
as
np
import
numpy
as
np
from
numpy
import
array
from
numpy
import
array
import
ipywidgets
import
ipywidgets
import
IPython
import
IPython
from
IPython.core.display
import
display
,
HTML
from
IPython.core.display
import
display
,
HTML
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
display
(
HTML
(
"
<style>.container { width:95% !important; }</style>
"
))
display
(
HTML
(
"
<style>.container { width:95% !important; }</style>
"
))
```
```
%% Output
%% Output
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
from
flatland.utils.editor
import
EditorMVC
,
EditorModel
,
View
,
Controller
from
flatland.utils.editor
import
EditorMVC
,
EditorModel
,
View
,
Controller
```
```
%% Output
cairo installed: OK
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
mvc
=
EditorMVC
(
sGL
=
"
PILSVG
"
)
# sGL="PIL")
mvc
=
EditorMVC
(
sGL
=
"
PILSVG
"
)
# sGL="PIL")
```
```
%% Output
%% Output
<flatland.utils.graphics_pil.PILSVG object at 0x000002
0D4CDD2E10
> <class 'flatland.utils.graphics_pil.PILSVG'>
<flatland.utils.graphics_pil.PILSVG object at 0x000002
1AB01F0198
> <class 'flatland.utils.graphics_pil.PILSVG'>
<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>
<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>
0000000000000000 Background_#91D1DD.svg
WE 0000000000000100 Gleis_Deadend.svg
WW EE NN SS 1000010000100001 Gleis_Diamond_Crossing.svg
WW EE 0000010000000001 Gleis_horizontal.svg
EN SW 0000100000010000 Gleis_Kurve_oben_links.svg
WN SE 0000000001001000 Gleis_Kurve_oben_rechts.svg
ES NW 0001001000000000 Gleis_Kurve_unten_links.svg
NE WS 0100000000000010 Gleis_Kurve_unten_rechts.svg
NN SS 1000000000100000 Gleis_vertikal.svg
NN SS EE WW ES NW SE WN 1001011001101001 Weiche_Double_Slip.svg
EE WW EN SW 0000110000010001 Weiche_horizontal_oben_links.svg
EE WW SE WN 0000010001001001 Weiche_horizontal_oben_rechts.svg
EE WW ES NW 0001011000000001 Weiche_horizontal_unten_links.svg
EE WW NE WS 0100010000000011 Weiche_horizontal_unten_rechts.svg
NN SS EE WW NW ES 1001011000100001 Weiche_Single_Slip.svg
NE NW ES WS 0101001000000010 Weiche_Symetrical.svg
NN SS EN SW 1000100000110000 Weiche_vertikal_oben_links.svg
NN SS SE WN 1000000001101000 Weiche_vertikal_oben_rechts.svg
NN SS NW ES 1001001000100000 Weiche_vertikal_unten_links.svg
NN SS NE WS 1100000000100010 Weiche_vertikal_unten_rechts.svg
EW 0000000100000000 Bahnhof_#d50000_Deadend_links.svg
NS 0010000000000000 Bahnhof_#d50000_Deadend_oben.svg
WE 0000000000000100 Bahnhof_#d50000_Deadend_rechts.svg
SN 0000000010000000 Bahnhof_#d50000_Deadend_unten.svg
EE WW 0000010000000001 Bahnhof_#d50000_Gleis_horizontal.svg
NN SS 1000000000100000 Bahnhof_#d50000_Gleis_vertikal.svg
Clear rails
Clear rails
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
## Instructions
## Instructions
-
Drag to draw (improved dead-ends)
-
Drag to draw (improved dead-ends)
-
Shift-Drag to erase rails (erasing dead ends not yet automated - drag right across them)
-
Shift-Drag to erase rails (erasing dead ends not yet automated - drag right across them)
-
ctrl-click to add agent
-
ctrl-click to add agent
-
direction chosen randomly to fit rail
-
direction chosen randomly to fit rail
-
ctrl-shift-click to add target for last agent
-
ctrl-shift-click to add target for last agent
-
target can be moved by repeating
-
target can be moved by repeating
-
to Resize the env (cannot preserve work):
-
to Resize the env (cannot preserve work):
-
select "Regen" tab, set regen size slider, click regenerate.
-
select "Regen" tab, set regen size slider, click regenerate.
-
alt-click remove all rails from cell
-
alt-click remove all rails from cell
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
mvc
.
view
.
display
()
mvc
.
view
.
display
()
```
```
%% Output
%% Output
<flatland.utils.graphics_pil.PILSVG object at 0x0000020D4CF49D30> <class 'flatland.utils.graphics_pil.PILSVG'>
---------------------------------------------------------------------------
<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>
AttributeError Traceback (most recent call last)
0000000000000000 Background_#91D1DD.svg
c:\users\u216993\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.1.1-py3.6.egg\flatland\utils\editor.py in step(self, event)
WE 0000000000000100 Gleis_Deadend.svg
386
WW EE NN SS 1000010000100001 Gleis_Diamond_Crossing.svg
387 def step(self, event):
WW EE 0000010000000001 Gleis_horizontal.svg
--> 388 self.model.step()
EN SW 0000100000010000 Gleis_Kurve_oben_links.svg
389
WN SE 0000000001001000 Gleis_Kurve_oben_rechts.svg
390 def start_run(self, event):
ES NW 0001001000000000 Gleis_Kurve_unten_links.svg
c:\users\u216993\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.1.1-py3.6.egg\flatland\utils\editor.py in step(self)
NE WS 0100000000000010 Gleis_Kurve_unten_rechts.svg
771 def step(self):
NN SS 1000000000100000 Gleis_vertikal.svg
772 if self.player is None:
NN SS EE WW ES NW SE WN 1001011001101001 Weiche_Double_Slip.svg
--> 773 self.model.init_agents_static = self.env.agents_static.copy()
EE WW EN SW 0000110000010001 Weiche_horizontal_oben_links.svg
774 self.player = Player(self.env)
EE WW SE WN 0000010001001001 Weiche_horizontal_oben_rechts.svg
775 self.env.reset(regen_rail=False, replace_agents=False)
EE WW ES NW 0001011000000001 Weiche_horizontal_unten_links.svg
AttributeError: 'EditorModel' object has no attribute 'model'
EE WW NE WS 0100010000000011 Weiche_horizontal_unten_rechts.svg
NN SS EE WW NW ES 1001011000100001 Weiche_Single_Slip.svg
NE NW ES WS 0101001000000010 Weiche_Symetrical.svg
NN SS EN SW 1000100000110000 Weiche_vertikal_oben_links.svg
NN SS SE WN 1000000001101000 Weiche_vertikal_oben_rechts.svg
NN SS NW ES 1001001000100000 Weiche_vertikal_unten_links.svg
NN SS NE WS 1100000000100010 Weiche_vertikal_unten_rechts.svg
EW 0000000100000000 Bahnhof_#d50000_Deadend_links.svg
NS 0010000000000000 Bahnhof_#d50000_Deadend_oben.svg
WE 0000000000000100 Bahnhof_#d50000_Deadend_rechts.svg
SN 0000000010000000 Bahnhof_#d50000_Deadend_unten.svg
EE WW 0000010000000001 Bahnhof_#d50000_Gleis_horizontal.svg
NN SS 1000000000100000 Bahnhof_#d50000_Gleis_vertikal.svg
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
mvc
.
view
.
wOutput
.
clear_output
()
mvc
.
view
.
wOutput
.
clear_output
()
mvc
.
view
.
wOutput
mvc
.
view
.
wOutput
```
```
%% Output
%% Output
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
len
(
mvc
.
editor
.
env
.
agents
),
len
(
mvc
.
editor
.
env
.
agents_static
)
len
(
mvc
.
editor
.
env
.
agents
),
len
(
mvc
.
editor
.
env
.
agents_static
)
```
```
%% Output
%% Output
(0, 0)
(0, 0)
...
...
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