index.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <!doctype html>
  2. <html class="no-js">
  3. <head><meta charset="utf-8"/>
  4. <meta name="viewport" content="width=device-width,initial-scale=1"/>
  5. <meta name="color-scheme" content="light dark"><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
  6. <link rel="index" title="Index" href="../../genindex/" /><link rel="search" title="Search" href="../../search/" /><link rel="next" title="Included environments" href="../" /><link rel="prev" title="List of publications" href="../../content/pubs/" />
  7. <link rel="canonical" href="https://minigrid.farama.org/environments/design.html" />
  8. <link rel="shortcut icon" href="../../_static/minigrid-white.png"/><meta name="generator" content="sphinx-4.2.0, furo 2022.06.21"/>
  9. <title>General Structure - MiniGrid Documentation</title>
  10. <link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
  11. <link rel="stylesheet" type="text/css" href="../../_static/styles/furo.css?digest=40978830699223671f4072448e654b5958f38b89" />
  12. <link rel="stylesheet" type="text/css" href="../../_static/styles/furo-extensions.css?digest=30d1aed668e5c3a91c3e3bf6a60b675221979f0e" />
  13. <link rel="stylesheet" type="text/css" href="../../_static/css/custom.css" />
  14. <style>
  15. body {
  16. --color-code-background: #f8f8f8;
  17. --color-code-foreground: black;
  18. }
  19. @media not print {
  20. body[data-theme="dark"] {
  21. --color-code-background: #202020;
  22. --color-code-foreground: #d0d0d0;
  23. }
  24. @media (prefers-color-scheme: dark) {
  25. body:not([data-theme="light"]) {
  26. --color-code-background: #202020;
  27. --color-code-foreground: #d0d0d0;
  28. }
  29. }
  30. }
  31. </style></head>
  32. <body>
  33. <script>
  34. document.body.dataset.theme = localStorage.getItem("theme") || "auto";
  35. </script>
  36. <svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
  37. <symbol id="svg-toc" viewBox="0 0 24 24">
  38. <title>Contents</title>
  39. <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024">
  40. <path d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM115.4 518.9L271.7 642c5.8 4.6 14.4.5 14.4-6.9V388.9c0-7.4-8.5-11.5-14.4-6.9L115.4 505.1a8.74 8.74 0 0 0 0 13.8z"/>
  41. </svg>
  42. </symbol>
  43. <symbol id="svg-menu" viewBox="0 0 24 24">
  44. <title>Menu</title>
  45. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  46. stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-menu">
  47. <line x1="3" y1="12" x2="21" y2="12"></line>
  48. <line x1="3" y1="6" x2="21" y2="6"></line>
  49. <line x1="3" y1="18" x2="21" y2="18"></line>
  50. </svg>
  51. </symbol>
  52. <symbol id="svg-arrow-right" viewBox="0 0 24 24">
  53. <title>Expand</title>
  54. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  55. stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-chevron-right">
  56. <polyline points="9 18 15 12 9 6"></polyline>
  57. </svg>
  58. </symbol>
  59. <symbol id="svg-sun" viewBox="0 0 24 24">
  60. <title>Light mode</title>
  61. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  62. stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather-sun">
  63. <circle cx="12" cy="12" r="5"></circle>
  64. <line x1="12" y1="1" x2="12" y2="3"></line>
  65. <line x1="12" y1="21" x2="12" y2="23"></line>
  66. <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
  67. <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
  68. <line x1="1" y1="12" x2="3" y2="12"></line>
  69. <line x1="21" y1="12" x2="23" y2="12"></line>
  70. <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
  71. <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
  72. </svg>
  73. </symbol>
  74. <symbol id="svg-moon" viewBox="0 0 24 24">
  75. <title>Dark mode</title>
  76. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  77. stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-moon">
  78. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  79. <path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z" />
  80. </svg>
  81. </symbol>
  82. <symbol id="svg-sun-half" viewBox="0 0 24 24">
  83. <title>Auto light/dark mode</title>
  84. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  85. stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-shadow">
  86. <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
  87. <circle cx="12" cy="12" r="9" />
  88. <path d="M13 12h5" />
  89. <path d="M13 15h4" />
  90. <path d="M13 18h1" />
  91. <path d="M13 9h4" />
  92. <path d="M13 6h1" />
  93. </svg>
  94. </symbol>
  95. </svg>
  96. <input type="checkbox" class="sidebar-toggle" name="__navigation" id="__navigation">
  97. <input type="checkbox" class="sidebar-toggle" name="__toc" id="__toc">
  98. <label class="overlay sidebar-overlay" for="__navigation">
  99. <div class="visually-hidden">Hide navigation sidebar</div>
  100. </label>
  101. <label class="overlay toc-overlay" for="__toc">
  102. <div class="visually-hidden">Hide table of contents sidebar</div>
  103. </label>
  104. <div class="page">
  105. <header class="mobile-header">
  106. <div class="header-left">
  107. <label class="nav-overlay-icon" for="__navigation">
  108. <div class="visually-hidden">Toggle site navigation sidebar</div>
  109. <i class="icon"><svg><use href="#svg-menu"></use></svg></i>
  110. </label>
  111. </div>
  112. <div class="header-center">
  113. <a href="../../"><div class="brand">MiniGrid Documentation</div></a>
  114. </div>
  115. <div class="header-right">
  116. <div class="theme-toggle-container theme-toggle-header">
  117. <button class="theme-toggle">
  118. <div class="visually-hidden">Toggle Light / Dark / Auto color theme</div>
  119. <svg class="theme-icon-when-auto"><use href="#svg-sun-half"></use></svg>
  120. <svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
  121. <svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
  122. </button>
  123. </div>
  124. <label class="toc-overlay-icon toc-header-icon no-toc" for="__toc">
  125. <div class="visually-hidden">Toggle table of contents sidebar</div>
  126. <i class="icon"><svg><use href="#svg-toc"></use></svg></i>
  127. </label>
  128. </div>
  129. </header>
  130. <aside class="sidebar-drawer">
  131. <div class="sidebar-container">
  132. <div class="sidebar-sticky"><a class="sidebar-brand" href="../../">
  133. <div class="sidebar-logo-container">
  134. <img class="sidebar-logo only-light" src="../../_static/img/minigrid.png" alt="Light Logo"/>
  135. <img class="sidebar-logo only-dark" src="../../_static/img/minigrid-white.png" alt="Dark Logo"/>
  136. </div>
  137. <span class="sidebar-brand-text">MiniGrid Documentation</span>
  138. </a><form class="sidebar-search-container" method="get" action="../../search/" role="search">
  139. <input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
  140. <input type="hidden" name="check_keywords" value="yes">
  141. <input type="hidden" name="area" value="default">
  142. </form>
  143. <div id="searchbox"></div><div class="sidebar-scroll"><div class="sidebar-tree">
  144. <p class="caption" role="heading"><span class="caption-text">Introduction</span></p>
  145. <ul>
  146. <li class="toctree-l1"><a class="reference internal" href="../../content/installation/">Installation</a></li>
  147. <li class="toctree-l1"><a class="reference internal" href="../../content/basic_usage/">Basic Usage</a></li>
  148. <li class="toctree-l1"><a class="reference internal" href="../../api/wrappers/">Wrappers</a></li>
  149. <li class="toctree-l1"><a class="reference internal" href="../../content/pubs/">List of publications</a></li>
  150. </ul>
  151. <p class="caption" role="heading"><span class="caption-text">Environments</span></p>
  152. <ul class="current">
  153. <li class="toctree-l1 current current-page"><a class="current reference internal" href="#">General Structure</a></li>
  154. <li class="toctree-l1 has-children"><a class="reference internal" href="../">Included environments</a><input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" role="switch" type="checkbox"/><label for="toctree-checkbox-1"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
  155. <li class="toctree-l2"><a class="reference internal" href="../empty/">Empty</a></li>
  156. <li class="toctree-l2"><a class="reference internal" href="../four_rooms/">Four Rooms</a></li>
  157. <li class="toctree-l2"><a class="reference internal" href="../door_key/">Door Key</a></li>
  158. <li class="toctree-l2"><a class="reference internal" href="../multi_room/">Multi Room</a></li>
  159. <li class="toctree-l2"><a class="reference internal" href="../fetch/">Fetch</a></li>
  160. <li class="toctree-l2"><a class="reference internal" href="../go_to_door/">Go To Door</a></li>
  161. <li class="toctree-l2"><a class="reference internal" href="../put_near/">Put Near</a></li>
  162. <li class="toctree-l2"><a class="reference internal" href="../red_blue_doors/">Red Blue Doors</a></li>
  163. <li class="toctree-l2"><a class="reference internal" href="../memory_s7/">Memory S7</a></li>
  164. <li class="toctree-l2"><a class="reference internal" href="../locked_room/">Locked Room</a></li>
  165. <li class="toctree-l2"><a class="reference internal" href="../key_corridor_s6_r3/">Key Corridor S6 R3</a></li>
  166. <li class="toctree-l2"><a class="reference internal" href="../unlock/">Unlock</a></li>
  167. <li class="toctree-l2"><a class="reference internal" href="../unlock_pickup/">Unlock Pickup</a></li>
  168. <li class="toctree-l2"><a class="reference internal" href="../blocked_unlock_pickup/">Blocked Unlock Pickup</a></li>
  169. <li class="toctree-l2"><a class="reference internal" href="../obstructed_maze/">Obstructed Maze</a></li>
  170. <li class="toctree-l2"><a class="reference internal" href="../dist_shift2/">Dist Shift2</a></li>
  171. <li class="toctree-l2"><a class="reference internal" href="../lava_gap_s7/">Lava Gap S7</a></li>
  172. <li class="toctree-l2"><a class="reference internal" href="../simple_crossing_s11_n5/">Simple Crossing S11 N5</a></li>
  173. <li class="toctree-l2"><a class="reference internal" href="../dynamic/">Dynamic</a></li>
  174. <li class="toctree-l2"><a class="reference internal" href="../go_to_object/">Go To Object</a></li>
  175. <li class="toctree-l2"><a class="reference internal" href="../playground/">Playground</a></li>
  176. </ul>
  177. </li>
  178. </ul>
  179. <p class="caption" role="heading"><span class="caption-text">Development</span></p>
  180. <ul>
  181. <li class="toctree-l1"><a class="reference external" href="https://github.com/Farama-Foundation/MiniGrid">Github</a></li>
  182. <li class="toctree-l1"><a class="reference external" href="https://farama.org/donations">Donate</a></li>
  183. <li class="toctree-l1"><a class="reference external" href="https://github.com/Farama-Foundation/MiniGrid/blob/master/.github/PULL_REQUEST_TEMPLATE.md">Contribute to the Docs</a></li>
  184. </ul>
  185. </div>
  186. </div>
  187. </div>
  188. </div>
  189. </aside>
  190. <div class="main">
  191. <div class="content">
  192. <div class="article-container">
  193. <a href="#" class="back-to-top muted-link">
  194. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
  195. <path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12z"></path>
  196. </svg>
  197. <span>Back to top</span>
  198. </a>
  199. <div class="content-icon-container">
  200. <div class="theme-toggle-container theme-toggle-content">
  201. <button class="theme-toggle">
  202. <div class="visually-hidden">Toggle Light / Dark / Auto color theme</div>
  203. <svg class="theme-icon-when-auto"><use href="#svg-sun-half"></use></svg>
  204. <svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
  205. <svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
  206. </button>
  207. </div>
  208. <label class="toc-overlay-icon toc-content-icon no-toc" for="__toc">
  209. <div class="visually-hidden">Toggle table of contents sidebar</div>
  210. <i class="icon"><svg><use href="#svg-toc"></use></svg></i>
  211. </label>
  212. </div>
  213. <article role="main">
  214. <section id="general-structure">
  215. <h1>General Structure<a class="headerlink" href="#general-structure" title="Permalink to this headline">#</a></h1>
  216. <p>Structure of the world:</p>
  217. <ul class="simple">
  218. <li><p>The world is an NxM grid of tiles</p></li>
  219. <li><p>Each tile in the grid world contains zero or one object</p>
  220. <ul>
  221. <li><p>Cells that do not contain an object have the value <code class="docutils literal notranslate"><span class="pre">None</span></code></p></li>
  222. </ul>
  223. </li>
  224. <li><p>Each object has an associated discrete color (string)</p></li>
  225. <li><p>Each object has an associated type (string)</p>
  226. <ul>
  227. <li><p>Provided object types are: wall, floor, lava, door, key, ball, box and goal</p></li>
  228. </ul>
  229. </li>
  230. <li><p>The agent can pick up and carry exactly one object (eg: ball or key)</p></li>
  231. <li><p>To open a locked door, the agent has to be carrying a key matching the door’s color</p></li>
  232. </ul>
  233. <p>Actions in the basic environment:</p>
  234. <ul class="simple">
  235. <li><p>Turn left</p></li>
  236. <li><p>Turn right</p></li>
  237. <li><p>Move forward</p></li>
  238. <li><p>Pick up an object</p></li>
  239. <li><p>Drop the object being carried</p></li>
  240. <li><p>Toggle (open doors, interact with objects)</p></li>
  241. <li><p>Done (task completed, optional)</p></li>
  242. </ul>
  243. <p>Default tile/observation encoding:</p>
  244. <ul class="simple">
  245. <li><p>Each tile is encoded as a 3 dimensional tuple: <code class="docutils literal notranslate"><span class="pre">(OBJECT_IDX,</span> <span class="pre">COLOR_IDX,</span> <span class="pre">STATE)</span></code></p></li>
  246. <li><p><code class="docutils literal notranslate"><span class="pre">OBJECT_TO_IDX</span></code> and <code class="docutils literal notranslate"><span class="pre">COLOR_TO_IDX</span></code> mapping can be found in <span class="xref myst">minigrid/minigrid.py</span></p></li>
  247. <li><p><code class="docutils literal notranslate"><span class="pre">STATE</span></code> refers to the door state with 0=open, 1=closed and 2=locked</p></li>
  248. </ul>
  249. <p>By default, sparse rewards are given for reaching a green goal tile. A
  250. reward of 1 is given for success, and zero for failure. There is also an
  251. environment-specific time step limit for completing the task.
  252. You can define your own reward function by creating a class derived
  253. from <code class="docutils literal notranslate"><span class="pre">MiniGridEnv</span></code>. Extending the environment with new object types or new actions
  254. should be very easy. If you wish to do this, you should take a look at the
  255. <span class="xref myst">minigrid/minigrid.py</span> source file.</p>
  256. </section>
  257. </article>
  258. </div>
  259. <footer>
  260. <div class="related-pages">
  261. <a class="next-page" href="../">
  262. <div class="page-info">
  263. <div class="context">
  264. <span>Next</span>
  265. </div>
  266. <div class="title">Included environments</div>
  267. </div>
  268. <svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
  269. </a>
  270. </div>
  271. <div class="bottom-of-page">
  272. <div class="left-details">
  273. <div class="copyright">
  274. Copyright &#169; 2022
  275. </div>
  276. Made with <a href="https://www.sphinx-doc.org/">Sphinx</a> and <a class="muted-link" href="https://pradyunsg.me">@pradyunsg</a>'s
  277. <a href="https://github.com/pradyunsg/furo">Furo</a>
  278. </div>
  279. <div class="right-details">
  280. <div class="icons">
  281. </div>
  282. </div>
  283. </div>
  284. </footer>
  285. </div>
  286. <aside class="toc-drawer no-toc">
  287. </aside>
  288. </div>
  289. </div><script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
  290. <script src="../../_static/jquery.js"></script>
  291. <script src="../../_static/underscore.js"></script>
  292. <script src="../../_static/doctools.js"></script>
  293. <script src="../../_static/scripts/furo.js"></script>
  294. <script>
  295. (() => {
  296. if (!localStorage.getItem("shownCookieAlert")) {
  297. const boxElem = document.createElement("div");
  298. boxElem.classList.add("cookie_alert");
  299. const containerElem = document.createElement("div");
  300. containerElem.classList.add("cookie_container");
  301. const textElem = document.createElement("p");
  302. textElem.innerHTML = `This page uses <a href="https://analytics.google.com/">
  303. Google Analytics</a> to collect statistics. You can disable it by blocking
  304. the JavaScript coming from www.google-analytics.com.`;
  305. containerElem.appendChild(textElem);
  306. const closeBtn = document.createElement("button");
  307. closeBtn.innerHTML = `<?xml version="1.0" ?><svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><defs><style>.cls-1{fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:2px;}</style></defs><title/><g id="cross"><line class="cls-1" x1="7" x2="25" y1="7" y2="25"/><line class="cls-1" x1="7" x2="25" y1="25" y2="7"/></g></svg>`
  308. closeBtn.onclick = () => {
  309. localStorage.setItem("shownCookieAlert", "true");
  310. boxElem.style.display = "none";
  311. }
  312. containerElem.appendChild(closeBtn);
  313. boxElem.appendChild(containerElem);
  314. document.body.appendChild(boxElem);
  315. }
  316. })()
  317. </script>
  318. <!-- Google tag (gtag.js) -->
  319. <script async src="https://www.googletagmanager.com/gtag/js?id=G-JGXSLW7N06"></script>
  320. <script>
  321. window.dataLayer = window.dataLayer || [];
  322. function gtag(){dataLayer.push(arguments);}
  323. gtag('js', new Date());
  324. gtag('config', 'G-JGXSLW7N06');
  325. </script></body>
  326. </html>