diff --git a/flatland/utils/editor.py b/flatland/utils/editor.py index a2e43ea6271d30146ca0d213e33188569bbe002a..e22e15af7cf18ab66a81260d5ab631ad3c5d822c 100644 --- a/flatland/utils/editor.py +++ b/flatland/utils/editor.py @@ -115,7 +115,7 @@ class View(object): self.wRegenSizeHeight.observe(self.controller.setRegenSizeHeight, names="value") # Number of Agents when regenerating - self.wRegenNAgents = IntSlider(value=1, min=0, max=20, step=1, description="# Agents", + self.wRegenNAgents = IntSlider(value=1, min=0, max=5, step=1, description="# Agents", tip="Click regenerate or reset after changing this") self.wRegenMethod = RadioButtons(description="Regen\nMethod", options=["Empty", "Random Cell", "Path-based"]) @@ -136,12 +136,11 @@ class View(object): # abbreviated description of buttons and the methods they call ldButtons = [ dict(name="Refresh", method=self.controller.refresh, tip="Redraw only"), - dict(name="Clear", method=self.controller.clear, tip="Clear rails and agents"), - dict(name="Reset", method=self.controller.reset, - tip="Standard env reset, including regen rail + agents"), dict(name="Rotate Agent", method=self.controller.rotate_agent, tip="Rotate selected agent"), dict(name="Restart Agents", method=self.controller.restartAgents, tip="Move agents back to start positions"), + dict(name="Random", method=self.controller.reset, + tip="Generate a randomized scene, including regen rail + agents"), dict(name="Regenerate", method=self.controller.regenerate, tip="Regenerate the rails using the method selected below"), dict(name="Load", method=self.controller.load), @@ -650,8 +649,7 @@ class EditorModel(object): def reset(self, replace_agents=False, nAgents=0): # if replace_agents: # self.env.agents_handles = range(nAgents) - self.env.reset(regen_rail=True, replace_agents=replace_agents) - self.player = None + self.regenerate("complex", nAgents=nAgents) self.redraw() def restartAgents(self): @@ -703,7 +701,7 @@ class EditorModel(object): elif method == "Random Cell": fnMethod = random_rail_generator(cell_type_relative_proportion=[1] * 11) else: - fnMethod = complex_rail_generator(nr_start_goal=5, nr_extra=20, min_dist=12) + fnMethod = complex_rail_generator(nr_start_goal=nAgents, nr_extra=20, min_dist=12, seed=int(time.time())) if env is None: self.env = RailEnv(width=self.regen_size_width, diff --git a/notebooks/Editor2.ipynb b/notebooks/Editor2.ipynb index ddfea41efa25d4c789522e051fb5bb8a1e8e3ef2..9d6e41c98d6dbdf2019eaa4793fa0b82382080a6 100644 --- a/notebooks/Editor2.ipynb +++ b/notebooks/Editor2.ipynb @@ -9,18 +9,9 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 1, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The autoreload extension is already loaded. To reload it, use:\n", - " %reload_ext autoreload\n" - ] - } - ], + "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2" @@ -28,7 +19,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -41,7 +32,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -63,23 +54,31 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "cairo installed: OK\n" + ] + } + ], "source": [ "from flatland.utils.editor import EditorMVC, EditorModel, View, Controller" ] }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "<flatland.utils.graphics_pil.PILSVG object at 0x000001FC6FB9E198> <class 'flatland.utils.graphics_pil.PILSVG'>\n", + "<flatland.utils.graphics_pil.PILSVG object at 0x0000022E68851F98> <class 'flatland.utils.graphics_pil.PILSVG'>\n", "<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n", "Clear rails\n" ] @@ -116,7 +115,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 6, "metadata": { "scrolled": false }, @@ -124,7 +123,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "df04f776b29f456eabb20b9587ea1f16", + "model_id": "3919c0bba981455285a93e045e305a05", "version_major": 2, "version_minor": 0 }, @@ -139,11 +138,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "<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", + "<flatland.utils.graphics_pil.PILSVG object at 0x0000022E6919E630> <class 'flatland.utils.graphics_pil.PILSVG'>\n", "<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n" ] } @@ -154,7 +149,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 7, "metadata": { "scrolled": false }, @@ -162,7 +157,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "6c0846dadce244ed877d53410dcfe0a7", + "model_id": "b91a94da22c846808020ab2aa1bc5ba7", "version_major": 2, "version_minor": 0 }, @@ -181,7 +176,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -190,7 +185,7 @@ "(0, 0)" ] }, - "execution_count": 16, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" }