From 229ddb8c5777047da16c3827a77f61d3b85db351 Mon Sep 17 00:00:00 2001 From: "Egli Adrian (IT-SCI-API-PFI)" <adrian.egli@sbb.ch> Date: Tue, 4 Jun 2019 14:14:21 +0200 Subject: [PATCH] Bugfix: code cleanup --- flatland/envs/rail_env.py | 4 +- notebooks/Editor2.ipynb | 51 +++++++----- svg/Selected_Agent.svg | 171 +++++++++++++++++++++----------------- svg/Selected_Target.svg | 127 ++++++++++++++-------------- 4 files changed, 187 insertions(+), 166 deletions(-) diff --git a/flatland/envs/rail_env.py b/flatland/envs/rail_env.py index 190a14ea..82d694cc 100644 --- a/flatland/envs/rail_env.py +++ b/flatland/envs/rail_env.py @@ -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 diff --git a/notebooks/Editor2.ipynb b/notebooks/Editor2.ipynb index 0645909b..ddfea41e 100644 --- a/notebooks/Editor2.ipynb +++ b/notebooks/Editor2.ipynb @@ -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 0x0000022C5FB44198> <class 'flatland.utils.graphics_pil.PILSVG'>\n", + "<flatland.utils.graphics_pil.PILSVG object at 0x000001FC6FB9E198> <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" } diff --git a/svg/Selected_Agent.svg b/svg/Selected_Agent.svg index 15761df8..ca607153 100644 --- a/svg/Selected_Agent.svg +++ b/svg/Selected_Agent.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_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> diff --git a/svg/Selected_Target.svg b/svg/Selected_Target.svg index a848696a..d5834efc 100644 --- a/svg/Selected_Target.svg +++ b/svg/Selected_Target.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> -- GitLab