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): ...@@ -220,9 +220,7 @@ class RailEnv(Environment):
if action > 0: if action > 0:
cell_isFree, new_cell_isValid, new_direction, new_position, transition_isValid = self._check_action_on_agent(action, cell_isFree, new_cell_isValid, new_direction, new_position, transition_isValid = self._check_action_on_agent(action,
agent, agent)
transition_isValid)
if all([new_cell_isValid, transition_isValid, cell_isFree]): if all([new_cell_isValid, transition_isValid, cell_isFree]):
# move and change direction to face the new_direction that was # move and change direction to face the new_direction that was
# performed # performed
......
%% 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 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'> <super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>
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 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'> <super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>
%% 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)
......
...@@ -2,45 +2,45 @@ ...@@ -2,45 +2,45 @@
<!-- Generator: Adobe Illustrator 23.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <!-- Generator: Adobe Illustrator 23.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg <svg
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#" xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-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="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.1"
version="1.1" id="Ebene_1"
id="Ebene_1" x="0px"
x="0px" y="0px"
y="0px" viewBox="0 0 240 240"
viewBox="0 0 240 240" style="enable-background:new 0 0 240 240;"
style="enable-background:new 0 0 240 240;" xml:space="preserve"
xml:space="preserve" sodipodi:docname="Selected_Agent.svg"
sodipodi:docname="Selected_Agent.svg" inkscape:version="0.92.4 (5da689c313, 2019-01-14)"><metadata
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"><metadata
id="metadata11"><rdf:RDF><cc:Work id="metadata11"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type 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 id="defs9" /><sodipodi:namedview
pagecolor="#ffffff" pagecolor="#ffffff"
bordercolor="#666666" bordercolor="#666666"
borderopacity="1" borderopacity="1"
objecttolerance="10" objecttolerance="10"
gridtolerance="10" gridtolerance="10"
guidetolerance="10" guidetolerance="10"
inkscape:pageopacity="0" inkscape:pageopacity="0"
inkscape:pageshadow="2" inkscape:pageshadow="2"
inkscape:window-width="1920" inkscape:window-width="1920"
inkscape:window-height="1137" inkscape:window-height="1137"
id="namedview7" id="namedview7"
showgrid="false" showgrid="false"
inkscape:zoom="2.7812867" inkscape:zoom="2.7812867"
inkscape:cx="205.50339" inkscape:cx="126.94263"
inkscape:cy="161.549" inkscape:cy="161.549"
inkscape:window-x="-8" inkscape:window-x="-8"
inkscape:window-y="-8" inkscape:window-y="-8"
inkscape:window-maximized="1" inkscape:window-maximized="1"
inkscape:current-layer="Ebene_1" /> inkscape:current-layer="Ebene_1" />
<style <style
type="text/css" type="text/css"
id="style2"> id="style2">
...@@ -48,45 +48,60 @@ ...@@ -48,45 +48,60 @@
</style> </style>
<rect <rect
id="rect13" id="rect13"
width="23.389822" width="23.389822"
height="23.38983" height="23.38983"
x="1.697217e-07" x="1.697217e-07"
y="-0.23616901" /><rect y="-0.23616901"
id="rect13-0" style="fill:#ff0000"/>
width="23.389822" <rect
height="23.38983" id="rect13-0"
x="216.82077" width="23.389822"
y="0.26172119" /><rect height="23.38983"
id="rect13-0-0" x="216.82077"
width="23.389822" y="0.26172119"
height="23.38983" style="fill:#ff0000"/>
x="216.75911" <rect
y="216.39955" /><rect id="rect13-0-0"
id="rect13-0-0-4" width="23.389822"
width="23.389822" height="23.38983"
height="23.38983" x="216.75911"
x="0.50847793" y="216.39955"
y="216.6974" /><rect style="fill:#ff0000"/>
id="rect60" <rect
width="2.5168207" id="rect13-0-0-4"
height="198.4693" width="23.389822"
x="10.067283" height="23.38983"
y="22.474777" /><rect x="0.50847793"
id="rect60-8" y="216.6974"
width="2.5168207" style="fill:#ff0000"/>
height="198.4693" <rect
x="228.49136" id="rect60"
y="22.115229" /><rect width="2.5741608"
id="rect60-8-5" height="240.53616"
width="2.5168207" x="1.697217e-07"
height="198.4693" y="-0.23616901"
x="-11.868174" style="stroke-width:1.11335897;fill:#ff0000"/>
y="19.775019" <rect
transform="rotate(-90)" /><rect id="rect60-8"
id="rect60-8-5-1" width="2.5741608"
width="2.5168207" height="239.45752"
height="198.4693" x="237.63643"
x="-230.11249" y="0.26172119"
y="20.853657" style="stroke-width:1.11085987;fill:#ff0000"/>
transform="rotate(-90)" /></svg> <rect
\ No newline at end of file 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 @@ ...@@ -2,45 +2,45 @@
<!-- Generator: Adobe Illustrator 23.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <!-- Generator: Adobe Illustrator 23.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg <svg
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#" xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-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="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.1"
version="1.1" id="Ebene_1"
id="Ebene_1" x="0px"
x="0px" y="0px"
y="0px" viewBox="0 0 240 240"
viewBox="0 0 240 240" style="enable-background:new 0 0 240 240;"
style="enable-background:new 0 0 240 240;" xml:space="preserve"
xml:space="preserve" sodipodi:docname="Selected_Target.svg"
sodipodi:docname="Selected_Target.svg" inkscape:version="0.92.4 (5da689c313, 2019-01-14)"><metadata
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"><metadata
id="metadata11"><rdf:RDF><cc:Work id="metadata11"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type 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 id="defs9" /><sodipodi:namedview
pagecolor="#ffffff" pagecolor="#ffffff"
bordercolor="#666666" bordercolor="#666666"
borderopacity="1" borderopacity="1"
objecttolerance="10" objecttolerance="10"
gridtolerance="10" gridtolerance="10"
guidetolerance="10" guidetolerance="10"
inkscape:pageopacity="0" inkscape:pageopacity="0"
inkscape:pageshadow="2" inkscape:pageshadow="2"
inkscape:window-width="1920" inkscape:window-width="1920"
inkscape:window-height="1137" inkscape:window-height="1137"
id="namedview7" id="namedview7"
showgrid="false" showgrid="false"
inkscape:zoom="2.7812867" inkscape:zoom="2.7812867"
inkscape:cx="126.94263" inkscape:cx="48.381869"
inkscape:cy="161.549" inkscape:cy="161.549"
inkscape:window-x="-8" inkscape:window-x="-8"
inkscape:window-y="-8" inkscape:window-y="-8"
inkscape:window-maximized="1" inkscape:window-maximized="1"
inkscape:current-layer="Ebene_1" /> inkscape:current-layer="Ebene_1" />
<style <style
type="text/css" type="text/css"
id="style2"> id="style2">
...@@ -48,29 +48,32 @@ ...@@ -48,29 +48,32 @@
</style> </style>
<rect <rect
id="rect60" id="rect60"
width="2.5168207" width="13.303195"
height="220.76114" height="220.04205"
x="10.067283" x="10.067283"
y="9.1715822" y="9.8906736"
style="stroke-width:1.05466521;fill:#999999" /><rect style="fill:#ff0000;stroke-width:2.42079496"/>
id="rect60-8" <rect
width="2.5168207" id="rect60-8"
height="217.88478" width="14.741379"
x="228.49136" height="220.40161"
y="10.250217" x="215.72748"
style="stroke-width:1.04777193;fill:#999999" /><rect y="9.531127"
id="rect60-8-5" style="fill:#ff0000;stroke-width:2.5503726"/>
width="2.5168207" <rect
height="220.04205" id="rect60-8-5"
x="-11.868174" width="12.584104"
y="10.786373" height="220.04205"
transform="rotate(-90)" x="-22.115231"
style="stroke-width:1.05294621;fill:#999999" /><rect y="10.4268"
id="rect60-8-5-1" transform="rotate(-90)"
width="2.5168207" style="fill:#ff0000;stroke-width:2.35445929"/>
height="220.40158" <rect
x="-230.11249" id="rect60-8-5-1"
y="10.786374" width="13.662741"
transform="rotate(-90)" height="220.40158"
style="stroke-width:1.05380607;fill:#999999" /></svg> x="216.26999"
\ No newline at end of file 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