2022-10-12 15:02:09 +00:00
<!doctype html>
2024-10-08 10:03:58 +00:00
< html class = "no-js" lang = "en" data-content_root = "../../../" >
2022-10-12 15:02:09 +00:00
< head > < meta charset = "utf-8" / >
< meta name = "viewport" content = "width=device-width,initial-scale=1" / >
2022-10-15 15:13:56 +00:00
< meta name = "color-scheme" content = "light dark" >
2022-10-16 13:56:17 +00:00
< meta name = "description" content = "A standard API for reinforcement learning and a diverse set of reference environments (formerly Gym)" >
2022-10-15 15:13:56 +00:00
< meta property = "og:title" content = "Gymnasium Documentation" / >
< meta property = "og:type" content = "website" / >
2022-10-16 13:56:17 +00:00
< meta property = "og:description" content = "A standard API for reinforcement learning and a diverse set of reference environments (formerly Gym)" / >
2023-07-14 22:50:55 +00:00
< meta property = "og:url" content = "https://gymnasium.farama.org/api/wrappers/action_wrappers.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 = "viewport" content = "width=device-width, initial-scale=1" / >
2022-10-12 15:02:09 +00:00
< link rel = "index" title = "Index" href = "../../../genindex/" / > < link rel = "search" title = "Search" href = "../../../search/" / > < link rel = "next" title = "Observation Wrappers" href = "../observation_wrappers/" / > < link rel = "prev" title = "Misc Wrappers" href = "../misc_wrappers/" / >
< link rel = "canonical" href = "https://gymnasium.farama.org/api/wrappers/action_wrappers.html" / >
2024-10-08 10:03:58 +00:00
< link rel = "shortcut icon" href = "../../../_static/favicon.png" / > <!-- Generated with Sphinx 7.4.7 and Furo 2023.08.19.dev1 -->
2022-10-12 15:02:09 +00:00
< title > Action Wrappers - Gymnasium Documentation< / title >
2025-02-26 11:56:33 +00:00
< link rel = "stylesheet" type = "text/css" href = "../../../_static/pygments.css?v=8f2a1f02" / >
2024-10-08 10:03:58 +00:00
< link rel = "stylesheet" type = "text/css" href = "../../../_static/styles/furo.css?v=3e7f4c72" / >
< link rel = "stylesheet" type = "text/css" href = "../../../_static/sg_gallery.css?v=61a4c737" / >
< link rel = "stylesheet" type = "text/css" href = "../../../_static/sg_gallery-binder.css?v=f4aeca0c" / >
< link rel = "stylesheet" type = "text/css" href = "../../../_static/sg_gallery-dataframe.css?v=2082cf3c" / >
< link rel = "stylesheet" type = "text/css" href = "../../../_static/sg_gallery-rendered-html.css?v=1277b6f3" / >
2025-02-26 11:56:33 +00:00
< link rel = "stylesheet" type = "text/css" href = "../../../_static/styles/furo-extensions.css?v=82c8b628" / >
2022-10-12 15:02:09 +00:00
< 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 >
2022-12-12 13:31:00 +00:00
< header class = "farama-header" aria-label = "Farama header" >
2022-10-12 15:02:09 +00:00
< div class = "farama-header__container" >
2022-12-12 13:31:00 +00:00
< 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 >
< / label >
< / div >
< div class = "farama-header__left farama-header__center--mobile" >
2022-10-12 15:02:09 +00:00
< 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" / >
2022-12-12 13:31:00 +00:00
< span class = "farama-header__title" > Gymnasium Documentation< / span >
2022-10-12 15:02:09 +00:00
< / a >
< / div >
< div class = "farama-header__right" >
< div class = "farama-header-menu" >
2022-12-12 13:31:00 +00:00
< button class = "farama-header-menu__btn" aria-label = "Open Farama Menu" aria-expanded = "false" aria-haspopup = "true" aria-controls = "farama-menu" >
2023-03-24 17:29:47 +00:00
< img class = "farama-black-logo-invert" src = "../../../_static/img/farama-logo-header.svg" >
2022-12-12 13:31:00 +00:00
< 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 >
2022-10-12 15:02:09 +00:00
< / svg >
2022-12-12 13:31:00 +00:00
< / button >
< div class = "farama-header-menu-container farama-hidden" aria-hidden = "true" id = "farama-menu" >
2022-10-15 15:13:56 +00:00
< div class = "farama-header-menu__header" >
2022-10-12 15:02:09 +00:00
< a href = "https://farama.org" >
2022-12-12 13:31:00 +00:00
< img class = "farama-header-menu__logo farama-white-logo-invert" src = "../../../_static/img/farama_solid_white.svg" alt = "Farama Foundation logo" >
2022-10-18 09:10:33 +00:00
< span > Farama Foundation< / span >
2022-10-12 15:02:09 +00:00
< / a >
2022-12-12 13:31:00 +00:00
< 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 >
2022-10-12 15:02:09 +00:00
< / div >
2022-10-15 15:13:56 +00:00
< div class = "farama-header-menu__body" >
2022-12-12 13:31:00 +00:00
<!-- Response from farama.org/api/projects.json -->
2022-10-12 15:02:09 +00:00
< / 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" >
2023-03-24 17:29:47 +00:00
<!-- <header class="mobile - header">
2022-10-12 15:02:09 +00:00
< 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 >
2022-12-12 13:31:00 +00:00
< / header > -->
2022-10-12 15:02:09 +00:00
< aside class = "sidebar-drawer" >
< div class = "sidebar-container" >
2022-12-12 13:31:00 +00:00
< 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" >
2023-03-24 17:29:47 +00:00
< input class = "sidebar-search" placeholder = "Search" name = "q" aria-label = "Search" >
2022-10-12 15:02:09 +00:00
< 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 >
2024-10-08 10:03:58 +00:00
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../introduction/basic_usage/" > Basic Usage< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../introduction/train_agent/" > Training an Agent< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../introduction/create_custom_env/" > Create a Custom Environment< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../introduction/record_agent/" > Recording Agents< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../introduction/speed_up_env/" > Speeding Up Training< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../introduction/gym_compatibility/" > Compatibility with Gym< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../introduction/migration_guide/" > Migration Guide - v0.21 to v1.0.0< / a > < / li >
2022-10-12 15:02:09 +00:00
< / 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 >
2024-10-08 10:03:58 +00:00
< li class = "toctree-l1" > < a class = "reference internal" href = "../../registry/" > Make and register< / a > < / li >
2023-07-14 22:50:55 +00:00
< li class = "toctree-l1 has-children" > < a class = "reference internal" href = "../../spaces/" > Spaces< / a > < input class = "toctree-checkbox" id = "toctree-checkbox-1" name = "toctree-checkbox-1" role = "switch" type = "checkbox" / > < label for = "toctree-checkbox-1" > < div class = "visually-hidden" > Toggle navigation of Spaces< / div > < i class = "icon" > < svg > < use href = "#svg-arrow-right" > < / use > < / svg > < / i > < / label > < ul >
2022-10-12 15:02:09 +00:00
< li class = "toctree-l2" > < a class = "reference internal" href = "../../spaces/fundamental/" > Fundamental Spaces< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../spaces/composite/" > Composite Spaces< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../spaces/utils/" > Spaces Utils< / a > < / li >
< / ul >
< / li >
2023-07-14 22:50:55 +00:00
< li class = "toctree-l1 current has-children" > < a class = "reference internal" href = "../" > Wrappers< / a > < input checked = "" 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 navigation of Wrappers< / div > < i class = "icon" > < svg > < use href = "#svg-arrow-right" > < / use > < / svg > < / i > < / label > < ul class = "current" >
2024-10-08 10:03:58 +00:00
< li class = "toctree-l2" > < a class = "reference internal" href = "../table/" > List of Wrappers< / a > < / li >
2022-10-12 15:02:09 +00:00
< li class = "toctree-l2" > < a class = "reference internal" href = "../misc_wrappers/" > Misc Wrappers< / a > < / li >
< li class = "toctree-l2 current current-page" > < a class = "current reference internal" href = "#" > Action Wrappers< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../observation_wrappers/" > Observation Wrappers< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../reward_wrappers/" > Reward Wrappers< / a > < / li >
< / ul >
< / li >
2024-10-08 10:03:58 +00:00
< li class = "toctree-l1 has-children" > < a class = "reference internal" href = "../../vector/" > Vectorize< / 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 navigation of Vectorize< / div > < i class = "icon" > < svg > < use href = "#svg-arrow-right" > < / use > < / svg > < / i > < / label > < ul >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../vector/wrappers/" > Wrappers< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../vector/async_vector_env/" > AsyncVectorEnv< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../vector/sync_vector_env/" > SyncVectorEnv< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../vector/utils/" > Utility functions< / a > < / li >
2022-12-12 13:31:00 +00:00
< / ul >
< / li >
2024-10-08 10:03:58 +00:00
< li class = "toctree-l1" > < a class = "reference internal" href = "../../utils/" > Utility functions< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../functional/" > Functional Env< / a > < / li >
2022-10-12 15:02:09 +00:00
< / ul >
< p class = "caption" role = "heading" > < span class = "caption-text" > Environments< / span > < / p >
< ul >
2023-07-14 22:50:55 +00:00
< 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 navigation of Classic Control< / div > < i class = "icon" > < svg > < use href = "#svg-arrow-right" > < / use > < / svg > < / i > < / label > < ul >
2022-10-27 14:56:52 +00:00
< 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 >
2022-10-12 15:02:09 +00:00
< / ul >
< / li >
2023-07-14 22:50:55 +00:00
< 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 navigation of Box2D< / div > < i class = "icon" > < svg > < use href = "#svg-arrow-right" > < / use > < / svg > < / i > < / label > < ul >
2022-10-27 14:56:52 +00:00
< 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 >
2022-10-12 15:02:09 +00:00
< / ul >
< / li >
2023-07-14 22:50:55 +00:00
< 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 navigation of Toy Text< / div > < i class = "icon" > < svg > < use href = "#svg-arrow-right" > < / use > < / svg > < / i > < / label > < ul >
2022-10-27 14:56:52 +00:00
< 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 >
2022-10-12 15:02:09 +00:00
< / ul >
< / li >
2023-07-14 22:50:55 +00:00
< 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 navigation of MuJoCo< / div > < i class = "icon" > < svg > < use href = "#svg-arrow-right" > < / use > < / svg > < / i > < / label > < ul >
2022-10-27 14:56:52 +00:00
< 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/" > Humanoid< / a > < / li >
2023-07-14 22:50:55 +00:00
< li class = "toctree-l2" > < a class = "reference internal" href = "../../../environments/mujoco/humanoid_standup/" > Humanoid Standup< / a > < / li >
2022-10-27 14:56:52 +00:00
< 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 >
2023-07-14 22:50:55 +00:00
< li class = "toctree-l2" > < a class = "reference internal" href = "../../../environments/mujoco/pusher/" > Pusher< / a > < / li >
2022-10-27 14:56:52 +00:00
< 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/walker2d/" > Walker2D< / a > < / li >
2022-10-12 15:02:09 +00:00
< / ul >
< / li >
2024-10-08 10:03:58 +00:00
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../environments/atari/" > Atari< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../environments/third_party_environments/" > External Environments< / a > < / li >
2022-10-12 15:02:09 +00:00
< / ul >
< p class = "caption" role = "heading" > < span class = "caption-text" > Tutorials< / span > < / p >
< ul >
2025-02-26 11:56:33 +00:00
< li class = "toctree-l1 has-children" > < a class = "reference internal" href = "../../../tutorials/gymnasium_basics/" > Gymnasium Basics Documentation Links< / 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 navigation of Gymnasium Basics Documentation Links< / div > < i class = "icon" > < svg > < use href = "#svg-arrow-right" > < / use > < / svg > < / i > < / label > < ul >
2024-10-08 10:03:58 +00:00
< li class = "toctree-l2" > < a class = "reference internal" href = "../../../tutorials/gymnasium_basics/load_quadruped_model/" > Load custom quadruped robot environments< / a > < / li >
2023-01-20 14:42:12 +00:00
< 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 >
2025-02-26 11:56:33 +00:00
< li class = "toctree-l1 has-children" > < a class = "reference internal" href = "../../../tutorials/training_agents/" > Training Agents links in the Gymnasium Documentation< / 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 navigation of Training Agents links in the Gymnasium Documentation< / div > < i class = "icon" > < svg > < use href = "#svg-arrow-right" > < / use > < / svg > < / i > < / label > < ul >
2023-01-20 14:42:12 +00:00
< 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 >
2023-03-24 17:29:47 +00:00
< li class = "toctree-l2" > < a class = "reference internal" href = "../../../tutorials/training_agents/FrozenLake_tuto/" > Frozenlake benchmark< / a > < / li >
2023-01-20 14:42:12 +00:00
< / ul >
< / li >
2024-10-08 10:03:58 +00:00
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../tutorials/third-party-tutorials/" > Third-Party Tutorials< / a > < / li >
2022-10-12 15:02:09 +00:00
< / 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 >
2024-10-08 10:03:58 +00:00
< li class = "toctree-l1" > < a class = "reference external" href = "https://arxiv.org/abs/2407.17032" > Paper< / a > < / li >
2023-03-25 12:03:43 +00:00
< 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 >
2022-10-25 11:10:26 +00:00
< 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 >
2022-10-12 15:02:09 +00:00
< / ul >
< / div >
< / div >
< / div >
< / div >
< / aside >
2023-03-24 17:29:47 +00:00
< div class = "main-container" >
2022-10-12 15:02:09 +00:00
2023-03-24 17:29:47 +00:00
< 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 >
2023-07-14 22:50:55 +00:00
< div class = "content-icon-container" > < div class = "edit-this-page" >
< a class = "muted-link" href = "https://github.com/Farama-Foundation/Gymnasium/edit/main/docs/api/wrappers/action_wrappers.md" title = "Edit this page" >
< svg aria-hidden = "true" viewBox = "0 0 24 24" stroke-width = "1.5" stroke = "currentColor" fill = "none" stroke-linecap = "round" stroke-linejoin = "round" >
< path stroke = "none" d = "M0 0h24v24H0z" fill = "none" / >
< path d = "M4 20h4l10.5 -10.5a1.5 1.5 0 0 0 -4 -4l-10.5 10.5v4" / >
< line x1 = "13.5" y1 = "6.5" x2 = "17.5" y2 = "10.5" / >
< / svg >
< span class = "visually-hidden" > Edit this page< / span >
< / a >
< / div > < div class = "theme-toggle-container theme-toggle-content" >
2023-03-24 17:29:47 +00:00
< 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 >
2022-10-12 15:02:09 +00:00
< / div >
2023-03-24 17:29:47 +00:00
< article role = "main" >
2024-10-08 10:03:58 +00:00
< section class = "tex2jax_ignore mathjax_ignore" id = "action-wrappers" >
< h1 > Action Wrappers< a class = "headerlink" href = "#action-wrappers" title = "Link to this heading" > ¶< / a > < / h1 >
2022-12-12 13:31:00 +00:00
< section id = "base-class" >
2024-10-08 10:03:58 +00:00
< h2 > Base Class< a class = "headerlink" href = "#base-class" title = "Link to this heading" > ¶< / a > < / h2 >
2022-10-12 15:02:09 +00:00
< dl class = "py class" >
< dt class = "sig sig-object py" id = "gymnasium.ActionWrapper" >
2024-10-08 10:03:58 +00:00
< em class = "property" > < span class = "pre" > class< / span > < span class = "w" > < / span > < / em > < span class = "sig-prename descclassname" > < span class = "pre" > gymnasium.< / span > < / span > < span class = "sig-name descname" > < span class = "pre" > ActionWrapper< / span > < / span > < span class = "sig-paren" > (< / span > < em class = "sig-param" > < span class = "n" > < span class = "pre" > env< / span > < / span > < span class = "p" > < span class = "pre" > :< / span > < / span > < span class = "w" > < / span > < span class = "n" > < a class = "reference internal" href = "../../env/#gymnasium.Env" title = "gymnasium.core.Env" > < span class = "pre" > Env< / span > < / a > < span class = "p" > < span class = "pre" > [< / span > < / span > < span class = "pre" > ObsType< / span > < span class = "p" > < span class = "pre" > ,< / span > < / span > < span class = "w" > < / span > < span class = "pre" > ActType< / span > < span class = "p" > < span class = "pre" > ]< / span > < / span > < / span > < / em > < span class = "sig-paren" > )< / span > < a class = "reference internal" href = "../../../_modules/gymnasium/core/#ActionWrapper" > < span class = "viewcode-link" > < span class = "pre" > [source]< / span > < / span > < / a > < a class = "headerlink" href = "#gymnasium.ActionWrapper" title = "Link to this definition" > ¶< / a > < / dt >
< dd > < p > Superclass of wrappers that can modify the action before < code class = "xref py py-meth docutils literal notranslate" > < span class = "pre" > step()< / span > < / code > .< / p >
2022-10-12 15:02:09 +00:00
< p > If you would like to apply a function to the action before passing it to the base environment,
2022-12-12 13:31:00 +00:00
you can simply inherit from < a class = "reference internal" href = "#gymnasium.ActionWrapper" title = "gymnasium.ActionWrapper" > < code class = "xref py py-class docutils literal notranslate" > < span class = "pre" > ActionWrapper< / span > < / code > < / a > and overwrite the method < a class = "reference internal" href = "#gymnasium.ActionWrapper.action" title = "gymnasium.ActionWrapper.action" > < code class = "xref py py-meth docutils literal notranslate" > < span class = "pre" > action()< / span > < / code > < / a > to implement
2022-10-12 15:02:09 +00:00
that transformation. The transformation defined in that method must take values in the base environment’ s
action space. However, its domain might differ from the original action space.
2024-10-08 10:03:58 +00:00
In that case, you need to specify the new action space of the wrapper by setting < code class = "xref py py-attr docutils literal notranslate" > < span class = "pre" > action_space< / span > < / code > in
2022-10-12 15:02:09 +00:00
the < code class = "xref py py-meth docutils literal notranslate" > < span class = "pre" > __init__()< / span > < / code > method of your wrapper.< / p >
2024-10-08 10:03:58 +00:00
< p > Among others, Gymnasium provides the action wrappers < a class = "reference internal" href = "#gymnasium.wrappers.ClipAction" title = "gymnasium.wrappers.ClipAction" > < code class = "xref py py-class docutils literal notranslate" > < span class = "pre" > gymnasium.wrappers.ClipAction< / span > < / code > < / a > and
< a class = "reference internal" href = "#gymnasium.wrappers.RescaleAction" title = "gymnasium.wrappers.RescaleAction" > < code class = "xref py py-class docutils literal notranslate" > < span class = "pre" > gymnasium.wrappers.RescaleAction< / span > < / code > < / a > for clipping and rescaling actions.< / p >
< dl class = "field-list simple" >
< dt class = "field-odd" > Parameters< span class = "colon" > :< / span > < / dt >
< dd class = "field-odd" > < p > < strong > env< / strong > – Environment to be wrapped.< / p >
< / dd >
< / dl >
2022-12-12 13:31:00 +00:00
< dl class = "py method" >
< dt class = "sig sig-object py" id = "gymnasium.ActionWrapper.action" >
2024-10-08 10:03:58 +00:00
< span class = "sig-name descname" > < span class = "pre" > action< / span > < / span > < span class = "sig-paren" > (< / span > < em class = "sig-param" > < span class = "n" > < span class = "pre" > action< / span > < / span > < span class = "p" > < span class = "pre" > :< / span > < / span > < span class = "w" > < / span > < span class = "n" > < span class = "pre" > WrapperActType< / 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" > ActType< / span > < / span > < / span > < a class = "reference internal" href = "../../../_modules/gymnasium/core/#ActionWrapper.action" > < span class = "viewcode-link" > < span class = "pre" > [source]< / span > < / span > < / a > < a class = "headerlink" href = "#gymnasium.ActionWrapper.action" title = "Link to this definition" > ¶< / a > < / dt >
< dd > < p > Returns a modified action before < code class = "xref py py-meth docutils literal notranslate" > < span class = "pre" > step()< / span > < / code > is called.< / p >
2022-10-12 15:02:09 +00:00
< dl class = "field-list simple" >
< dt class = "field-odd" > Parameters< span class = "colon" > :< / span > < / dt >
< dd class = "field-odd" > < p > < strong > action< / strong > – The original < code class = "xref py py-meth docutils literal notranslate" > < span class = "pre" > step()< / span > < / code > actions< / p >
< / dd >
< dt class = "field-even" > Returns< span class = "colon" > :< / span > < / dt >
< dd class = "field-even" > < p > < strong > The modified actions< / strong > < / p >
< / dd >
< / dl >
< / dd > < / dl >
< / dd > < / dl >
< / section >
2022-12-12 13:31:00 +00:00
< section id = "available-action-wrappers" >
2024-10-08 10:03:58 +00:00
< h2 > Available Action Wrappers< a class = "headerlink" href = "#available-action-wrappers" title = "Link to this heading" > ¶< / a > < / h2 >
< dl class = "py class" >
< dt class = "sig sig-object py" id = "gymnasium.wrappers.TransformAction" >
< em class = "property" > < span class = "pre" > class< / span > < span class = "w" > < / span > < / em > < span class = "sig-prename descclassname" > < span class = "pre" > gymnasium.wrappers.< / span > < / span > < span class = "sig-name descname" > < span class = "pre" > TransformAction< / span > < / span > < span class = "sig-paren" > (< / span > < em class = "sig-param" > < span class = "n" > < span class = "pre" > env< / span > < / span > < span class = "p" > < span class = "pre" > :< / span > < / span > < span class = "w" > < / span > < span class = "n" > < span class = "pre" > gym.Env< / span > < span class = "p" > < span class = "pre" > [< / span > < / span > < span class = "pre" > ObsType< / span > < span class = "p" > < span class = "pre" > ,< / span > < / span > < span class = "w" > < / span > < span class = "pre" > ActType< / span > < span class = "p" > < span class = "pre" > ]< / span > < / span > < / span > < / em > , < em class = "sig-param" > < span class = "n" > < span class = "pre" > func< / span > < / span > < span class = "p" > < span class = "pre" > :< / span > < / span > < span class = "w" > < / span > < span class = "n" > < span class = "pre" > Callable< / span > < span class = "p" > < span class = "pre" > [< / span > < / span > < span class = "p" > < span class = "pre" > [< / span > < / span > < span class = "pre" > WrapperActType< / span > < span class = "p" > < span class = "pre" > ]< / span > < / span > < span class = "p" > < span class = "pre" > ,< / span > < / span > < span class = "w" > < / span > < span class = "pre" > ActType< / span > < span class = "p" > < span class = "pre" > ]< / span > < / span > < / span > < / em > , < em class = "sig-param" > < span class = "n" > < span class = "pre" > action_space< / span > < / span > < span class = "p" > < span class = "pre" > :< / span > < / span > < span class = "w" > < / span > < span class = "n" > < a class = "reference internal" href = "../../spaces/#gymnasium.spaces.Space" title = "gymnasium.spaces.Space" > < span class = "pre" > Space< / span > < / a > < span class = "p" > < span class = "pre" > [< / span > < / span > < span class = "pre" > WrapperActType< / 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 > < / em > < span class = "sig-paren" > )< / span > < a class = "reference internal" href = "../../../_modules/gymnasium/wrappers/transform_action/#TransformAction" > < span class = "viewcode-link" > < span class = "pre" > [source]< / span > < / span > < / a > < a class = "headerlink" href = "#gymnasium.wrappers.TransformAction" title = "Link to this definition" > ¶< / a > < / dt >
< dd > < p > Applies a function to the < code class = "docutils literal notranslate" > < span class = "pre" > action< / span > < / code > before passing the modified value to the environment < code class = "docutils literal notranslate" > < span class = "pre" > step< / span > < / code > function.< / p >
< p > A vector version of the wrapper exists < a class = "reference internal" href = "../../vector/wrappers/#gymnasium.wrappers.vector.TransformAction" title = "gymnasium.wrappers.vector.TransformAction" > < code class = "xref py py-class docutils literal notranslate" > < span class = "pre" > gymnasium.wrappers.vector.TransformAction< / span > < / code > < / a > .< / p >
< p class = "rubric" > Example< / p >
2025-02-26 11:56:33 +00:00
< div class = "doctest highlight-default notranslate" > < div class = "highlight" > < pre > < span > < / span > < span class = "gp" > > > > < / span > < span class = "kn" > import< / span > < span class = "w" > < / span > < span class = "nn" > numpy< / span > < span class = "w" > < / span > < span class = "k" > as< / span > < span class = "w" > < / span > < span class = "nn" > np< / span >
< span class = "gp" > > > > < / span > < span class = "kn" > import< / span > < span class = "w" > < / span > < span class = "nn" > gymnasium< / span > < span class = "w" > < / span > < span class = "k" > as< / span > < span class = "w" > < / span > < span class = "nn" > gym< / span >
2024-10-08 10:03:58 +00:00
< span class = "gp" > > > > < / span > < span class = "n" > env< / span > < span class = "o" > =< / span > < span class = "n" > gym< / span > < span class = "o" > .< / span > < span class = "n" > make< / span > < span class = "p" > (< / span > < span class = "s2" > " MountainCarContinuous-v0" < / span > < span class = "p" > )< / span >
< span class = "gp" > > > > < / span > < span class = "n" > _< / span > < span class = "o" > =< / span > < span class = "n" > env< / span > < span class = "o" > .< / span > < span class = "n" > reset< / span > < span class = "p" > (< / span > < span class = "n" > seed< / span > < span class = "o" > =< / span > < span class = "mi" > 123< / span > < span class = "p" > )< / span >
< span class = "gp" > > > > < / span > < span class = "n" > obs< / span > < span class = "p" > ,< / span > < span class = "o" > *< / span > < span class = "n" > _< / span > < span class = "o" > =< / span > < span class = "n" > env< / span > < span class = "o" > .< / span > < span class = "n" > step< / span > < span class = "p" > (< / span > < span class = "n" > np< / span > < span class = "o" > .< / span > < span class = "n" > array< / span > < span class = "p" > ([< / span > < span class = "mf" > 0.0< / span > < span class = "p" > ,< / span > < span class = "mf" > 1.0< / span > < span class = "p" > ]))< / span >
< span class = "gp" > > > > < / span > < span class = "n" > obs< / span >
< span class = "go" > array([-4.6397772e-01, -4.4808415e-04], dtype=float32)< / span >
< span class = "gp" > > > > < / span > < span class = "n" > env< / span > < span class = "o" > =< / span > < span class = "n" > gym< / span > < span class = "o" > .< / span > < span class = "n" > make< / span > < span class = "p" > (< / span > < span class = "s2" > " MountainCarContinuous-v0" < / span > < span class = "p" > )< / span >
< span class = "gp" > > > > < / span > < span class = "n" > env< / span > < span class = "o" > =< / span > < span class = "n" > TransformAction< / span > < span class = "p" > (< / span > < span class = "n" > env< / span > < span class = "p" > ,< / span > < span class = "k" > lambda< / span > < span class = "n" > a< / span > < span class = "p" > :< / span > < span class = "mf" > 0.5< / span > < span class = "o" > *< / span > < span class = "n" > a< / span > < span class = "o" > +< / span > < span class = "mf" > 0.1< / span > < span class = "p" > ,< / span > < span class = "n" > env< / span > < span class = "o" > .< / span > < span class = "n" > action_space< / span > < span class = "p" > )< / span >
< span class = "gp" > > > > < / span > < span class = "n" > _< / span > < span class = "o" > =< / span > < span class = "n" > env< / span > < span class = "o" > .< / span > < span class = "n" > reset< / span > < span class = "p" > (< / span > < span class = "n" > seed< / span > < span class = "o" > =< / span > < span class = "mi" > 123< / span > < span class = "p" > )< / span >
< span class = "gp" > > > > < / span > < span class = "n" > obs< / span > < span class = "p" > ,< / span > < span class = "o" > *< / span > < span class = "n" > _< / span > < span class = "o" > =< / span > < span class = "n" > env< / span > < span class = "o" > .< / span > < span class = "n" > step< / span > < span class = "p" > (< / span > < span class = "n" > np< / span > < span class = "o" > .< / span > < span class = "n" > array< / span > < span class = "p" > ([< / span > < span class = "mf" > 0.0< / span > < span class = "p" > ,< / span > < span class = "mf" > 1.0< / span > < span class = "p" > ]))< / span >
< span class = "gp" > > > > < / span > < span class = "n" > obs< / span >
< span class = "go" > array([-4.6382770e-01, -2.9808417e-04], dtype=float32)< / span >
< / pre > < / div >
< / div >
< dl class = "simple" >
< dt > Change logs:< / dt > < dd > < ul class = "simple" >
< li > < p > v1.0.0 - Initially added< / p > < / li >
< / ul >
< / dd >
< / dl >
< 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 > env< / strong > – The environment to wrap< / p > < / li >
< li > < p > < strong > func< / strong > – Function to apply to the < code class = "xref py py-meth docutils literal notranslate" > < span class = "pre" > step()< / span > < / code > ’ s < code class = "docutils literal notranslate" > < span class = "pre" > action< / span > < / code > < / p > < / li >
< li > < p > < strong > action_space< / strong > – The updated action space of the wrapper given the function.< / p > < / li >
< / ul >
< / dd >
< / dl >
< / dd > < / dl >
2022-10-12 15:02:09 +00:00
< dl class = "py class" >
< dt class = "sig sig-object py" id = "gymnasium.wrappers.ClipAction" >
2024-10-08 10:03:58 +00:00
< em class = "property" > < span class = "pre" > class< / span > < span class = "w" > < / span > < / em > < span class = "sig-prename descclassname" > < span class = "pre" > gymnasium.wrappers.< / span > < / span > < span class = "sig-name descname" > < span class = "pre" > ClipAction< / span > < / span > < span class = "sig-paren" > (< / span > < em class = "sig-param" > < span class = "n" > < span class = "pre" > env< / span > < / span > < span class = "p" > < span class = "pre" > :< / span > < / span > < span class = "w" > < / span > < span class = "n" > < a class = "reference internal" href = "../../env/#gymnasium.Env" title = "gymnasium.core.Env" > < span class = "pre" > Env< / span > < / a > < span class = "p" > < span class = "pre" > [< / span > < / span > < span class = "pre" > ObsType< / span > < span class = "p" > < span class = "pre" > ,< / span > < / span > < span class = "w" > < / span > < span class = "pre" > ActType< / span > < span class = "p" > < span class = "pre" > ]< / span > < / span > < / span > < / em > < span class = "sig-paren" > )< / span > < a class = "reference internal" href = "../../../_modules/gymnasium/wrappers/transform_action/#ClipAction" > < span class = "viewcode-link" > < span class = "pre" > [source]< / span > < / span > < / a > < a class = "headerlink" href = "#gymnasium.wrappers.ClipAction" title = "Link to this definition" > ¶< / a > < / dt >
< dd > < p > Clips the < code class = "docutils literal notranslate" > < span class = "pre" > action< / span > < / code > pass to < code class = "docutils literal notranslate" > < span class = "pre" > step< / span > < / code > to be within the environment’ s < cite > action_space< / cite > .< / p >
< p > A vector version of the wrapper exists < a class = "reference internal" href = "../../vector/wrappers/#gymnasium.wrappers.vector.ClipAction" title = "gymnasium.wrappers.vector.ClipAction" > < code class = "xref py py-class docutils literal notranslate" > < span class = "pre" > gymnasium.wrappers.vector.ClipAction< / span > < / code > < / a > .< / p >
2022-10-12 15:02:09 +00:00
< p class = "rubric" > Example< / p >
2025-02-26 11:56:33 +00:00
< div class = "doctest highlight-default notranslate" > < div class = "highlight" > < pre > < span > < / span > < span class = "gp" > > > > < / span > < span class = "kn" > import< / span > < span class = "w" > < / span > < span class = "nn" > gymnasium< / span > < span class = "w" > < / span > < span class = "k" > as< / span > < span class = "w" > < / span > < span class = "nn" > gym< / span >
< span class = "gp" > > > > < / span > < span class = "kn" > from< / span > < span class = "w" > < / span > < span class = "nn" > gymnasium.wrappers< / span > < span class = "w" > < / span > < span class = "kn" > import< / span > < span class = "n" > ClipAction< / span >
< span class = "gp" > > > > < / span > < span class = "kn" > import< / span > < span class = "w" > < / span > < span class = "nn" > numpy< / span > < span class = "w" > < / span > < span class = "k" > as< / span > < span class = "w" > < / span > < span class = "nn" > np< / span >
2024-10-08 10:03:58 +00:00
< span class = "gp" > > > > < / span > < span class = "n" > env< / span > < span class = "o" > =< / span > < span class = "n" > gym< / span > < span class = "o" > .< / span > < span class = "n" > make< / span > < span class = "p" > (< / span > < span class = "s2" > " Hopper-v4" < / span > < span class = "p" > ,< / span > < span class = "n" > disable_env_checker< / span > < span class = "o" > =< / span > < span class = "kc" > True< / span > < span class = "p" > )< / span >
2022-10-12 15:02:09 +00:00
< span class = "gp" > > > > < / span > < span class = "n" > env< / span > < span class = "o" > =< / span > < span class = "n" > ClipAction< / span > < span class = "p" > (< / span > < span class = "n" > env< / span > < span class = "p" > )< / span >
< span class = "gp" > > > > < / span > < span class = "n" > env< / span > < span class = "o" > .< / span > < span class = "n" > action_space< / span >
2024-10-08 10:03:58 +00:00
< span class = "go" > Box(-inf, inf, (3,), float32)< / span >
2023-01-20 14:42:12 +00:00
< span class = "gp" > > > > < / span > < span class = "n" > _< / span > < span class = "o" > =< / span > < span class = "n" > env< / span > < span class = "o" > .< / span > < span class = "n" > reset< / span > < span class = "p" > (< / span > < span class = "n" > seed< / span > < span class = "o" > =< / span > < span class = "mi" > 42< / span > < span class = "p" > )< / span >
2024-10-08 10:03:58 +00:00
< span class = "gp" > > > > < / span > < span class = "n" > _< / span > < span class = "o" > =< / span > < span class = "n" > env< / span > < span class = "o" > .< / span > < span class = "n" > step< / span > < span class = "p" > (< / span > < span class = "n" > np< / span > < span class = "o" > .< / span > < span class = "n" > array< / span > < span class = "p" > ([< / span > < span class = "mf" > 5.0< / span > < span class = "p" > ,< / span > < span class = "o" > -< / span > < span class = "mf" > 2.0< / span > < span class = "p" > ,< / span > < span class = "mf" > 0.0< / span > < span class = "p" > ],< / span > < span class = "n" > dtype< / span > < span class = "o" > =< / span > < span class = "n" > np< / span > < span class = "o" > .< / span > < span class = "n" > float32< / span > < span class = "p" > ))< / span >
2023-01-20 14:42:12 +00:00
< span class = "gp" > ... < / span > < span class = "c1" > # Executes the action np.array([1.0, -1.0, 0]) in the base environment< / span >
2022-10-12 15:02:09 +00:00
< / pre > < / div >
< / div >
2024-10-08 10:03:58 +00:00
< dl class = "simple" >
< dt > Change logs:< / dt > < dd > < ul class = "simple" >
< li > < p > v0.12.6 - Initially added< / p > < / li >
< li > < p > v1.0.0 - Action space is updated to infinite bounds as is technically correct< / p > < / li >
< / ul >
< / dd >
< / dl >
2022-10-12 15:02:09 +00:00
< dl class = "field-list simple" >
< dt class = "field-odd" > Parameters< span class = "colon" > :< / span > < / dt >
2024-10-08 10:03:58 +00:00
< dd class = "field-odd" > < p > < strong > env< / strong > – The environment to wrap< / p >
2022-10-12 15:02:09 +00:00
< / dd >
< / dl >
< / dd > < / dl >
< dl class = "py class" >
< dt class = "sig sig-object py" id = "gymnasium.wrappers.RescaleAction" >
2024-10-08 10:03:58 +00:00
< em class = "property" > < span class = "pre" > class< / span > < span class = "w" > < / span > < / em > < span class = "sig-prename descclassname" > < span class = "pre" > gymnasium.wrappers.< / span > < / span > < span class = "sig-name descname" > < span class = "pre" > RescaleAction< / span > < / span > < span class = "sig-paren" > (< / span > < em class = "sig-param" > < span class = "n" > < span class = "pre" > env< / span > < / span > < span class = "p" > < span class = "pre" > :< / span > < / span > < span class = "w" > < / span > < span class = "n" > < span class = "pre" > gym.Env< / span > < span class = "p" > < span class = "pre" > [< / span > < / span > < span class = "pre" > ObsType< / span > < span class = "p" > < span class = "pre" > ,< / span > < / span > < span class = "w" > < / span > < span class = "pre" > ActType< / span > < span class = "p" > < span class = "pre" > ]< / span > < / span > < / span > < / em > , < em class = "sig-param" > < span class = "n" > < span class = "pre" > min_action< / span > < / span > < span class = "p" > < span class = "pre" > :< / span > < / span > < span class = "w" > < / span > < span class = "n" > < span class = "pre" > np.floating< / 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" > np.ndarray< / span > < / span > < / em > , < em class = "sig-param" > < span class = "n" > < span class = "pre" > max_action< / span > < / span > < span class = "p" > < span class = "pre" > :< / span > < / span > < span class = "w" > < / span > < span class = "n" > < span class = "pre" > np.floating< / 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" > np.ndarray< / span > < / span > < / em > < span class = "sig-paren" > )< / span > < a class = "reference internal" href = "../../../_modules/gymnasium/wrappers/transform_action/#RescaleAction" > < span class = "viewcode-link" > < span class = "pre" > [source]< / span > < / span > < / a > < a class = "headerlink" href = "#gymnasium.wrappers.RescaleAction" title = "Link to this definition" > ¶< / a > < / dt >
< dd > < p > Affinely (linearly) rescales a < code class = "docutils literal notranslate" > < span class = "pre" > Box< / span > < / code > action space of the environment to within the range of < code class = "docutils literal notranslate" > < span class = "pre" > [min_action,< / span > < span class = "pre" > max_action]< / span > < / code > .< / p >
2022-10-12 15:02:09 +00:00
< p > The base environment < code class = "xref py py-attr docutils literal notranslate" > < span class = "pre" > env< / span > < / code > must have an action space of type < code class = "xref py py-class docutils literal notranslate" > < span class = "pre" > spaces.Box< / span > < / code > . If < code class = "xref py py-attr docutils literal notranslate" > < span class = "pre" > min_action< / span > < / code >
or < code class = "xref py py-attr docutils literal notranslate" > < span class = "pre" > max_action< / span > < / code > are numpy arrays, the shape must match the shape of the environment’ s action space.< / p >
2024-10-08 10:03:58 +00:00
< p > A vector version of the wrapper exists < a class = "reference internal" href = "../../vector/wrappers/#gymnasium.wrappers.vector.RescaleAction" title = "gymnasium.wrappers.vector.RescaleAction" > < code class = "xref py py-class docutils literal notranslate" > < span class = "pre" > gymnasium.wrappers.vector.RescaleAction< / span > < / code > < / a > .< / p >
2022-10-12 15:02:09 +00:00
< p class = "rubric" > Example< / p >
2025-02-26 11:56:33 +00:00
< div class = "doctest highlight-default notranslate" > < div class = "highlight" > < pre > < span > < / span > < span class = "gp" > > > > < / span > < span class = "kn" > import< / span > < span class = "w" > < / span > < span class = "nn" > gymnasium< / span > < span class = "w" > < / span > < span class = "k" > as< / span > < span class = "w" > < / span > < span class = "nn" > gym< / span >
< span class = "gp" > > > > < / span > < span class = "kn" > from< / span > < span class = "w" > < / span > < span class = "nn" > gymnasium.wrappers< / span > < span class = "w" > < / span > < span class = "kn" > import< / span > < span class = "n" > RescaleAction< / span >
< span class = "gp" > > > > < / span > < span class = "kn" > import< / span > < span class = "w" > < / span > < span class = "nn" > numpy< / span > < span class = "w" > < / span > < span class = "k" > as< / span > < span class = "w" > < / span > < span class = "nn" > np< / span >
2024-10-08 10:03:58 +00:00
< span class = "gp" > > > > < / span > < span class = "n" > env< / span > < span class = "o" > =< / span > < span class = "n" > gym< / span > < span class = "o" > .< / span > < span class = "n" > make< / span > < span class = "p" > (< / span > < span class = "s2" > " Hopper-v4" < / span > < span class = "p" > ,< / span > < span class = "n" > disable_env_checker< / span > < span class = "o" > =< / span > < span class = "kc" > True< / span > < span class = "p" > )< / span >
2023-01-20 14:42:12 +00:00
< span class = "gp" > > > > < / span > < span class = "n" > _< / span > < span class = "o" > =< / span > < span class = "n" > env< / span > < span class = "o" > .< / span > < span class = "n" > reset< / span > < span class = "p" > (< / span > < span class = "n" > seed< / span > < span class = "o" > =< / span > < span class = "mi" > 42< / span > < span class = "p" > )< / span >
2024-10-08 10:03:58 +00:00
< span class = "gp" > > > > < / span > < span class = "n" > obs< / span > < span class = "p" > ,< / span > < span class = "n" > _< / span > < span class = "p" > ,< / span > < span class = "n" > _< / span > < span class = "p" > ,< / span > < span class = "n" > _< / span > < span class = "p" > ,< / span > < span class = "n" > _< / span > < span class = "o" > =< / span > < span class = "n" > env< / span > < span class = "o" > .< / span > < span class = "n" > step< / span > < span class = "p" > (< / span > < span class = "n" > np< / span > < span class = "o" > .< / span > < span class = "n" > array< / span > < span class = "p" > ([< / span > < span class = "mi" > 1< / span > < span class = "p" > ,< / span > < span class = "mi" > 1< / span > < span class = "p" > ,< / span > < span class = "mi" > 1< / span > < span class = "p" > ],< / span > < span class = "n" > dtype< / span > < span class = "o" > =< / span > < span class = "n" > np< / span > < span class = "o" > .< / span > < span class = "n" > float32< / span > < span class = "p" > ))< / span >
2023-01-20 14:42:12 +00:00
< span class = "gp" > > > > < / span > < span class = "n" > _< / span > < span class = "o" > =< / span > < span class = "n" > env< / span > < span class = "o" > .< / span > < span class = "n" > reset< / span > < span class = "p" > (< / span > < span class = "n" > seed< / span > < span class = "o" > =< / span > < span class = "mi" > 42< / span > < span class = "p" > )< / span >
2022-10-12 15:02:09 +00:00
< span class = "gp" > > > > < / span > < span class = "n" > min_action< / span > < span class = "o" > =< / span > < span class = "o" > -< / span > < span class = "mf" > 0.5< / span >
2024-10-08 10:03:58 +00:00
< span class = "gp" > > > > < / span > < span class = "n" > max_action< / span > < span class = "o" > =< / span > < span class = "n" > np< / span > < span class = "o" > .< / span > < span class = "n" > array< / span > < span class = "p" > ([< / span > < span class = "mf" > 0.0< / span > < span class = "p" > ,< / span > < span class = "mf" > 0.5< / span > < span class = "p" > ,< / span > < span class = "mf" > 0.75< / span > < span class = "p" > ],< / span > < span class = "n" > dtype< / span > < span class = "o" > =< / span > < span class = "n" > np< / span > < span class = "o" > .< / span > < span class = "n" > float32< / span > < span class = "p" > )< / span >
2023-01-20 14:42:12 +00:00
< span class = "gp" > > > > < / span > < span class = "n" > wrapped_env< / span > < span class = "o" > =< / span > < span class = "n" > RescaleAction< / span > < span class = "p" > (< / span > < span class = "n" > env< / span > < span class = "p" > ,< / span > < span class = "n" > min_action< / span > < span class = "o" > =< / span > < span class = "n" > min_action< / span > < span class = "p" > ,< / span > < span class = "n" > max_action< / span > < span class = "o" > =< / span > < span class = "n" > max_action< / span > < span class = "p" > )< / span >
< span class = "gp" > > > > < / span > < span class = "n" > wrapped_env_obs< / span > < span class = "p" > ,< / span > < span class = "n" > _< / span > < span class = "p" > ,< / span > < span class = "n" > _< / span > < span class = "p" > ,< / span > < span class = "n" > _< / span > < span class = "p" > ,< / span > < span class = "n" > _< / span > < span class = "o" > =< / span > < span class = "n" > wrapped_env< / span > < span class = "o" > .< / span > < span class = "n" > step< / span > < span class = "p" > (< / span > < span class = "n" > max_action< / span > < span class = "p" > )< / span >
2024-10-08 10:03:58 +00:00
< span class = "gp" > > > > < / span > < span class = "n" > np< / span > < span class = "o" > .< / span > < span class = "n" > all< / span > < span class = "p" > (< / span > < span class = "n" > obs< / span > < span class = "o" > ==< / span > < span class = "n" > wrapped_env_obs< / span > < span class = "p" > )< / span >
< span class = "go" > np.True_< / span >
2022-10-12 15:02:09 +00:00
< / pre > < / div >
< / div >
2024-10-08 10:03:58 +00:00
< dl class = "simple" >
< dt > Change logs:< / dt > < dd > < ul class = "simple" >
< li > < p > v0.15.4 - Initially added< / p > < / li >
< / ul >
< / dd >
< / dl >
2022-10-12 15:02:09 +00:00
< dl class = "field-list simple" >
< dt class = "field-odd" > Parameters< span class = "colon" > :< / span > < / dt >
< dd class = "field-odd" > < ul class = "simple" >
2024-10-08 10:03:58 +00:00
< li > < p > < strong > env< / strong > (< a class = "reference internal" href = "../../env/#gymnasium.Env" title = "gymnasium.Env" > < em > Env< / em > < / a > ) – The environment to wrap< / p > < / li >
2022-10-12 15:02:09 +00:00
< li > < p > < strong > min_action< / strong > (< em > float< / em > < em > , < / em > < em > int< / em > < em > or < / em > < em > np.ndarray< / em > ) – The min values for each action. This may be a numpy array or a scalar.< / p > < / li >
< li > < p > < strong > max_action< / strong > (< em > float< / em > < em > , < / em > < em > int< / em > < em > or < / em > < em > np.ndarray< / em > ) – The max values for each action. This may be a numpy array or a scalar.< / p > < / li >
< / ul >
< / dd >
< / dl >
< / dd > < / dl >
2024-10-08 10:03:58 +00:00
< dl class = "py class" >
< dt class = "sig sig-object py" id = "gymnasium.wrappers.StickyAction" >
2025-02-26 11:56:33 +00:00
< em class = "property" > < span class = "pre" > class< / span > < span class = "w" > < / span > < / em > < span class = "sig-prename descclassname" > < span class = "pre" > gymnasium.wrappers.< / span > < / span > < span class = "sig-name descname" > < span class = "pre" > StickyAction< / span > < / span > < span class = "sig-paren" > (< / span > < em class = "sig-param" > < span class = "n" > < span class = "pre" > env< / span > < / span > < span class = "p" > < span class = "pre" > :< / span > < / span > < span class = "w" > < / span > < span class = "n" > < span class = "pre" > gym.Env< / span > < span class = "p" > < span class = "pre" > [< / span > < / span > < span class = "pre" > ObsType< / span > < span class = "p" > < span class = "pre" > ,< / span > < / span > < span class = "w" > < / span > < span class = "pre" > ActType< / span > < span class = "p" > < span class = "pre" > ]< / span > < / span > < / span > < / em > , < em class = "sig-param" > < span class = "n" > < span class = "pre" > repeat_action_probability< / span > < / span > < span class = "p" > < span class = "pre" > :< / span > < / span > < span class = "w" > < / span > < span class = "n" > < span class = "pre" > float< / span > < / span > < / em > , < em class = "sig-param" > < span class = "n" > < span class = "pre" > repeat_action_duration< / 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" > tuple< / 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 = "pre" > int< / 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" > 1< / span > < / span > < / em > < span class = "sig-paren" > )< / span > < a class = "reference internal" href = "../../../_modules/gymnasium/wrappers/stateful_action/#StickyAction" > < span class = "viewcode-link" > < span class = "pre" > [source]< / span > < / span > < / a > < a class = "headerlink" href = "#gymnasium.wrappers.StickyAction" title = "Link to this definition" > ¶< / a > < / dt >
2024-10-08 10:03:58 +00:00
< dd > < p > Adds a probability that the action is repeated for the same < code class = "docutils literal notranslate" > < span class = "pre" > step< / span > < / code > function.< / p >
< p > This wrapper follows the implementation proposed by < a class = "reference external" href = "https://arxiv.org/pdf/1709.06009.pdf" > Machado et al., 2018< / a >
2025-02-26 11:56:33 +00:00
in Section 5.2 on page 12, and adds the possibility to repeat the action for
more than one step.< / p >
2024-10-08 10:03:58 +00:00
< p > No vector version of the wrapper exists.< / p >
< p class = "rubric" > Example< / p >
2025-02-26 11:56:33 +00:00
< div class = "doctest highlight-default notranslate" > < div class = "highlight" > < pre > < span > < / span > < span class = "gp" > > > > < / span > < span class = "kn" > import< / span > < span class = "w" > < / span > < span class = "nn" > gymnasium< / span > < span class = "w" > < / span > < span class = "k" > as< / span > < span class = "w" > < / span > < span class = "nn" > gym< / span >
2024-10-08 10:03:58 +00:00
< span class = "gp" > > > > < / span > < span class = "n" > env< / span > < span class = "o" > =< / span > < span class = "n" > gym< / span > < span class = "o" > .< / span > < span class = "n" > make< / span > < span class = "p" > (< / span > < span class = "s2" > " CartPole-v1" < / span > < span class = "p" > )< / span >
< span class = "gp" > > > > < / span > < span class = "n" > env< / span > < span class = "o" > =< / span > < span class = "n" > StickyAction< / span > < span class = "p" > (< / span > < span class = "n" > env< / span > < span class = "p" > ,< / span > < span class = "n" > repeat_action_probability< / span > < span class = "o" > =< / span > < span class = "mf" > 0.9< / span > < span class = "p" > )< / span >
< span class = "gp" > > > > < / span > < span class = "n" > env< / span > < span class = "o" > .< / span > < span class = "n" > reset< / span > < span class = "p" > (< / span > < span class = "n" > seed< / span > < span class = "o" > =< / span > < span class = "mi" > 123< / span > < span class = "p" > )< / span >
< span class = "go" > (array([ 0.01823519, -0.0446179 , -0.02796401, -0.03156282], dtype=float32), {})< / span >
< span class = "gp" > > > > < / span > < span class = "n" > env< / span > < span class = "o" > .< / span > < span class = "n" > step< / span > < span class = "p" > (< / span > < span class = "mi" > 1< / span > < span class = "p" > )< / span >
< span class = "go" > (array([ 0.01734283, 0.15089367, -0.02859527, -0.33293587], dtype=float32), 1.0, False, False, {})< / span >
< span class = "gp" > > > > < / span > < span class = "n" > env< / span > < span class = "o" > .< / span > < span class = "n" > step< / span > < span class = "p" > (< / span > < span class = "mi" > 0< / span > < span class = "p" > )< / span >
< span class = "go" > (array([ 0.0203607 , 0.34641072, -0.03525399, -0.6344974 ], dtype=float32), 1.0, False, False, {})< / span >
< span class = "gp" > > > > < / span > < span class = "n" > env< / span > < span class = "o" > .< / span > < span class = "n" > step< / span > < span class = "p" > (< / span > < span class = "mi" > 1< / span > < span class = "p" > )< / span >
< span class = "go" > (array([ 0.02728892, 0.5420062 , -0.04794393, -0.9380709 ], dtype=float32), 1.0, False, False, {})< / span >
< span class = "gp" > > > > < / span > < span class = "n" > env< / span > < span class = "o" > .< / span > < span class = "n" > step< / span > < span class = "p" > (< / span > < span class = "mi" > 0< / span > < span class = "p" > )< / span >
< span class = "go" > (array([ 0.03812904, 0.34756234, -0.06670535, -0.6608303 ], dtype=float32), 1.0, False, False, {})< / span >
< / pre > < / div >
< / div >
< dl class = "simple" >
< dt > Change logs:< / dt > < dd > < ul class = "simple" >
< li > < p > v1.0.0 - Initially added< / p > < / li >
2025-02-26 11:56:33 +00:00
< li > < p > v1.1.0 - Add < cite > repeat_action_duration< / cite > argument for dynamic number of sticky actions< / p > < / li >
2024-10-08 10:03:58 +00:00
< / ul >
< / dd >
< / dl >
< dl class = "field-list simple" >
< dt class = "field-odd" > Parameters< span class = "colon" > :< / span > < / dt >
< dd class = "field-odd" > < ul class = "simple" >
2025-02-26 11:56:33 +00:00
< li > < p > < strong > env< / strong > (< a class = "reference internal" href = "../../env/#gymnasium.Env" title = "gymnasium.Env" > < em > Env< / em > < / a > ) – the wrapped environment,< / p > < / li >
< li > < p > < strong > repeat_action_probability< / strong > (< em > int< / em > < em > | < / em > < em > float< / em > ) – a probability of repeating the old action,< / p > < / li >
< li > < p > < strong > repeat_action_duration< / strong > (< em > int< / em > < em > | < / em > < em > tuple< / em > < em > [< / em > < em > int< / em > < em > , < / em > < em > int< / em > < em > ]< / em > ) – the number of steps
the action is repeated. It can be either an int (for deterministic
repeats) or a tuple[int, int] for a range of stochastic number of repeats.< / p > < / li >
2024-10-08 10:03:58 +00:00
< / ul >
< / dd >
< / dl >
< / dd > < / dl >
2022-10-12 15:02:09 +00:00
< / section >
< / section >
2023-03-24 17:29:47 +00:00
< / article >
< / div >
< footer >
< div class = "related-pages" >
< a class = "next-page" href = "../observation_wrappers/" >
2022-10-12 15:02:09 +00:00
< div class = "page-info" >
< div class = "context" >
< span > Next< / span >
< / div >
< div class = "title" > Observation Wrappers< / div >
< / div >
2023-03-24 17:29:47 +00:00
< svg class = "furo-related-icon" >
< use href = "#svg-arrow-right" > < / use >
< / svg >
2022-10-12 15:02:09 +00:00
< / a >
< a class = "prev-page" href = "../misc_wrappers/" >
2023-03-24 17:29:47 +00:00
< svg class = "furo-related-icon" >
< use href = "#svg-arrow-right" > < / use >
< / svg >
2022-10-12 15:02:09 +00:00
< div class = "page-info" >
< div class = "context" >
< span > Previous< / span >
< / div >
< div class = "title" > Misc Wrappers< / div >
< / div >
< / a >
2023-03-24 17:29:47 +00:00
< / div >
< div class = "bottom-of-page" >
< div class = "left-details" >
< div class = "copyright" >
2025-02-26 11:56:33 +00:00
Copyright © 2025 Farama Foundation
2023-03-24 17:29:47 +00:00
< / div >
<!--
2022-10-12 15:02:09 +00:00
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 >
2022-10-15 15:13:56 +00:00
-->
2023-03-24 17:29:47 +00:00
< / div >
< div class = "right-details" >
< div class = "icons" >
2023-07-14 22:50:55 +00:00
< a class = "muted-link" href = "https://github.com/Farama-Foundation/Gymnasium/"
aria-label="On GitHub">
< svg stroke = "currentColor" fill = "currentColor" stroke-width = "0" viewBox = "0 0 16 16" >
< path fill-rule = "evenodd"
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z">
< / path >
< / svg >
< / a >
2023-03-24 17:29:47 +00:00
< / div >
2022-10-12 15:02:09 +00:00
< / div >
< / div >
2023-03-24 17:29:47 +00:00
< / footer >
< / div >
< aside class = "toc-drawer" >
2022-10-12 15:02:09 +00:00
2023-03-24 17:29:47 +00:00
< 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 >
2022-10-12 15:02:09 +00:00
< li > < a class = "reference internal" href = "#" > Action Wrappers< / a > < ul >
2022-12-12 13:31:00 +00:00
< li > < a class = "reference internal" href = "#base-class" > Base Class< / a > < ul >
< li > < a class = "reference internal" href = "#gymnasium.ActionWrapper" > < code class = "docutils literal notranslate" > < span class = "pre" > ActionWrapper< / span > < / code > < / a > < ul >
< li > < a class = "reference internal" href = "#gymnasium.ActionWrapper.action" > < code class = "docutils literal notranslate" > < span class = "pre" > ActionWrapper.action()< / span > < / code > < / a > < / li >
2022-10-12 15:02:09 +00:00
< / ul >
< / li >
< / ul >
< / li >
2022-12-12 13:31:00 +00:00
< li > < a class = "reference internal" href = "#available-action-wrappers" > Available Action Wrappers< / a > < ul >
2024-10-08 10:03:58 +00:00
< li > < a class = "reference internal" href = "#gymnasium.wrappers.TransformAction" > < code class = "docutils literal notranslate" > < span class = "pre" > TransformAction< / span > < / code > < / a > < / li >
2022-12-12 13:31:00 +00:00
< li > < a class = "reference internal" href = "#gymnasium.wrappers.ClipAction" > < code class = "docutils literal notranslate" > < span class = "pre" > ClipAction< / span > < / code > < / a > < / li >
2022-10-12 15:02:09 +00:00
< li > < a class = "reference internal" href = "#gymnasium.wrappers.RescaleAction" > < code class = "docutils literal notranslate" > < span class = "pre" > RescaleAction< / span > < / code > < / a > < / li >
2024-10-08 10:03:58 +00:00
< li > < a class = "reference internal" href = "#gymnasium.wrappers.StickyAction" > < code class = "docutils literal notranslate" > < span class = "pre" > StickyAction< / span > < / code > < / a > < / li >
2022-10-12 15:02:09 +00:00
< / ul >
< / li >
< / ul >
< / li >
< / ul >
2023-03-24 17:29:47 +00:00
< / div >
2022-10-12 15:02:09 +00:00
< / div >
< / div >
2023-03-24 17:29:47 +00:00
< / aside >
< / div >
2022-10-12 15:02:09 +00:00
< / div >
< / div >
< script >
2022-12-12 13:31:00 +00:00
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")) {
2023-01-20 14:42:12 +00:00
menuBtn.setAttribute("aria-expanded", "false");
menuContainer.setAttribute("aria-hidden", "true");
2022-12-12 13:31:00 +00:00
} else {
2023-01-20 14:42:12 +00:00
menuBtn.setAttribute("aria-expanded", "true");
menuContainer.setAttribute("aria-hidden", "false");
2022-12-12 13:31:00 +00:00
}
2022-10-12 15:02:09 +00:00
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 >
2024-10-08 10:03:58 +00:00
< script async src = "https://www.googletagmanager.com/gtag/js?id=G-6H9C8TWXZ8" > < / script >
< script >
const enableGtag = () => {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-6H9C8TWXZ8');
}
(() => {
if (!localStorage.getItem("acceptedCookieAlert")) {
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.`;
containerElem.appendChild(textElem);
const declineBtn = Object.assign(document.createElement("button"),
{
innerText: "Deny",
className: "farama-btn cookie-alert__button",
id: "cookie-alert__decline",
2022-10-13 10:54:57 +00:00
}
2024-10-08 10:03:58 +00:00
);
declineBtn.addEventListener("click", () => {
localStorage.setItem("acceptedCookieAlert", false);
boxElem.remove();
});
2022-10-13 10:54:57 +00:00
2024-10-08 10:03:58 +00:00
const acceptBtn = Object.assign(document.createElement("button"),
{
innerText: "Allow",
className: "farama-btn cookie-alert__button",
id: "cookie-alert__accept",
}
);
acceptBtn.addEventListener("click", () => {
localStorage.setItem("acceptedCookieAlert", true);
boxElem.remove();
enableGtag();
});
2022-10-13 10:54:57 +00:00
2024-10-08 10:03:58 +00:00
containerElem.appendChild(declineBtn);
containerElem.appendChild(acceptBtn);
boxElem.appendChild(containerElem);
document.body.appendChild(boxElem);
} else if (localStorage.getItem("acceptedCookieAlert") === "true") {
enableGtag();
}
})()
2022-10-13 10:54:57 +00:00
< / script >
2022-10-12 15:02:09 +00:00
2025-02-26 11:56:33 +00:00
< script src = "../../../_static/documentation_options.js?v=25d39d6f" > < / script >
2024-10-08 10:03:58 +00:00
< script src = "../../../_static/doctools.js?v=9a2dae69" > < / script >
< script src = "../../../_static/sphinx_highlight.js?v=dc90522c" > < / script >
< script src = "../../../_static/scripts/furo.js?v=7660844c" > < / script >
2022-10-21 15:39:00 +00:00
2022-12-12 13:31:00 +00:00
< script >
2024-10-08 10:03:58 +00:00
const createProjectsList = (projects, displayImages) => {
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 (displayImages) {
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);
}
return ulElem;
}
2023-07-14 22:50:55 +00:00
// Create menu with Farama projects by using the API at farama.org/api/projects.json
2022-12-12 13:31:00 +00:00
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 = {
2024-10-08 10:03:58 +00:00
"Core Projects": [],
"Mature Projects": {
"Documentation": [],
"Repositories": [],
},
"Incubating Projects": {
"Documentation": [],
"Repositories": [],
},
2022-12-12 13:31:00 +00:00
"Foundation": [
{
name: "About",
link: "https://farama.org/about"
},
{
name: "Standards",
link: "https://farama.org/project_standards",
},
{
name: "Donate",
link: "https://farama.org/donations"
}
]
}
2024-10-08 10:03:58 +00:00
// Categorize projects
2022-12-12 13:31:00 +00:00
Object.keys(jsonResponse).forEach(key => {
projectJson = jsonResponse[key];
if (projectJson.website !== null) {
projectJson.link = projectJson.website;
} else {
projectJson.link = projectJson.github;
2024-10-08 10:03:58 +00:00
}
if (projectJson.type === "core") {
sections["Core Projects"].push(projectJson)
} else if (projectJson.type == "mature") {
if (projectJson.website !== null) {
sections["Mature Projects"]["Documentation"].push(projectJson)
} else {
sections["Mature Projects"]["Repositories"].push(projectJson)
}
} else {
if (projectJson.website !== null) {
sections["Incubating Projects"]["Documentation"].push(projectJson)
} else {
sections["Incubating Projects"]["Repositories"].push(projectJson)
}
2022-12-12 13:31:00 +00:00
}
})
const menuContainer = document.querySelector(".farama-header-menu__body");
Object.keys(sections).forEach((key, i) => {
const sectionElem = Object.assign(
document.createElement('div'), {
className:'farama-header-menu__section',
}
)
sectionElem.appendChild(Object.assign(document.createElement('span'),
{
className:'farama-header-menu__section-title' ,
innerText: key
}
))
2024-10-08 10:03:58 +00:00
// is not a list
if (sections[key].constructor !== Array) {
const subSections = sections[key];
const subSectionContainerElem = Object.assign(
document.createElement('div'), {
className:'farama-header-menu__subsections-container',
style: 'display: flex'
}
)
Object.keys(subSections).forEach((subKey, i) => {
const subSectionElem = Object.assign(
document.createElement('div'), {
className:'farama-header-menu__subsection',
}
)
subSectionElem.appendChild(Object.assign(document.createElement('span'),
2022-12-12 13:31:00 +00:00
{
2024-10-08 10:03:58 +00:00
className:'farama-header-menu__subsection-title' ,
innerText: subKey
2022-12-12 13:31:00 +00:00
}
2024-10-08 10:03:58 +00:00
))
const ulElem = createProjectsList(subSections[subKey], key !== 'Foundation');
subSectionElem.appendChild(ulElem);
subSectionContainerElem.appendChild(subSectionElem);
})
sectionElem.appendChild(subSectionContainerElem);
} else {
const projects = sections[key];
const ulElem = createProjectsList(projects, true);
sectionElem.appendChild(ulElem);
2022-12-12 13:31:00 +00:00
}
menuContainer.appendChild(sectionElem)
});
}
xhr.onerror = function() {
console.error("Unable to load projects");
};
xhr.send();
< / script >
2022-10-25 11:10:26 +00:00
< script >
const versioningConfig = {
githubUser: 'Farama-Foundation',
githubRepo: 'Gymnasium',
};
2023-01-20 14:42:12 +00:00
fetch('/main/_static/versioning/versioning_menu.html').then(response => {
2022-10-25 11:10:26 +00:00
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);
}
});
2023-03-24 17:29:47 +00:00
< / script >
< / body >
2022-10-12 15:02:09 +00:00
< / html >