Skip to content
Snippets Groups Projects
Commit 229ddb8c authored by Egli Adrian (IT-SCI-API-PFI)'s avatar Egli Adrian (IT-SCI-API-PFI)
Browse files

Bugfix: code cleanup

parent c1b96225
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
%% 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 0x0000022C5FB44198> <class 'flatland.utils.graphics_pil.PILSVG'>
<flatland.utils.graphics_pil.PILSVG object at 0x000001FC6FB9E198> <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)
......
......@@ -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>
......@@ -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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment