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
pranjal_dhole
Flatland
Commits
229ddb8c
Commit
229ddb8c
authored
5 years ago
by
Egli Adrian (IT-SCI-API-PFI)
Browse files
Options
Downloads
Patches
Plain Diff
Bugfix: code cleanup
parent
c1b96225
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
flatland/envs/rail_env.py
+1
-3
1 addition, 3 deletions
flatland/envs/rail_env.py
notebooks/Editor2.ipynb
+28
-23
28 additions, 23 deletions
notebooks/Editor2.ipynb
svg/Selected_Agent.svg
+93
-78
93 additions, 78 deletions
svg/Selected_Agent.svg
svg/Selected_Target.svg
+65
-62
65 additions, 62 deletions
svg/Selected_Target.svg
with
187 additions
and
166 deletions
flatland/envs/rail_env.py
+
1
−
3
View file @
229ddb8c
...
...
@@ -220,9 +220,7 @@ class RailEnv(Environment):
if
action
>
0
:
cell_isFree
,
new_cell_isValid
,
new_direction
,
new_position
,
transition_isValid
=
self
.
_check_action_on_agent
(
action
,
agent
,
transition_isValid
)
agent
)
if
all
([
new_cell_isValid
,
transition_isValid
,
cell_isFree
]):
# move and change direction to face the new_direction that was
# performed
...
...
This diff is collapsed.
Click to expand it.
notebooks/Editor2.ipynb
+
28
−
23
View file @
229ddb8c
...
...
@@ -9,9 +9,18 @@
},
{
"cell_type": "code",
"execution_count":
1
,
"execution_count":
9
,
"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": [
"%load_ext autoreload\n",
"%autoreload 2"
...
...
@@ -19,7 +28,7 @@
},
{
"cell_type": "code",
"execution_count":
2
,
"execution_count":
10
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -32,7 +41,7 @@
},
{
"cell_type": "code",
"execution_count":
3
,
"execution_count":
11
,
"metadata": {},
"outputs": [
{
...
...
@@ -54,31 +63,23 @@
},
{
"cell_type": "code",
"execution_count":
4
,
"execution_count":
12
,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cairo installed: OK\n"
]
}
],
"outputs": [],
"source": [
"from flatland.utils.editor import EditorMVC, EditorModel, View, Controller"
]
},
{
"cell_type": "code",
"execution_count":
5
,
"execution_count":
13
,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<flatland.utils.graphics_pil.PILSVG object at 0x00000
22C5FB44
198> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"<flatland.utils.graphics_pil.PILSVG object at 0x00000
1FC6FB9E
198> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n",
"Clear rails\n"
]
...
...
@@ -115,7 +116,7 @@
},
{
"cell_type": "code",
"execution_count":
6
,
"execution_count":
14
,
"metadata": {
"scrolled": false
},
...
...
@@ -123,7 +124,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
094a0a3e4351403d8d119b0696abaee4
",
"model_id": "
df04f776b29f456eabb20b9587ea1f16
",
"version_major": 2,
"version_minor": 0
},
...
...
@@ -138,7 +139,11 @@
"name": "stdout",
"output_type": "stream",
"text": [
"<flatland.utils.graphics_pil.PILSVG object at 0x0000022C6066EC50> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"<flatland.utils.graphics_pil.PILSVG object at 0x000001FC6FBB7FD0> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n",
"<flatland.utils.graphics_pil.PILSVG object at 0x000001FC6FA8C5C0> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n",
"<flatland.utils.graphics_pil.PILSVG object at 0x000001FC73AF2908> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n"
]
}
...
...
@@ -149,7 +154,7 @@
},
{
"cell_type": "code",
"execution_count":
7
,
"execution_count":
15
,
"metadata": {
"scrolled": false
},
...
...
@@ -157,7 +162,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
98b1504729884d8a9362dbf246d81f78
",
"model_id": "
6c0846dadce244ed877d53410dcfe0a7
",
"version_major": 2,
"version_minor": 0
},
...
...
@@ -176,7 +181,7 @@
},
{
"cell_type": "code",
"execution_count":
8
,
"execution_count":
16
,
"metadata": {},
"outputs": [
{
...
...
@@ -185,7 +190,7 @@
"(0, 0)"
]
},
"execution_count":
8
,
"execution_count":
16
,
"metadata": {},
"output_type": "execute_result"
}
...
...
%% Cell type:markdown id: tags:
# Rail Editor v0.2
%% Cell type:code id: tags:
```
python
%
load_ext
autoreload
%
autoreload
2
```
%% Output
The autoreload extension is already loaded. To reload it, use:
%reload_ext autoreload
%% Cell type:code id: tags:
```
python
import
numpy
as
np
from
numpy
import
array
import
ipywidgets
import
IPython
from
IPython.core.display
import
display
,
HTML
```
%% Cell type:code id: tags:
```
python
display
(
HTML
(
"
<style>.container { width:95% !important; }</style>
"
))
```
%% Output
%% Cell type:code id: tags:
```
python
from
flatland.utils.editor
import
EditorMVC
,
EditorModel
,
View
,
Controller
```
%% Output
cairo installed: OK
%% Cell type:code id: tags:
```
python
mvc
=
EditorMVC
(
sGL
=
"
PILSVG
"
)
# sGL="PIL")
```
%% Output
<flatland.utils.graphics_pil.PILSVG object at 0x00000
22C5FB44
198> <class 'flatland.utils.graphics_pil.PILSVG'>
<flatland.utils.graphics_pil.PILSVG object at 0x00000
1FC6FB9E
198> <class 'flatland.utils.graphics_pil.PILSVG'>
<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>
Clear rails
%% Cell type:markdown id: tags:
## Instructions
-
Drag to draw (improved dead-ends)
-
Shift-Drag to erase rails (erasing dead ends not yet automated - drag right across them)
-
ctrl-click to add agent
-
direction chosen randomly to fit rail
-
ctrl-shift-click to add target for last agent
-
target can be moved by repeating
-
to Resize the env (cannot preserve work):
-
select "Regen" tab, set regen size slider, click regenerate.
-
alt-click remove all rails from cell
%% Cell type:code id: tags:
```
python
mvc
.
view
.
display
()
```
%% Output
<flatland.utils.graphics_pil.PILSVG object at 0x0000022C6066EC50> <class 'flatland.utils.graphics_pil.PILSVG'>
<flatland.utils.graphics_pil.PILSVG object at 0x000001FC6FBB7FD0> <class 'flatland.utils.graphics_pil.PILSVG'>
<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>
<flatland.utils.graphics_pil.PILSVG object at 0x000001FC6FA8C5C0> <class 'flatland.utils.graphics_pil.PILSVG'>
<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>
<flatland.utils.graphics_pil.PILSVG object at 0x000001FC73AF2908> <class 'flatland.utils.graphics_pil.PILSVG'>
<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>
%% Cell type:code id: tags:
```
python
mvc
.
view
.
wOutput
.
clear_output
()
mvc
.
view
.
wOutput
```
%% Output
%% Cell type:code id: tags:
```
python
len
(
mvc
.
editor
.
env
.
agents
),
len
(
mvc
.
editor
.
env
.
agents_static
)
```
%% Output
(0, 0)
...
...
This diff is collapsed.
Click to expand it.
svg/Selected_Agent.svg
+
93
−
78
View file @
229ddb8c
...
...
@@ -2,45 +2,45 @@
<!-- Generator: Adobe Illustrator 23.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:dc=
"http://purl.org/dc/elements/1.1/"
xmlns:cc=
"http://creativecommons.org/ns#"
xmlns:rdf=
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg=
"http://www.w3.org/2000/svg"
xmlns=
"http://www.w3.org/2000/svg"
xmlns:sodipodi=
"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape=
"http://www.inkscape.org/namespaces/inkscape"
version=
"1.1"
id=
"Ebene_1"
x=
"0px"
y=
"0px"
viewBox=
"0 0 240 240"
style=
"enable-background:new 0 0 240 240;"
xml:space=
"preserve"
sodipodi:docname=
"Selected_Agent.svg"
inkscape:version=
"0.92.4 (5da689c313, 2019-01-14)"
><metadata
xmlns:dc=
"http://purl.org/dc/elements/1.1/"
xmlns:cc=
"http://creativecommons.org/ns#"
xmlns:rdf=
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns=
"http://www.w3.org/2000/svg"
xmlns:sodipodi=
"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape=
"http://www.inkscape.org/namespaces/inkscape"
version=
"1.1"
id=
"Ebene_1"
x=
"0px"
y=
"0px"
viewBox=
"0 0 240 240"
style=
"enable-background:new 0 0 240 240;"
xml:space=
"preserve"
sodipodi:docname=
"Selected_Agent.svg"
inkscape:version=
"0.92.4 (5da689c313, 2019-01-14)"
><metadata
id=
"metadata11"
><rdf:RDF><cc:Work
rdf:about=
""
><dc:format>
image/svg+xml
</dc:format><dc:type
rdf:resource=
"http://purl.org/dc/dcmitype/StillImage"
/><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
rdf:resource=
"http://purl.org/dc/dcmitype/StillImage"
/><dc:title/></cc:Work></rdf:RDF></metadata>
<defs
id=
"defs9"
/><sodipodi:namedview
pagecolor=
"#ffffff"
bordercolor=
"#666666"
borderopacity=
"1"
objecttolerance=
"10"
gridtolerance=
"10"
guidetolerance=
"10"
inkscape:pageopacity=
"0"
inkscape:pageshadow=
"2"
inkscape:window-width=
"1920"
inkscape:window-height=
"1137"
id=
"namedview7"
showgrid=
"false"
inkscape:zoom=
"2.7812867"
inkscape:cx=
"
205.50339
"
inkscape:cy=
"161.549"
inkscape:window-x=
"-8"
inkscape:window-y=
"-8"
inkscape:window-maximized=
"1"
inkscape:current-layer=
"Ebene_1"
/>
pagecolor=
"#ffffff"
bordercolor=
"#666666"
borderopacity=
"1"
objecttolerance=
"10"
gridtolerance=
"10"
guidetolerance=
"10"
inkscape:pageopacity=
"0"
inkscape:pageshadow=
"2"
inkscape:window-width=
"1920"
inkscape:window-height=
"1137"
id=
"namedview7"
showgrid=
"false"
inkscape:zoom=
"2.7812867"
inkscape:cx=
"
126.94263
"
inkscape:cy=
"161.549"
inkscape:window-x=
"-8"
inkscape:window-y=
"-8"
inkscape:window-maximized=
"1"
inkscape:current-layer=
"Ebene_1"
/>
<style
type=
"text/css"
id=
"style2"
>
...
...
@@ -48,45 +48,60 @@
</style>
<rect
id=
"rect13"
width=
"23.389822"
height=
"23.38983"
x=
"1.697217e-07"
y=
"-0.23616901"
/><rect
id=
"rect13-0"
width=
"23.389822"
height=
"23.38983"
x=
"216.82077"
y=
"0.26172119"
/><rect
id=
"rect13-0-0"
width=
"23.389822"
height=
"23.38983"
x=
"216.75911"
y=
"216.39955"
/><rect
id=
"rect13-0-0-4"
width=
"23.389822"
height=
"23.38983"
x=
"0.50847793"
y=
"216.6974"
/><rect
id=
"rect60"
width=
"2.5168207"
height=
"198.4693"
x=
"10.067283"
y=
"22.474777"
/><rect
id=
"rect60-8"
width=
"2.5168207"
height=
"198.4693"
x=
"228.49136"
y=
"22.115229"
/><rect
id=
"rect60-8-5"
width=
"2.5168207"
height=
"198.4693"
x=
"-11.868174"
y=
"19.775019"
transform=
"rotate(-90)"
/><rect
id=
"rect60-8-5-1"
width=
"2.5168207"
height=
"198.4693"
x=
"-230.11249"
y=
"20.853657"
transform=
"rotate(-90)"
/></svg>
\ No newline at end of file
id=
"rect13"
width=
"23.389822"
height=
"23.38983"
x=
"1.697217e-07"
y=
"-0.23616901"
style=
"fill:#ff0000"
/>
<rect
id=
"rect13-0"
width=
"23.389822"
height=
"23.38983"
x=
"216.82077"
y=
"0.26172119"
style=
"fill:#ff0000"
/>
<rect
id=
"rect13-0-0"
width=
"23.389822"
height=
"23.38983"
x=
"216.75911"
y=
"216.39955"
style=
"fill:#ff0000"
/>
<rect
id=
"rect13-0-0-4"
width=
"23.389822"
height=
"23.38983"
x=
"0.50847793"
y=
"216.6974"
style=
"fill:#ff0000"
/>
<rect
id=
"rect60"
width=
"2.5741608"
height=
"240.53616"
x=
"1.697217e-07"
y=
"-0.23616901"
style=
"stroke-width:1.11335897;fill:#ff0000"
/>
<rect
id=
"rect60-8"
width=
"2.5741608"
height=
"239.45752"
x=
"237.63643"
y=
"0.26172119"
style=
"stroke-width:1.11085987;fill:#ff0000"
/>
<rect
id=
"rect60-8-5"
width=
"2.5168207"
height=
"237.86693"
x=
"-2.778542"
y=
"2.3436601"
transform=
"rotate(-90)"
style=
"stroke-width:1.09476364;fill:#ff0000"
/>
<rect
id=
"rect60-8-5-1"
width=
"2.5168207"
height=
"240.0242"
x=
"-240.29999"
y=
"1.6972172e-07"
transform=
"rotate(-90)"
style=
"stroke-width:1.09971678;fill:#ff0000"
/></svg>
This diff is collapsed.
Click to expand it.
svg/Selected_Target.svg
+
65
−
62
View file @
229ddb8c
...
...
@@ -2,45 +2,45 @@
<!-- Generator: Adobe Illustrator 23.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:dc=
"http://purl.org/dc/elements/1.1/"
xmlns:cc=
"http://creativecommons.org/ns#"
xmlns:rdf=
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg=
"http://www.w3.org/2000/svg"
xmlns=
"http://www.w3.org/2000/svg"
xmlns:sodipodi=
"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape=
"http://www.inkscape.org/namespaces/inkscape"
version=
"1.1"
id=
"Ebene_1"
x=
"0px"
y=
"0px"
viewBox=
"0 0 240 240"
style=
"enable-background:new 0 0 240 240;"
xml:space=
"preserve"
sodipodi:docname=
"Selected_Target.svg"
inkscape:version=
"0.92.4 (5da689c313, 2019-01-14)"
><metadata
xmlns:dc=
"http://purl.org/dc/elements/1.1/"
xmlns:cc=
"http://creativecommons.org/ns#"
xmlns:rdf=
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns=
"http://www.w3.org/2000/svg"
xmlns:sodipodi=
"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape=
"http://www.inkscape.org/namespaces/inkscape"
version=
"1.1"
id=
"Ebene_1"
x=
"0px"
y=
"0px"
viewBox=
"0 0 240 240"
style=
"enable-background:new 0 0 240 240;"
xml:space=
"preserve"
sodipodi:docname=
"Selected_Target.svg"
inkscape:version=
"0.92.4 (5da689c313, 2019-01-14)"
><metadata
id=
"metadata11"
><rdf:RDF><cc:Work
rdf:about=
""
><dc:format>
image/svg+xml
</dc:format><dc:type
rdf:resource=
"http://purl.org/dc/dcmitype/StillImage"
/><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
rdf:resource=
"http://purl.org/dc/dcmitype/StillImage"
/><dc:title/></cc:Work></rdf:RDF></metadata>
<defs
id=
"defs9"
/><sodipodi:namedview
pagecolor=
"#ffffff"
bordercolor=
"#666666"
borderopacity=
"1"
objecttolerance=
"10"
gridtolerance=
"10"
guidetolerance=
"10"
inkscape:pageopacity=
"0"
inkscape:pageshadow=
"2"
inkscape:window-width=
"1920"
inkscape:window-height=
"1137"
id=
"namedview7"
showgrid=
"false"
inkscape:zoom=
"2.7812867"
inkscape:cx=
"
126.94263
"
inkscape:cy=
"161.549"
inkscape:window-x=
"-8"
inkscape:window-y=
"-8"
inkscape:window-maximized=
"1"
inkscape:current-layer=
"Ebene_1"
/>
pagecolor=
"#ffffff"
bordercolor=
"#666666"
borderopacity=
"1"
objecttolerance=
"10"
gridtolerance=
"10"
guidetolerance=
"10"
inkscape:pageopacity=
"0"
inkscape:pageshadow=
"2"
inkscape:window-width=
"1920"
inkscape:window-height=
"1137"
id=
"namedview7"
showgrid=
"false"
inkscape:zoom=
"2.7812867"
inkscape:cx=
"
48.381869
"
inkscape:cy=
"161.549"
inkscape:window-x=
"-8"
inkscape:window-y=
"-8"
inkscape:window-maximized=
"1"
inkscape:current-layer=
"Ebene_1"
/>
<style
type=
"text/css"
id=
"style2"
>
...
...
@@ -48,29 +48,32 @@
</style>
<rect
id=
"rect60"
width=
"2.5168207"
height=
"220.76114"
x=
"10.067283"
y=
"9.1715822"
style=
"stroke-width:1.05466521;fill:#999999"
/><rect
id=
"rect60-8"
width=
"2.5168207"
height=
"217.88478"
x=
"228.49136"
y=
"10.250217"
style=
"stroke-width:1.04777193;fill:#999999"
/><rect
id=
"rect60-8-5"
width=
"2.5168207"
height=
"220.04205"
x=
"-11.868174"
y=
"10.786373"
transform=
"rotate(-90)"
style=
"stroke-width:1.05294621;fill:#999999"
/><rect
id=
"rect60-8-5-1"
width=
"2.5168207"
height=
"220.40158"
x=
"-230.11249"
y=
"10.786374"
transform=
"rotate(-90)"
style=
"stroke-width:1.05380607;fill:#999999"
/></svg>
\ No newline at end of file
id=
"rect60"
width=
"13.303195"
height=
"220.04205"
x=
"10.067283"
y=
"9.8906736"
style=
"fill:#ff0000;stroke-width:2.42079496"
/>
<rect
id=
"rect60-8"
width=
"14.741379"
height=
"220.40161"
x=
"215.72748"
y=
"9.531127"
style=
"fill:#ff0000;stroke-width:2.5503726"
/>
<rect
id=
"rect60-8-5"
width=
"12.584104"
height=
"220.04205"
x=
"-22.115231"
y=
"10.4268"
transform=
"rotate(-90)"
style=
"fill:#ff0000;stroke-width:2.35445929"
/>
<rect
id=
"rect60-8-5-1"
width=
"13.662741"
height=
"220.40158"
x=
"216.26999"
y=
"10.067283"
transform=
"matrix(0,1,1,0,0,0)"
style=
"fill:#ff0000;stroke-width:2.45529389"
/></svg>
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