Skip to content
Snippets Groups Projects
Editor2.ipynb 6.09 KiB
Newer Older
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Rail Editor v0.2"
   ]
  },
  {
   "cell_type": "code",
Egli Adrian (IT-SCI-API-PFI)'s avatar
Egli Adrian (IT-SCI-API-PFI) committed
   "execution_count": 1,
   "metadata": {},
Egli Adrian (IT-SCI-API-PFI)'s avatar
Egli Adrian (IT-SCI-API-PFI) committed
   "outputs": [],
hagrid67's avatar
hagrid67 committed
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2"
   ]
  },
  {
   "cell_type": "code",
Egli Adrian (IT-SCI-API-PFI)'s avatar
Egli Adrian (IT-SCI-API-PFI) committed
   "execution_count": 2,
hagrid67's avatar
hagrid67 committed
   "metadata": {},
   "outputs": [],
   "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",
Egli Adrian (IT-SCI-API-PFI)'s avatar
Egli Adrian (IT-SCI-API-PFI) committed
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
hagrid67's avatar
hagrid67 committed
       "<style>.container { width:95% !important; }</style>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
hagrid67's avatar
hagrid67 committed
    "display(HTML(\"<style>.container { width:95% !important; }</style>\"))"
   ]
  },
  {
   "cell_type": "code",
Egli Adrian (IT-SCI-API-PFI)'s avatar
Egli Adrian (IT-SCI-API-PFI) committed
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (graphics_pil.py, line 263)",
     "output_type": "error",
     "traceback": [
      "Traceback \u001b[1;36m(most recent call last)\u001b[0m:\n",
      "  File \u001b[0;32m\"c:\\users\\u216993\\appdata\\local\\programs\\python\\python36\\lib\\site-packages\\IPython\\core\\interactiveshell.py\"\u001b[0m, line \u001b[0;32m3291\u001b[0m, in \u001b[0;35mrun_code\u001b[0m\n    exec(code_obj, self.user_global_ns, self.user_ns)\n",
      "  File \u001b[0;32m\"<ipython-input-4-cd594490df80>\"\u001b[0m, line \u001b[0;32m1\u001b[0m, in \u001b[0;35m<module>\u001b[0m\n    from flatland.utils.editor import EditorMVC, EditorModel, View, Controller\n",
      "  File \u001b[0;32m\"c:\\users\\u216993\\appdata\\local\\programs\\python\\python36\\lib\\site-packages\\flatland_rl-0.1.1-py3.6.egg\\flatland\\utils\\editor.py\"\u001b[0m, line \u001b[0;32m21\u001b[0m, in \u001b[0;35m<module>\u001b[0m\n    import flatland.utils.rendertools as rt\n",
      "\u001b[1;36m  File \u001b[1;32m\"c:\\users\\u216993\\appdata\\local\\programs\\python\\python36\\lib\\site-packages\\flatland_rl-0.1.1-py3.6.egg\\flatland\\utils\\rendertools.py\"\u001b[1;36m, line \u001b[1;32m7\u001b[1;36m, in \u001b[1;35m<module>\u001b[1;36m\u001b[0m\n\u001b[1;33m    from flatland.utils.graphics_pil import PILGL, PILSVG\u001b[0m\n",
      "\u001b[1;36m  File \u001b[1;32m\"c:\\users\\u216993\\appdata\\local\\programs\\python\\python36\\lib\\site-packages\\flatland_rl-0.1.1-py3.6.egg\\flatland\\utils\\graphics_pil.py\"\u001b[1;36m, line \u001b[1;32m263\u001b[0m\n\u001b[1;33m    newList.append( [word for word in os.listdir(directory): if word.startswith('flatland')] )\u001b[0m\n\u001b[1;37m                                                           ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
   "source": [
    "from flatland.utils.editor import EditorMVC, EditorModel, View, Controller"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {},
    "mvc = EditorMVC(sGL=\"PIL\" ) # 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
   },
   "source": [
    "mvc.view.display()"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
hagrid67's avatar
hagrid67 committed
    "scrolled": false
   "source": [
    "mvc.view.wOutput.clear_output()\n",
    "mvc.view.wOutput"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {},
   "source": [
    "len(mvc.editor.env.agents), len(mvc.editor.env.agents_static)"
   ]
  }
 ],
 "metadata": {
  "hide_input": false,
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  },
  "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
}