mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-18 21:06:59 +00:00
1060 lines
94 KiB
HTML
1060 lines
94 KiB
HTML
<!doctype html>
|
||
<html class="no-js" lang="en">
|
||
<head><meta charset="utf-8"/>
|
||
<meta name="viewport" content="width=device-width,initial-scale=1"/>
|
||
<meta name="color-scheme" content="light dark">
|
||
<meta name="description" content="A standard API for reinforcement learning and a diverse set of reference environments (formerly Gym)">
|
||
<meta property="og:title" content="Gymnasium Documentation" />
|
||
<meta property="og:type" content="website" />
|
||
<meta property="og:description" content="A standard API for reinforcement learning and a diverse set of reference environments (formerly Gym)" />
|
||
<meta property="og:url" content="https://gymnasium.farama.org/api/spaces/composite.html" /><meta property="og:image" content="https://gymnasium.farama.org/_static/img/gymnasium-github.png" /><meta name="twitter:card" content="summary_large_image"><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
|
||
<link rel="index" title="Index" href="../../../genindex/" /><link rel="search" title="Search" href="../../../search/" /><link rel="next" title="Spaces Utils" href="../utils/" /><link rel="prev" title="Fundamental Spaces" href="../fundamental/" />
|
||
<link rel="canonical" href="https://gymnasium.farama.org/api/spaces/composite.html" />
|
||
|
||
<link rel="shortcut icon" href="../../../_static/favicon.png"/><!-- Generated with Sphinx 6.1.3 and Furo 2022.12.07.dev1 -->
|
||
<title>Composite Spaces - Gymnasium Documentation</title>
|
||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||
<link rel="stylesheet" type="text/css" href="../../../_static/styles/furo.css?digest=721f65a87c37740baa8d605b09db5bec3a2987a8" />
|
||
<link rel="stylesheet" type="text/css" href="../../../_static/sg_gallery.css" />
|
||
<link rel="stylesheet" type="text/css" href="../../../_static/sg_gallery-binder.css" />
|
||
<link rel="stylesheet" type="text/css" href="../../../_static/sg_gallery-dataframe.css" />
|
||
<link rel="stylesheet" type="text/css" href="../../../_static/sg_gallery-rendered-html.css" />
|
||
<link rel="stylesheet" type="text/css" href="../../../_static/styles/furo-extensions.css?digest=b0c92cd440df7c18a0306b0433406327ff2c572f" />
|
||
|
||
|
||
|
||
|
||
<style>
|
||
body {
|
||
--color-code-background: #f8f8f8;
|
||
--color-code-foreground: black;
|
||
|
||
}
|
||
@media not print {
|
||
body[data-theme="dark"] {
|
||
--color-code-background: #202020;
|
||
--color-code-foreground: #d0d0d0;
|
||
|
||
}
|
||
@media (prefers-color-scheme: dark) {
|
||
body:not([data-theme="light"]) {
|
||
--color-code-background: #202020;
|
||
--color-code-foreground: #d0d0d0;
|
||
|
||
}
|
||
}
|
||
}
|
||
</style></head>
|
||
<body>
|
||
<header class="farama-header" aria-label="Farama header">
|
||
<div class="farama-header__container">
|
||
<div class="farama-header__left--mobile">
|
||
<label class="nav-overlay-icon" for="__navigation">
|
||
<div class="visually-hidden">Toggle site navigation sidebar</div>
|
||
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||
<defs></defs>
|
||
<line x1="0.5" y1="4" x2="23.5" y2="4"></line>
|
||
<line x1="0.232" y1="12" x2="23.5" y2="12"></line>
|
||
<line x1="0.232" y1="20" x2="23.5" y2="20"></line>
|
||
</svg>
|
||
<!-- <svg viewBox="0 0 24 24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||
<line x1="0.5" y1="4.5" x2="23.5" y2="4.5" style="fill: none; "></line>
|
||
<line x1="0.5" y1="12" x2="14" y2="12" ></line>
|
||
<line x1="0.5" y1="19.5" x2="23.5" y2="19.5"></line>
|
||
<polyline style="stroke-width: 0px;" points="17 7 22 12 17 17"></polyline>
|
||
</svg> -->
|
||
<!-- <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" style="width:20px">
|
||
<defs></defs>
|
||
<rect y="1" width="22" height="22" rx="2" ry="2" style="fill: none;" x="1"></rect>
|
||
<line x1="8" y1="1" x2="8" y2="23"></line>
|
||
<polyline style="stroke-linecap: round; fill: none; stroke-linejoin: round;" points="13 7 17 12 13 17"></polyline>
|
||
</svg> -->
|
||
</label>
|
||
</div>
|
||
<div class="farama-header__left farama-header__center--mobile">
|
||
<a href="../../../">
|
||
<img class="farama-header__logo only-light" src="../../../_static/img/gymnasium_black.svg" alt="Light Logo"/>
|
||
<img class="farama-header__logo only-dark" src="../../../_static/img/gymnasium_white.svg" alt="Dark Logo"/>
|
||
<span class="farama-header__title">Gymnasium Documentation</span>
|
||
</a>
|
||
</div>
|
||
<div class="farama-header__right">
|
||
<div class="farama-header-menu">
|
||
<button class="farama-header-menu__btn" aria-label="Open Farama Menu" aria-expanded="false" aria-haspopup="true" aria-controls="farama-menu">
|
||
<img class="farama-black-logo-invert" src="../../../_static/img/farama-logo-header.svg">
|
||
<svg viewBox="0 0 24 24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||
<polyline style="stroke-linecap: round; stroke-linejoin: round; fill: none; stroke-width: 2px;" points="1 7 12 18 23 7"></polyline>
|
||
</svg>
|
||
</button>
|
||
<div class="farama-header-menu-container farama-hidden" aria-hidden="true" id="farama-menu">
|
||
<div class="farama-header-menu__header">
|
||
<a href="https://farama.org">
|
||
<img class="farama-header-menu__logo farama-white-logo-invert" src="../../../_static/img/farama_solid_white.svg" alt="Farama Foundation logo">
|
||
<span>Farama Foundation</span>
|
||
</a>
|
||
<div class="farama-header-menu-header__right">
|
||
<button id="farama-close-menu">
|
||
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor"
|
||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon-close">
|
||
<line x1="3" y1="21" x2="21" y2="3"></line>
|
||
<line x1="3" y1="3" x2="21" y2="21"></line>
|
||
</svg>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
<div class="farama-header-menu__body">
|
||
<!-- Response from farama.org/api/projects.json -->
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</header>
|
||
|
||
|
||
<script>
|
||
document.body.dataset.theme = localStorage.getItem("theme") || "auto";
|
||
</script>
|
||
|
||
|
||
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
|
||
<symbol id="svg-toc" viewBox="0 0 24 24">
|
||
<title>Contents</title>
|
||
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024">
|
||
<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"/>
|
||
</svg>
|
||
</symbol>
|
||
<symbol id="svg-menu" viewBox="0 0 24 24">
|
||
<title>Menu</title>
|
||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-menu">
|
||
<line x1="3" y1="12" x2="21" y2="12"></line>
|
||
<line x1="3" y1="6" x2="21" y2="6"></line>
|
||
<line x1="3" y1="18" x2="21" y2="18"></line>
|
||
</svg>
|
||
</symbol>
|
||
<symbol id="svg-arrow-right" viewBox="0 0 24 24">
|
||
<title>Expand</title>
|
||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-chevron-right">
|
||
<polyline points="9 18 15 12 9 6"></polyline>
|
||
</svg>
|
||
</symbol>
|
||
<symbol id="svg-sun" viewBox="0 0 24 24">
|
||
<title>Light mode</title>
|
||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather-sun">
|
||
<circle cx="12" cy="12" r="5"></circle>
|
||
<line x1="12" y1="1" x2="12" y2="3"></line>
|
||
<line x1="12" y1="21" x2="12" y2="23"></line>
|
||
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
|
||
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
|
||
<line x1="1" y1="12" x2="3" y2="12"></line>
|
||
<line x1="21" y1="12" x2="23" y2="12"></line>
|
||
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
|
||
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
|
||
</svg>
|
||
</symbol>
|
||
<symbol id="svg-moon" viewBox="0 0 24 24">
|
||
<title>Dark mode</title>
|
||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-moon">
|
||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||
<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" />
|
||
</svg>
|
||
</symbol>
|
||
<symbol id="svg-sun-half" viewBox="0 0 24 24">
|
||
<title>Auto light/dark mode</title>
|
||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-shadow">
|
||
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
|
||
<circle cx="12" cy="12" r="9" />
|
||
<path d="M13 12h5" />
|
||
<path d="M13 15h4" />
|
||
<path d="M13 18h1" />
|
||
<path d="M13 9h4" />
|
||
<path d="M13 6h1" />
|
||
</svg>
|
||
</symbol>
|
||
</svg>
|
||
|
||
<input type="checkbox" class="sidebar-toggle" name="__navigation" id="__navigation">
|
||
<input type="checkbox" class="sidebar-toggle" name="__toc" id="__toc">
|
||
<label class="overlay sidebar-overlay" for="__navigation">
|
||
<div class="visually-hidden">Hide navigation sidebar</div>
|
||
</label>
|
||
<label class="overlay toc-overlay" for="__toc">
|
||
<div class="visually-hidden">Hide table of contents sidebar</div>
|
||
</label>
|
||
|
||
<div class="page">
|
||
<!--<header class="mobile-header">
|
||
<div class="header-left">
|
||
<label class="nav-overlay-icon" for="__navigation">
|
||
<div class="visually-hidden">Toggle site navigation sidebar</div>
|
||
<i class="icon"><svg><use href="#svg-menu"></use></svg></i>
|
||
</label>
|
||
</div>
|
||
<div class="header-center">
|
||
<a href="../../../"><div class="brand">Gymnasium Documentation</div></a>
|
||
</div>
|
||
<div class="header-right">
|
||
<div class="theme-toggle-container theme-toggle-header">
|
||
<button class="theme-toggle">
|
||
<div class="visually-hidden">Toggle Light / Dark / Auto color theme</div>
|
||
<svg class="theme-icon-when-auto"><use href="#svg-sun-half"></use></svg>
|
||
<svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
|
||
<svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
|
||
</button>
|
||
</div>
|
||
<label class="toc-overlay-icon toc-header-icon" for="__toc">
|
||
<div class="visually-hidden">Toggle table of contents sidebar</div>
|
||
<i class="icon"><svg><use href="#svg-toc"></use></svg></i>
|
||
</label>
|
||
</div>
|
||
</header>-->
|
||
<aside class="sidebar-drawer">
|
||
<div class="sidebar-container">
|
||
|
||
<div class="sidebar-sticky"><a class="farama-sidebar__title" href="../../../">
|
||
<img class="farama-header__logo only-light" src="../../../_static/img/gymnasium_black.svg" alt="Light Logo"/>
|
||
<img class="farama-header__logo only-dark" src="../../../_static/img/gymnasium_white.svg" alt="Dark Logo"/>
|
||
<span class="farama-header__title">Gymnasium Documentation</span>
|
||
</a><form class="sidebar-search-container" method="get" action="../../../search/" role="search">
|
||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||
<input type="hidden" name="check_keywords" value="yes">
|
||
<input type="hidden" name="area" value="default">
|
||
</form>
|
||
<div id="searchbox"></div><div class="sidebar-scroll"><div class="sidebar-tree">
|
||
<p class="caption" role="heading"><span class="caption-text">Introduction</span></p>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../../content/basic_usage/">Basic Usage</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../../content/gym_compatibility/">Compatibility with Gym</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../../content/migration-guide/">v21 to v26 Migration Guide</a></li>
|
||
</ul>
|
||
<p class="caption" role="heading"><span class="caption-text">API</span></p>
|
||
<ul class="current">
|
||
<li class="toctree-l1"><a class="reference internal" href="../../env/">Env</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../registry/">Register and Make</a></li>
|
||
<li class="toctree-l1 current has-children"><a class="reference internal" href="../">Spaces</a><input checked="" 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 class="current">
|
||
<li class="toctree-l2"><a class="reference internal" href="../fundamental/">Fundamental Spaces</a></li>
|
||
<li class="toctree-l2 current current-page"><a class="current reference internal" href="#">Composite Spaces</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../utils/">Spaces Utils</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../vector_utils/">Spaces Vector Utils</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l1 has-children"><a class="reference internal" href="../../wrappers/">Wrappers</a><input class="toctree-checkbox" id="toctree-checkbox-2" name="toctree-checkbox-2" role="switch" type="checkbox"/><label for="toctree-checkbox-2"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../wrappers/misc_wrappers/">Misc Wrappers</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../wrappers/action_wrappers/">Action Wrappers</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../wrappers/observation_wrappers/">Observation Wrappers</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../wrappers/reward_wrappers/">Reward Wrappers</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../vector/">Vector</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../utils/">Utils</a></li>
|
||
<li class="toctree-l1 has-children"><a class="reference internal" href="../../experimental/">Experimental</a><input class="toctree-checkbox" id="toctree-checkbox-3" name="toctree-checkbox-3" role="switch" type="checkbox"/><label for="toctree-checkbox-3"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../experimental/functional/">Functional Environment</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../experimental/wrappers/">Wrappers</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../experimental/vector/">Vectorizing Environment</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../experimental/vector_wrappers/">Vector Environment Wrappers</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../experimental/vector_utils/">Utility functions for vectorisation</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<p class="caption" role="heading"><span class="caption-text">Environments</span></p>
|
||
<ul>
|
||
<li class="toctree-l1 has-children"><a class="reference internal" href="../../../environments/classic_control/">Classic Control</a><input class="toctree-checkbox" id="toctree-checkbox-4" name="toctree-checkbox-4" role="switch" type="checkbox"/><label for="toctree-checkbox-4"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/classic_control/acrobot/">Acrobot</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/classic_control/cart_pole/">Cart Pole</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/classic_control/mountain_car_continuous/">Mountain Car Continuous</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/classic_control/mountain_car/">Mountain Car</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/classic_control/pendulum/">Pendulum</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l1 has-children"><a class="reference internal" href="../../../environments/box2d/">Box2D</a><input class="toctree-checkbox" id="toctree-checkbox-5" name="toctree-checkbox-5" role="switch" type="checkbox"/><label for="toctree-checkbox-5"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/box2d/bipedal_walker/">Bipedal Walker</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/box2d/car_racing/">Car Racing</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/box2d/lunar_lander/">Lunar Lander</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l1 has-children"><a class="reference internal" href="../../../environments/toy_text/">Toy Text</a><input class="toctree-checkbox" id="toctree-checkbox-6" name="toctree-checkbox-6" role="switch" type="checkbox"/><label for="toctree-checkbox-6"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/toy_text/blackjack/">Blackjack</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/toy_text/taxi/">Taxi</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/toy_text/cliff_walking/">Cliff Walking</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/toy_text/frozen_lake/">Frozen Lake</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l1 has-children"><a class="reference internal" href="../../../environments/mujoco/">MuJoCo</a><input class="toctree-checkbox" id="toctree-checkbox-7" name="toctree-checkbox-7" role="switch" type="checkbox"/><label for="toctree-checkbox-7"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/mujoco/ant/">Ant</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/mujoco/half_cheetah/">Half Cheetah</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/mujoco/hopper/">Hopper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/mujoco/humanoid_standup/">Humanoid Standup</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/mujoco/humanoid/">Humanoid</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/mujoco/inverted_double_pendulum/">Inverted Double Pendulum</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/mujoco/inverted_pendulum/">Inverted Pendulum</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/mujoco/reacher/">Reacher</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/mujoco/swimmer/">Swimmer</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/mujoco/pusher/">Pusher</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/mujoco/walker2d/">Walker2D</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l1 has-children"><a class="reference internal" href="../../../environments/atari/">Atari</a><input class="toctree-checkbox" id="toctree-checkbox-8" name="toctree-checkbox-8" role="switch" type="checkbox"/><label for="toctree-checkbox-8"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/adventure/">Adventure</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/air_raid/">AirRaid</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/alien/">Alien</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/amidar/">Amidar</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/assault/">Assault</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/asterix/">Asterix</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/asteroids/">Asteroids</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/atlantis/">Atlantis</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/atlantis2/">Atlantis2</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/backgammon/">Backgammon</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/bank_heist/">BankHeist</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/basic_math/">BasicMath</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/battle_zone/">BattleZone</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/beam_rider/">BeamRider</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/berzerk/">Berzerk</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/blackjack/">Blackjack</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/bowling/">Bowling</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/boxing/">Boxing</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/breakout/">Breakout</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/carnival/">Carnival</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/casino/">Casino</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/centipede/">Centipede</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/chopper_command/">ChopperCommand</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/crazy_climber/">CrazyClimber</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/crossbow/">Crossbow</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/darkchambers/">Darkchambers</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/defender/">Defender</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/demon_attack/">DemonAttack</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/donkey_kong/">DonkeyKong</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/double_dunk/">DoubleDunk</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/earthworld/">Earthworld</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/elevator_action/">ElevatorAction</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/enduro/">Enduro</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/entombed/">Entombed</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/et/">Et</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/fishing_derby/">FishingDerby</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/flag_capture/">FlagCapture</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/freeway/">Freeway</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/frogger/">Frogger</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/frostbite/">Frostbite</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/galaxian/">Galaxian</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/gopher/">Gopher</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/gravitar/">Gravitar</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/hangman/">Hangman</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/haunted_house/">HauntedHouse</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/hero/">Hero</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/human_cannonball/">HumanCannonball</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/ice_hockey/">IceHockey</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/jamesbond/">Jamesbond</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/journey_escape/">JourneyEscape</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/kaboom/">Kaboom</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/kangaroo/">Kangaroo</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/keystone_kapers/">KeystoneKapers</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/king_kong/">KingKong</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/klax/">Klax</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/koolaid/">Koolaid</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/krull/">Krull</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/kung_fu_master/">KungFuMaster</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/laser_gates/">LaserGates</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/lost_luggage/">LostLuggage</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/mario_bros/">MarioBros</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/miniature_golf/">MiniatureGolf</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/montezuma_revenge/">MontezumaRevenge</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/mr_do/">MrDo</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/ms_pacman/">MsPacman</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/name_this_game/">NameThisGame</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/othello/">Othello</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/pacman/">Pacman</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/phoenix/">Phoenix</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/pitfall/">Pitfall</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/pitfall2/">Pitfall2</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/pong/">Pong</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/pooyan/">Pooyan</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/private_eye/">PrivateEye</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/qbert/">Qbert</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/riverraid/">Riverraid</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/road_runner/">RoadRunner</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/robotank/">Robotank</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/seaquest/">Seaquest</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/sir_lancelot/">SirLancelot</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/skiing/">Skiing</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/solaris/">Solaris</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/space_invaders/">SpaceInvaders</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/space_war/">SpaceWar</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/star_gunner/">StarGunner</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/superman/">Superman</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/surround/">Surround</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/tennis/">Tennis</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/tetris/">Tetris</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/tic_tac_toe_3d/">TicTacToe3D</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/time_pilot/">TimePilot</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/trondead/">Trondead</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/turmoil/">Turmoil</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/tutankham/">Tutankham</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/up_n_down/">UpNDown</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/venture/">Venture</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/video_checkers/">VideoCheckers</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/video_chess/">VideoChess</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/video_cube/">VideoCube</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/video_pinball/">VideoPinball</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/wizard_of_wor/">WizardOfWor</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/word_zapper/">WordZapper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/yars_revenge/">YarsRevenge</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../environments/atari/zaxxon/">Zaxxon</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../../environments/third_party_environments/">Third-Party Environments</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../../environments/third_party_environments/#third-party-environments-using-gym">Third-Party Environments using Gym</a></li>
|
||
</ul>
|
||
<p class="caption" role="heading"><span class="caption-text">Tutorials</span></p>
|
||
<ul>
|
||
<li class="toctree-l1 has-children"><a class="reference internal" href="../../../tutorials/gymnasium_basics/">Gymnasium Basics</a><input class="toctree-checkbox" id="toctree-checkbox-9" name="toctree-checkbox-9" role="switch" type="checkbox"/><label for="toctree-checkbox-9"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../tutorials/gymnasium_basics/handling_time_limits/">Handling Time Limits</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../tutorials/gymnasium_basics/implementing_custom_wrappers/">Implementing Custom Wrappers</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../tutorials/gymnasium_basics/environment_creation/">Make your own custom environment</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../tutorials/gymnasium_basics/vector_envs_tutorial/">Training A2C with Vector Envs and Domain Randomization</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l1 has-children"><a class="reference internal" href="../../../tutorials/training_agents/">Training Agents</a><input class="toctree-checkbox" id="toctree-checkbox-10" name="toctree-checkbox-10" role="switch" type="checkbox"/><label for="toctree-checkbox-10"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../tutorials/training_agents/reinforce_invpend_gym_v26/">Training using REINFORCE for Mujoco</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../tutorials/training_agents/blackjack_tutorial/">Solving Blackjack with Q-Learning</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../../tutorials/training_agents/FrozenLake_tuto/">Frozenlake benchmark</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l1"><a class="reference external" href="https://www.comet.com/docs/v2/integrations/ml-frameworks/gymnasium/?utm_source=gymnasium&utm_medium=partner&utm_campaign=partner_gymnasium_2023&utm_content=docs_gymnasium">Comet Tutorial</a></li>
|
||
</ul>
|
||
<p class="caption" role="heading"><span class="caption-text">Development</span></p>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference external" href="https://github.com/Farama-Foundation/Gymnasium">Github</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../../gymnasium_release_notes/">Gymnasium Release Notes</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../../gym_release_notes/">Gym Release Notes</a></li>
|
||
<li class="toctree-l1"><a class="reference external" href="https://github.com/Farama-Foundation/Gymnasium/blob/main/docs/README.md">Contribute to the Docs</a></li>
|
||
</ul>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
</aside>
|
||
<div class="main-container">
|
||
|
||
|
||
|
||
|
||
|
||
<div class="main">
|
||
<div class="content">
|
||
<div class="article-container">
|
||
<a href="#" class="back-to-top muted-link">
|
||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||
<path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12z"></path>
|
||
</svg>
|
||
<span>Back to top</span>
|
||
</a>
|
||
<div class="content-icon-container">
|
||
<div class="theme-toggle-container theme-toggle-content">
|
||
<button class="theme-toggle" title="Toggle color theme">
|
||
<div class="visually-hidden">Toggle Light / Dark / Auto color theme</div>
|
||
<svg class="theme-icon-when-auto">
|
||
<use href="#svg-sun-half"></use>
|
||
</svg>
|
||
<svg class="theme-icon-when-dark">
|
||
<use href="#svg-moon"></use>
|
||
</svg>
|
||
<svg class="theme-icon-when-light">
|
||
<use href="#svg-sun"></use>
|
||
</svg>
|
||
</button>
|
||
</div>
|
||
<label class="toc-overlay-icon toc-content-icon" for="__toc">
|
||
<div class="visually-hidden">Toggle table of contents sidebar</div>
|
||
<i class="icon"><svg>
|
||
<use href="#svg-toc"></use>
|
||
</svg></i>
|
||
</label>
|
||
</div>
|
||
<article role="main">
|
||
|
||
<section id="composite-spaces">
|
||
<h1>Composite Spaces<a class="headerlink" href="#composite-spaces" title="Permalink to this heading">#</a></h1>
|
||
<section id="dict">
|
||
<h2>Dict<a class="headerlink" href="#dict" title="Permalink to this heading">#</a></h2>
|
||
<dl class="py class">
|
||
<dt class="sig sig-object py" id="gymnasium.spaces.Dict">
|
||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">gymnasium.spaces.</span></span><span class="sig-name descname"><span class="pre">Dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">spaces</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">None</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="../#gymnasium.spaces.Space" title="gymnasium.spaces.Space"><span class="pre">Space</span></a><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference internal" href="#gymnasium.spaces.Sequence" title="gymnasium.spaces.Sequence"><span class="pre">Sequence</span></a><span class="p"><span class="pre">[</span></span><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="../#gymnasium.spaces.Space" title="gymnasium.spaces.Space"><span class="pre">Space</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">dict</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">np.random.Generator</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">spaces_kwargs</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="../#gymnasium.spaces.Space" title="gymnasium.spaces.Space"><span class="pre">Space</span></a></span></em><span class="sig-paren">)</span><a class="headerlink" href="#gymnasium.spaces.Dict" title="Permalink to this definition">#</a></dt>
|
||
<dd><p>A dictionary of <a class="reference internal" href="../#gymnasium.spaces.Space" title="gymnasium.spaces.Space"><code class="xref py py-class docutils literal notranslate"><span class="pre">Space</span></code></a> instances.</p>
|
||
<p>Elements of this space are (ordered) dictionaries of elements from the constituent spaces.</p>
|
||
<p class="rubric">Example</p>
|
||
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">gymnasium.spaces</span> <span class="kn">import</span> <span class="n">Dict</span><span class="p">,</span> <span class="n">Box</span><span class="p">,</span> <span class="n">Discrete</span>
|
||
<span class="gp">>>> </span><span class="n">observation_space</span> <span class="o">=</span> <span class="n">Dict</span><span class="p">({</span><span class="s2">"position"</span><span class="p">:</span> <span class="n">Box</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,)),</span> <span class="s2">"color"</span><span class="p">:</span> <span class="n">Discrete</span><span class="p">(</span><span class="mi">3</span><span class="p">)},</span> <span class="n">seed</span><span class="o">=</span><span class="mi">42</span><span class="p">)</span>
|
||
<span class="gp">>>> </span><span class="n">observation_space</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>
|
||
<span class="go">OrderedDict([('color', 0), ('position', array([-0.3991573 , 0.21649833], dtype=float32))])</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>With a nested dict:</p>
|
||
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">gymnasium.spaces</span> <span class="kn">import</span> <span class="n">Box</span><span class="p">,</span> <span class="n">Dict</span><span class="p">,</span> <span class="n">Discrete</span><span class="p">,</span> <span class="n">MultiBinary</span><span class="p">,</span> <span class="n">MultiDiscrete</span>
|
||
<span class="gp">>>> </span><span class="n">Dict</span><span class="p">(</span>
|
||
<span class="gp">... </span> <span class="p">{</span>
|
||
<span class="gp">... </span> <span class="s2">"ext_controller"</span><span class="p">:</span> <span class="n">MultiDiscrete</span><span class="p">([</span><span class="mi">5</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">]),</span>
|
||
<span class="gp">... </span> <span class="s2">"inner_state"</span><span class="p">:</span> <span class="n">Dict</span><span class="p">(</span>
|
||
<span class="gp">... </span> <span class="p">{</span>
|
||
<span class="gp">... </span> <span class="s2">"charge"</span><span class="p">:</span> <span class="n">Discrete</span><span class="p">(</span><span class="mi">100</span><span class="p">),</span>
|
||
<span class="gp">... </span> <span class="s2">"system_checks"</span><span class="p">:</span> <span class="n">MultiBinary</span><span class="p">(</span><span class="mi">10</span><span class="p">),</span>
|
||
<span class="gp">... </span> <span class="s2">"job_status"</span><span class="p">:</span> <span class="n">Dict</span><span class="p">(</span>
|
||
<span class="gp">... </span> <span class="p">{</span>
|
||
<span class="gp">... </span> <span class="s2">"task"</span><span class="p">:</span> <span class="n">Discrete</span><span class="p">(</span><span class="mi">5</span><span class="p">),</span>
|
||
<span class="gp">... </span> <span class="s2">"progress"</span><span class="p">:</span> <span class="n">Box</span><span class="p">(</span><span class="n">low</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">high</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="p">()),</span>
|
||
<span class="gp">... </span> <span class="p">}</span>
|
||
<span class="gp">... </span> <span class="p">),</span>
|
||
<span class="gp">... </span> <span class="p">}</span>
|
||
<span class="gp">... </span> <span class="p">),</span>
|
||
<span class="gp">... </span> <span class="p">}</span>
|
||
<span class="gp">... </span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>It can be convenient to use <a class="reference internal" href="#gymnasium.spaces.Dict" title="gymnasium.spaces.Dict"><code class="xref py py-class docutils literal notranslate"><span class="pre">Dict</span></code></a> spaces if you want to make complex observations or actions more human-readable.
|
||
Usually, it will not be possible to use elements of this space directly in learning code. However, you can easily
|
||
convert <cite>Dict</cite> observations to flat arrays by using a <a class="reference internal" href="../../wrappers/observation_wrappers/#gymnasium.wrappers.FlattenObservation" title="gymnasium.wrappers.FlattenObservation"><code class="xref py py-class docutils literal notranslate"><span class="pre">gymnasium.wrappers.FlattenObservation</span></code></a> wrapper.
|
||
Similar wrappers can be implemented to deal with <a class="reference internal" href="#gymnasium.spaces.Dict" title="gymnasium.spaces.Dict"><code class="xref py py-class docutils literal notranslate"><span class="pre">Dict</span></code></a> actions.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>spaces</strong> – A dictionary of spaces. This specifies the structure of the <a class="reference internal" href="#gymnasium.spaces.Dict" title="gymnasium.spaces.Dict"><code class="xref py py-class docutils literal notranslate"><span class="pre">Dict</span></code></a> space</p></li>
|
||
<li><p><strong>seed</strong> – Optionally, you can use this argument to seed the RNGs of the spaces that make up the <a class="reference internal" href="#gymnasium.spaces.Dict" title="gymnasium.spaces.Dict"><code class="xref py py-class docutils literal notranslate"><span class="pre">Dict</span></code></a> space.</p></li>
|
||
<li><p><strong>**spaces_kwargs</strong> – If <code class="docutils literal notranslate"><span class="pre">spaces</span></code> is <code class="docutils literal notranslate"><span class="pre">None</span></code>, you need to pass the constituent spaces as keyword arguments, as described above.</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="gymnasium.spaces.Dict.sample">
|
||
<span class="sig-prename descclassname"><span class="pre">Dict.</span></span><span class="sig-name descname"><span class="pre">sample</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mask</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#gymnasium.spaces.Dict.sample" title="Permalink to this definition">#</a></dt>
|
||
<dd><p>Generates a single random sample from this space.</p>
|
||
<p>The sample is an ordered dictionary of independent samples from the constituent spaces.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>mask</strong> – An optional mask for each of the subspaces, expects the same keys as the space</p>
|
||
</dd>
|
||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||
<dd class="field-even"><p><strong>A dictionary with the same key and sampled values from :attr:`self.spaces`</strong></p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="gymnasium.spaces.Dict.seed">
|
||
<span class="sig-prename descclassname"><span class="pre">Dict.</span></span><span class="sig-name descname"><span class="pre">seed</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#gymnasium.spaces.Dict.seed" title="Permalink to this definition">#</a></dt>
|
||
<dd><p>Seed the PRNG of this space and all subspaces.</p>
|
||
<p>Depending on the type of seed, the subspaces will be seeded differently</p>
|
||
<ul class="simple">
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">None</span></code> - All the subspaces will use a random initial seed</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">Int</span></code> - The integer is used to seed the <a class="reference internal" href="#gymnasium.spaces.Dict" title="gymnasium.spaces.Dict"><code class="xref py py-class docutils literal notranslate"><span class="pre">Dict</span></code></a> space that is used to generate seed values for each of the subspaces. Warning, this does not guarantee unique seeds for all of the subspaces.</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">Dict</span></code> - Using all the keys in the seed dictionary, the values are used to seed the subspaces. This allows the seeding of multiple composite subspaces (<code class="docutils literal notranslate"><span class="pre">Dict["space":</span> <span class="pre">Dict[...],</span> <span class="pre">...]</span></code> with <code class="docutils literal notranslate"><span class="pre">{"space":</span> <span class="pre">{...},</span> <span class="pre">...}</span></code>).</p></li>
|
||
</ul>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>seed</strong> – An optional list of ints or int to seed the (sub-)spaces.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
</section>
|
||
<section id="tuple">
|
||
<h2>Tuple<a class="headerlink" href="#tuple" title="Permalink to this heading">#</a></h2>
|
||
<dl class="py class">
|
||
<dt class="sig sig-object py" id="gymnasium.spaces.Tuple">
|
||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">gymnasium.spaces.</span></span><span class="sig-name descname"><span class="pre">Tuple</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">spaces</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Iterable</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="../#gymnasium.spaces.Space" title="gymnasium.spaces.Space"><span class="pre">Space</span></a><span class="p"><span class="pre">[</span></span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Sequence</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">np.random.Generator</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#gymnasium.spaces.Tuple" title="Permalink to this definition">#</a></dt>
|
||
<dd><p>A tuple (more precisely: the cartesian product) of <a class="reference internal" href="../#gymnasium.spaces.Space" title="gymnasium.spaces.Space"><code class="xref py py-class docutils literal notranslate"><span class="pre">Space</span></code></a> instances.</p>
|
||
<p>Elements of this space are tuples of elements of the constituent spaces.</p>
|
||
<p class="rubric">Example</p>
|
||
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">gymnasium.spaces</span> <span class="kn">import</span> <span class="n">Tuple</span><span class="p">,</span> <span class="n">Box</span><span class="p">,</span> <span class="n">Discrete</span>
|
||
<span class="gp">>>> </span><span class="n">observation_space</span> <span class="o">=</span> <span class="n">Tuple</span><span class="p">((</span><span class="n">Discrete</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">Box</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,))),</span> <span class="n">seed</span><span class="o">=</span><span class="mi">42</span><span class="p">)</span>
|
||
<span class="gp">>>> </span><span class="n">observation_space</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>
|
||
<span class="go">(0, array([-0.3991573 , 0.21649833], dtype=float32))</span>
|
||
</pre></div>
|
||
</div>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>spaces</strong> (<em>Iterable</em><em>[</em><a class="reference internal" href="../#gymnasium.spaces.Space" title="gymnasium.spaces.Space"><em>Space</em></a><em>]</em>) – The spaces that are involved in the cartesian product.</p></li>
|
||
<li><p><strong>seed</strong> – Optionally, you can use this argument to seed the RNGs of the <code class="docutils literal notranslate"><span class="pre">spaces</span></code> to ensure reproducible sampling.</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="gymnasium.spaces.Tuple.sample">
|
||
<span class="sig-prename descclassname"><span class="pre">Tuple.</span></span><span class="sig-name descname"><span class="pre">sample</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mask</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">Any</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="p"><span class="pre">...</span></span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="p"><span class="pre">...</span></span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#gymnasium.spaces.Tuple.sample" title="Permalink to this definition">#</a></dt>
|
||
<dd><p>Generates a single random sample inside this space.</p>
|
||
<p>This method draws independent samples from the subspaces.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>mask</strong> – An optional tuple of optional masks for each of the subspace’s samples,
|
||
expects the same number of masks as spaces</p>
|
||
</dd>
|
||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||
<dd class="field-even"><p><strong>Tuple of the subspace’s samples</strong></p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="gymnasium.spaces.Tuple.seed">
|
||
<span class="sig-prename descclassname"><span class="pre">Tuple.</span></span><span class="sig-name descname"><span class="pre">seed</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Sequence</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#gymnasium.spaces.Tuple.seed" title="Permalink to this definition">#</a></dt>
|
||
<dd><p>Seed the PRNG of this space and all subspaces.</p>
|
||
<p>Depending on the type of seed, the subspaces will be seeded differently</p>
|
||
<ul class="simple">
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">None</span></code> - All the subspaces will use a random initial seed</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">Int</span></code> - The integer is used to seed the <cite>Tuple</cite> space that is used to generate seed values for each of the subspaces. Warning, this does not guarantee unique seeds for all of the subspaces.</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">List</span></code> - Values used to seed the subspaces. This allows the seeding of multiple composite subspaces (<code class="docutils literal notranslate"><span class="pre">List(42,</span> <span class="pre">54,</span> <span class="pre">...</span></code>).</p></li>
|
||
</ul>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>seed</strong> – An optional list of ints or int to seed the (sub-)spaces.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
</section>
|
||
<section id="sequence">
|
||
<h2>Sequence<a class="headerlink" href="#sequence" title="Permalink to this heading">#</a></h2>
|
||
<dl class="py class">
|
||
<dt class="sig sig-object py" id="gymnasium.spaces.Sequence">
|
||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">gymnasium.spaces.</span></span><span class="sig-name descname"><span class="pre">Sequence</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">space</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="../#gymnasium.spaces.Space" title="gymnasium.spaces.Space"><span class="pre">Space</span></a><span class="p"><span class="pre">[</span></span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">np.random.Generator</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stack</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#gymnasium.spaces.Sequence" title="Permalink to this definition">#</a></dt>
|
||
<dd><p>This space represent sets of finite-length sequences.</p>
|
||
<p>This space represents the set of tuples of the form <span class="math notranslate nohighlight">\((a_0, \dots, a_n)\)</span> where the <span class="math notranslate nohighlight">\(a_i\)</span> belong
|
||
to some space that is specified during initialization and the integer <span class="math notranslate nohighlight">\(n\)</span> is not fixed</p>
|
||
<p class="rubric">Example</p>
|
||
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">gymnasium.spaces</span> <span class="kn">import</span> <span class="n">Sequence</span><span class="p">,</span> <span class="n">Box</span>
|
||
<span class="gp">>>> </span><span class="n">observation_space</span> <span class="o">=</span> <span class="n">Sequence</span><span class="p">(</span><span class="n">Box</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">seed</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
|
||
<span class="gp">>>> </span><span class="n">observation_space</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>
|
||
<span class="go">(array([0.26161215], dtype=float32),)</span>
|
||
<span class="gp">>>> </span><span class="n">observation_space</span> <span class="o">=</span> <span class="n">Sequence</span><span class="p">(</span><span class="n">Box</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">seed</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
|
||
<span class="gp">>>> </span><span class="n">observation_space</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>
|
||
<span class="go">(array([0.6369617], dtype=float32), array([0.26978672], dtype=float32), array([0.04097353], dtype=float32))</span>
|
||
</pre></div>
|
||
</div>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>space</strong> – Elements in the sequences this space represent must belong to this space.</p></li>
|
||
<li><p><strong>seed</strong> – Optionally, you can use this argument to seed the RNG that is used to sample from the space.</p></li>
|
||
<li><p><strong>stack</strong> – If <cite>True</cite> then the resulting samples would be stacked.</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="gymnasium.spaces.Sequence.sample">
|
||
<span class="sig-prename descclassname"><span class="pre">Sequence.</span></span><span class="sig-name descname"><span class="pre">sample</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mask</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">None</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">None</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">np.integer</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">NDArray</span><span class="p"><span class="pre">[</span></span><span class="pre">np.integer</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Any</span></span></span><a class="headerlink" href="#gymnasium.spaces.Sequence.sample" title="Permalink to this definition">#</a></dt>
|
||
<dd><p>Generates a single random sample from this space.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>mask</strong> – <p>An optional mask for (optionally) the length of the sequence and (optionally) the values in the sequence.
|
||
If you specify <cite>mask</cite>, it is expected to be a tuple of the form <cite>(length_mask, sample_mask)</cite> where <cite>length_mask</cite>
|
||
is</p>
|
||
<ul class="simple">
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">None</span></code> The length will be randomly drawn from a geometric distribution</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">np.ndarray</span></code> of integers, in which case the length of the sampled sequence is randomly drawn from this array.</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">int</span></code> for a fixed length sample</p></li>
|
||
</ul>
|
||
<p>The second element of the mask tuple <cite>sample</cite> mask specifies a mask that is applied when
|
||
sampling elements from the base space. The mask is applied for each feature space sample.</p>
|
||
</p>
|
||
</dd>
|
||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||
<dd class="field-even"><p><strong>A tuple of random length with random samples of elements from the :attr:`feature_space`.</strong></p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="gymnasium.spaces.Sequence.seed">
|
||
<span class="sig-prename descclassname"><span class="pre">Sequence.</span></span><span class="sig-name descname"><span class="pre">seed</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#gymnasium.spaces.Sequence.seed" title="Permalink to this definition">#</a></dt>
|
||
<dd><p>Seed the PRNG of this space and the feature space.</p>
|
||
</dd></dl>
|
||
|
||
</section>
|
||
<section id="graph">
|
||
<h2>Graph<a class="headerlink" href="#graph" title="Permalink to this heading">#</a></h2>
|
||
<dl class="py class">
|
||
<dt class="sig sig-object py" id="gymnasium.spaces.Graph">
|
||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">gymnasium.spaces.</span></span><span class="sig-name descname"><span class="pre">Graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">node_space</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="../fundamental/#gymnasium.spaces.Box" title="gymnasium.spaces.Box"><span class="pre">Box</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference internal" href="../fundamental/#gymnasium.spaces.Discrete" title="gymnasium.spaces.Discrete"><span class="pre">Discrete</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">edge_space</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">None</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference internal" href="../fundamental/#gymnasium.spaces.Box" title="gymnasium.spaces.Box"><span class="pre">Box</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference internal" href="../fundamental/#gymnasium.spaces.Discrete" title="gymnasium.spaces.Discrete"><span class="pre">Discrete</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">np.random.Generator</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#gymnasium.spaces.Graph" title="Permalink to this definition">#</a></dt>
|
||
<dd><p>A space representing graph information as a series of <cite>nodes</cite> connected with <cite>edges</cite> according to an adjacency matrix represented as a series of <cite>edge_links</cite>.</p>
|
||
<p class="rubric">Example</p>
|
||
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">gymnasium.spaces</span> <span class="kn">import</span> <span class="n">Graph</span><span class="p">,</span> <span class="n">Box</span><span class="p">,</span> <span class="n">Discrete</span>
|
||
<span class="gp">>>> </span><span class="n">observation_space</span> <span class="o">=</span> <span class="n">Graph</span><span class="p">(</span><span class="n">node_space</span><span class="o">=</span><span class="n">Box</span><span class="p">(</span><span class="n">low</span><span class="o">=-</span><span class="mi">100</span><span class="p">,</span> <span class="n">high</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="mi">3</span><span class="p">,)),</span> <span class="n">edge_space</span><span class="o">=</span><span class="n">Discrete</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">seed</span><span class="o">=</span><span class="mi">42</span><span class="p">)</span>
|
||
<span class="gp">>>> </span><span class="n">observation_space</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>
|
||
<span class="go">GraphInstance(nodes=array([[-12.224312 , 71.71958 , 39.473606 ],</span>
|
||
<span class="go"> [-81.16453 , 95.12447 , 52.22794 ],</span>
|
||
<span class="go"> [ 57.21286 , -74.37727 , -9.922812 ],</span>
|
||
<span class="go"> [-25.840395 , 85.353 , 28.773024 ],</span>
|
||
<span class="go"> [ 64.55232 , -11.317161 , -54.552258 ],</span>
|
||
<span class="go"> [ 10.916958 , -87.23655 , 65.52624 ],</span>
|
||
<span class="go"> [ 26.33288 , 51.61755 , -29.094807 ],</span>
|
||
<span class="go"> [ 94.1396 , 78.62422 , 55.6767 ],</span>
|
||
<span class="go"> [-61.072258 , -6.6557994, -91.23925 ],</span>
|
||
<span class="go"> [-69.142105 , 36.60979 , 48.95243 ]], dtype=float32), edges=array([2, 0, 1, 1, 0, 0, 1, 0]), edge_links=array([[7, 5],</span>
|
||
<span class="go"> [6, 9],</span>
|
||
<span class="go"> [4, 1],</span>
|
||
<span class="go"> [8, 6],</span>
|
||
<span class="go"> [7, 0],</span>
|
||
<span class="go"> [3, 7],</span>
|
||
<span class="go"> [8, 4],</span>
|
||
<span class="go"> [8, 8]]))</span>
|
||
</pre></div>
|
||
</div>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>node_space</strong> (<em>Union</em><em>[</em><a class="reference internal" href="../fundamental/#gymnasium.spaces.Box" title="gymnasium.spaces.Box"><em>Box</em></a><em>, </em><a class="reference internal" href="../fundamental/#gymnasium.spaces.Discrete" title="gymnasium.spaces.Discrete"><em>Discrete</em></a><em>]</em>) – space of the node features.</p></li>
|
||
<li><p><strong>edge_space</strong> (<em>Union</em><em>[</em><em>None</em><em>, </em><a class="reference internal" href="../fundamental/#gymnasium.spaces.Box" title="gymnasium.spaces.Box"><em>Box</em></a><em>, </em><a class="reference internal" href="../fundamental/#gymnasium.spaces.Discrete" title="gymnasium.spaces.Discrete"><em>Discrete</em></a><em>]</em>) – space of the node features.</p></li>
|
||
<li><p><strong>seed</strong> – Optionally, you can use this argument to seed the RNG that is used to sample from the space.</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="gymnasium.spaces.Graph.sample">
|
||
<span class="sig-prename descclassname"><span class="pre">Graph.</span></span><span class="sig-name descname"><span class="pre">sample</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mask</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">None</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">NDArray</span><span class="p"><span class="pre">[</span></span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="p"><span class="pre">...</span></span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">NDArray</span><span class="p"><span class="pre">[</span></span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="p"><span class="pre">...</span></span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_nodes</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_edges</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">GraphInstance</span></span></span><a class="headerlink" href="#gymnasium.spaces.Graph.sample" title="Permalink to this definition">#</a></dt>
|
||
<dd><p>Generates a single sample graph with num_nodes between 1 and 10 sampled from the Graph.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>mask</strong> – An optional tuple of optional node and edge mask that is only possible with Discrete spaces
|
||
(Box spaces don’t support sample masks).
|
||
If no <cite>num_edges</cite> is provided then the <cite>edge_mask</cite> is multiplied by the number of edges</p></li>
|
||
<li><p><strong>num_nodes</strong> – The number of nodes that will be sampled, the default is 10 nodes</p></li>
|
||
<li><p><strong>num_edges</strong> – An optional number of edges, otherwise, a random number between 0 and <cite>num_nodes</cite> ^ 2</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||
<dd class="field-even"><p><strong>A :class:`GraphInstance` with attributes `.nodes`, `.edges`, and `.edge_links`.</strong></p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="gymnasium.spaces.Graph.seed">
|
||
<span class="sig-prename descclassname"><span class="pre">Graph.</span></span><span class="sig-name descname"><span class="pre">seed</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#gymnasium.spaces.Graph.seed" title="Permalink to this definition">#</a></dt>
|
||
<dd><p>Seed the PRNG of this space and possibly the PRNGs of subspaces.</p>
|
||
</dd></dl>
|
||
|
||
</section>
|
||
</section>
|
||
|
||
</article>
|
||
</div>
|
||
<footer>
|
||
|
||
<div class="related-pages">
|
||
<a class="next-page" href="../utils/">
|
||
<div class="page-info">
|
||
<div class="context">
|
||
<span>Next</span>
|
||
</div>
|
||
<div class="title">Spaces Utils</div>
|
||
</div>
|
||
<svg class="furo-related-icon">
|
||
<use href="#svg-arrow-right"></use>
|
||
</svg>
|
||
</a>
|
||
<a class="prev-page" href="../fundamental/">
|
||
<svg class="furo-related-icon">
|
||
<use href="#svg-arrow-right"></use>
|
||
</svg>
|
||
<div class="page-info">
|
||
<div class="context">
|
||
<span>Previous</span>
|
||
</div>
|
||
|
||
<div class="title">Fundamental Spaces</div>
|
||
|
||
</div>
|
||
</a>
|
||
</div>
|
||
<div class="bottom-of-page">
|
||
<div class="left-details">
|
||
<div class="copyright">
|
||
Copyright © 2022 Farama Foundation
|
||
</div>
|
||
<!--
|
||
Made with <a href="https://www.sphinx-doc.org/">Sphinx</a> and <a class="muted-link" href="https://pradyunsg.me">@pradyunsg</a>'s
|
||
|
||
<a href="https://github.com/pradyunsg/furo">Furo</a>
|
||
-->
|
||
</div>
|
||
<div class="right-details">
|
||
<div class="icons">
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</footer>
|
||
</div>
|
||
<aside class="toc-drawer">
|
||
|
||
|
||
<div class="toc-sticky toc-scroll">
|
||
<div class="toc-title-container">
|
||
<span class="toc-title">
|
||
On this page
|
||
</span>
|
||
</div>
|
||
<div class="toc-tree-container">
|
||
<div class="toc-tree">
|
||
<ul>
|
||
<li><a class="reference internal" href="#">Composite Spaces</a><ul>
|
||
<li><a class="reference internal" href="#dict">Dict</a><ul>
|
||
<li><a class="reference internal" href="#gymnasium.spaces.Dict"><code class="docutils literal notranslate"><span class="pre">Dict</span></code></a><ul>
|
||
<li><a class="reference internal" href="#gymnasium.spaces.Dict.sample"><code class="docutils literal notranslate"><span class="pre">Dict.sample()</span></code></a></li>
|
||
<li><a class="reference internal" href="#gymnasium.spaces.Dict.seed"><code class="docutils literal notranslate"><span class="pre">Dict.seed()</span></code></a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#tuple">Tuple</a><ul>
|
||
<li><a class="reference internal" href="#gymnasium.spaces.Tuple"><code class="docutils literal notranslate"><span class="pre">Tuple</span></code></a><ul>
|
||
<li><a class="reference internal" href="#gymnasium.spaces.Tuple.sample"><code class="docutils literal notranslate"><span class="pre">Tuple.sample()</span></code></a></li>
|
||
<li><a class="reference internal" href="#gymnasium.spaces.Tuple.seed"><code class="docutils literal notranslate"><span class="pre">Tuple.seed()</span></code></a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#sequence">Sequence</a><ul>
|
||
<li><a class="reference internal" href="#gymnasium.spaces.Sequence"><code class="docutils literal notranslate"><span class="pre">Sequence</span></code></a><ul>
|
||
<li><a class="reference internal" href="#gymnasium.spaces.Sequence.sample"><code class="docutils literal notranslate"><span class="pre">Sequence.sample()</span></code></a></li>
|
||
<li><a class="reference internal" href="#gymnasium.spaces.Sequence.seed"><code class="docutils literal notranslate"><span class="pre">Sequence.seed()</span></code></a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#graph">Graph</a><ul>
|
||
<li><a class="reference internal" href="#gymnasium.spaces.Graph"><code class="docutils literal notranslate"><span class="pre">Graph</span></code></a><ul>
|
||
<li><a class="reference internal" href="#gymnasium.spaces.Graph.sample"><code class="docutils literal notranslate"><span class="pre">Graph.sample()</span></code></a></li>
|
||
<li><a class="reference internal" href="#gymnasium.spaces.Graph.seed"><code class="docutils literal notranslate"><span class="pre">Graph.seed()</span></code></a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</aside>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<script>
|
||
const toggleMenu = () => {
|
||
const menuBtn = document.querySelector(".farama-header-menu__btn");
|
||
const menuContainer = document.querySelector(".farama-header-menu-container");
|
||
if (document.querySelector(".farama-header-menu").classList.contains("active")) {
|
||
menuBtn.setAttribute("aria-expanded", "false");
|
||
menuContainer.setAttribute("aria-hidden", "true");
|
||
} else {
|
||
menuBtn.setAttribute("aria-expanded", "true");
|
||
menuContainer.setAttribute("aria-hidden", "false");
|
||
}
|
||
document.querySelector(".farama-header-menu").classList.toggle("active");
|
||
}
|
||
|
||
document.querySelector(".farama-header-menu__btn").addEventListener("click", toggleMenu);
|
||
document.getElementById("farama-close-menu").addEventListener("click", toggleMenu);
|
||
</script>
|
||
|
||
|
||
<script>
|
||
(() => {
|
||
if (!localStorage.getItem("shownCookieAlert")) {
|
||
const boxElem = document.createElement("div");
|
||
boxElem.classList.add("cookie-alert");
|
||
const containerElem = document.createElement("div");
|
||
containerElem.classList.add("cookie-alert__container");
|
||
const textElem = document.createElement("p");
|
||
textElem.innerHTML = `This page uses <a href="https://analytics.google.com/">
|
||
Google Analytics</a> to collect statistics. You can disable it by blocking
|
||
the JavaScript coming from www.google-analytics.com.`;
|
||
containerElem.appendChild(textElem);
|
||
const closeBtn = document.createElement("button");
|
||
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>`
|
||
closeBtn.onclick = () => {
|
||
localStorage.setItem("shownCookieAlert", "true");
|
||
boxElem.style.display = "none";
|
||
}
|
||
containerElem.appendChild(closeBtn);
|
||
boxElem.appendChild(containerElem);
|
||
document.body.appendChild(boxElem);
|
||
}
|
||
})()
|
||
</script>
|
||
|
||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-6H9C8TWXZ8"></script>
|
||
<script>
|
||
window.dataLayer = window.dataLayer || [];
|
||
function gtag(){dataLayer.push(arguments);}
|
||
gtag('js', new Date());
|
||
|
||
gtag('config', 'G-6H9C8TWXZ8');
|
||
</script>
|
||
|
||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||
<script src="../../../_static/doctools.js"></script>
|
||
<script src="../../../_static/sphinx_highlight.js"></script>
|
||
<script src="../../../_static/scripts/furo.js"></script>
|
||
<script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
||
|
||
<script>
|
||
const createCORSRequest = (method, url) => {
|
||
let xhr = new XMLHttpRequest();
|
||
xhr.responseType = 'json';
|
||
|
||
if ("withCredentials" in xhr) {
|
||
xhr.open(method, url, true);
|
||
} else if (typeof XDomainRequest != "undefined") {
|
||
// IE8 & IE9
|
||
xhr = new XDomainRequest();
|
||
xhr.open(method, url);
|
||
} else {
|
||
// CORS not supported.
|
||
xhr = null;
|
||
}
|
||
return xhr;
|
||
};
|
||
|
||
const url = 'https://farama.org/api/projects.json';
|
||
const imagesBasepath = "https://farama.org/assets/images"
|
||
const method = 'GET';
|
||
let xhr = createCORSRequest(method, url);
|
||
|
||
xhr.onload = () => {
|
||
const jsonResponse = xhr.response;
|
||
const sections = {
|
||
"Documentation": [],
|
||
"Mature Projects": [],
|
||
"Incubating Projects": [],
|
||
"Foundation": [
|
||
{
|
||
name: "About",
|
||
link: "https://farama.org/about"
|
||
},
|
||
{
|
||
name: "Standards",
|
||
link: "https://farama.org/project_standards",
|
||
},
|
||
{
|
||
name: "Donate",
|
||
link: "https://farama.org/donations"
|
||
}
|
||
]
|
||
}
|
||
Object.keys(jsonResponse).forEach(key => {
|
||
projectJson = jsonResponse[key];
|
||
if (projectJson.website !== null) {
|
||
projectJson.link = projectJson.website;
|
||
sections["Documentation"].push(projectJson)
|
||
} else if (projectJson.type == "mature") {
|
||
projectJson.link = projectJson.github;
|
||
sections["Mature Projects"].push(projectJson)
|
||
} else {
|
||
projectJson.link = projectJson.github;
|
||
sections["Incubating Projects"].push(projectJson)
|
||
}
|
||
})
|
||
|
||
const menuContainer = document.querySelector(".farama-header-menu__body");
|
||
|
||
Object.keys(sections).forEach((key, i) => {
|
||
projects = sections[key];
|
||
const sectionElem = Object.assign(
|
||
document.createElement('div'), {
|
||
className:'farama-header-menu__section',
|
||
style: "padding-left: 24px"
|
||
}
|
||
)
|
||
sectionElem.appendChild(Object.assign(document.createElement('span'),
|
||
{
|
||
className:'farama-header-menu__section-title' ,
|
||
innerText: key
|
||
}
|
||
))
|
||
const ulElem = Object.assign(document.createElement('ul'),
|
||
{
|
||
className:'farama-header-menu-list',
|
||
}
|
||
)
|
||
for (let project of projects) {
|
||
const liElem = document.createElement("li");
|
||
const aElem = Object.assign(document.createElement("a"),
|
||
{
|
||
href: project.link
|
||
}
|
||
);
|
||
liElem.appendChild(aElem);
|
||
if (key !== "Foundation") {
|
||
const imgElem = Object.assign(document.createElement("img"),
|
||
{
|
||
src: project.image ? imagesBasepath + project.image : imagesBasepath + "/farama_black.svg",
|
||
alt: `${project.name} logo`,
|
||
className: "farama-black-logo-invert"
|
||
}
|
||
);
|
||
aElem.appendChild(imgElem);
|
||
}
|
||
aElem.appendChild(document.createTextNode(project.name));
|
||
ulElem.appendChild(liElem);
|
||
}
|
||
sectionElem.appendChild(ulElem);
|
||
menuContainer.appendChild(sectionElem)
|
||
});
|
||
}
|
||
|
||
xhr.onerror = function() {
|
||
console.error("Unable to load projects");
|
||
};
|
||
|
||
xhr.send();
|
||
</script>
|
||
|
||
|
||
<script>
|
||
const versioningConfig = {
|
||
githubUser: 'Farama-Foundation',
|
||
githubRepo: 'Gymnasium',
|
||
};
|
||
fetch('/main/_static/versioning/versioning_menu.html').then(response => {
|
||
if (response.status === 200) {
|
||
response.text().then(text => {
|
||
const container = document.createElement("div");
|
||
container.innerHTML = text;
|
||
document.querySelector("body").appendChild(container);
|
||
// innerHtml doenst evaluate scripts, we need to add them dynamically
|
||
Array.from(container.querySelectorAll("script")).forEach(oldScript => {
|
||
const newScript = document.createElement("script");
|
||
Array.from(oldScript.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value));
|
||
newScript.appendChild(document.createTextNode(oldScript.innerHTML));
|
||
oldScript.parentNode.replaceChild(newScript, oldScript);
|
||
});
|
||
});
|
||
} else {
|
||
console.warn("Unable to load versioning menu", response);
|
||
}
|
||
});
|
||
</script>
|
||
|
||
</body>
|
||
</html> |