Newer
Older
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Rail Editor v0.2"
]
},
{
"cell_type": "code",
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"source": [
"import numpy as np\n",
"from numpy import array\n",
"import ipywidgets\n",
"import IPython\n",
"from IPython.core.display import display, HTML"
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<style>.container { width:95% !important; }</style>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"display(HTML(\"<style>.container { width:95% !important; }</style>\"))"
]
},
{
"cell_type": "code",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cairo installed: OK\n"
]
}
],
"source": [
"from flatland.utils.editor import EditorMVC, EditorModel, View, Controller"
]
},
{
"cell_type": "code",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<flatland.utils.graphics_pil.PILSVG object at 0x00000228826E5048> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n",
"Clear rails\n"
]
},
{
"data": {
"text/plain": [
"<Figure size 432x288 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"mvc = EditorMVC(sGL=\"PILSVG\" ) # sGL=\"PIL\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Instructions\n",
"- Drag to draw (improved dead-ends)\n",
"- Shift-Drag to erase rails (erasing dead ends not yet automated - drag right across them)\n",
"- ctrl-click to add agent\n",
" - direction chosen randomly to fit rail\n",
"- ctrl-shift-click to add target for last agent\n",
" - target can be moved by repeating\n",
"- to Resize the env (cannot preserve work):\n",
" - select \"Regen\" tab, set regen size slider, click regenerate.\n",
"- alt-click remove all rails from cell \n"
]
},
{
"cell_type": "code",
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a70b4e1bbe8a41cc85af8e0073862bf3",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Canvas(), VBox(children=(Text(value='temp.pkl', description='Filename'), Button(description='Re…"
]
},
"metadata": {},
"output_type": "display_data"
"name": "stdout",
"output_type": "stream",
"text": [
"<flatland.utils.graphics_pil.PILSVG object at 0x0000022882FA48D0> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n",
"<flatland.utils.graphics_pil.PILSVG object at 0x000002288301CEB8> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n",
"<flatland.utils.graphics_pil.PILSVG object at 0x000002288318CD30> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n",
"<flatland.utils.graphics_pil.PILSVG object at 0x0000022883001D30> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n",
"<flatland.utils.graphics_pil.PILSVG object at 0x0000022882FCC438> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n",
"<flatland.utils.graphics_pil.PILSVG object at 0x0000022886C20668> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n",
"complex_rail_generator: num_agents > nr_start_goal, changing num_agents\n",
"complex_rail_generator: num_agents > nr_start_goal, changing num_agents\n",
"<flatland.utils.graphics_pil.PILSVG object at 0x0000022882DF7518> <class 'flatland.utils.graphics_pil.PILSVG'>\n",
"<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>\n"
"source": [
"mvc.view.display()"
]
},
{
"cell_type": "code",
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8fb6b8a5c8374de29ab80c6b62cd8fd9",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"mvc.view.wOutput.clear_output()\n",
"mvc.view.wOutput"
]
"outputs": [
{
"data": {
"text/plain": [
"(0, 0)"
]
},
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(mvc.editor.env.agents), len(mvc.editor.env.agents_static)"
]
}
],
"metadata": {
"hide_input": false,
"kernelspec": {
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autoclose": false,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 2
}