Merge pull request #3 from pseudo-rnd-thoughts/rename

Renames Gym to Gymnasium
This commit is contained in:
Mark Towers
2022-09-08 13:05:14 +01:00
committed by GitHub
291 changed files with 1554 additions and 1473 deletions

View File

@@ -15,7 +15,7 @@ Please try to provide a minimal example to reproduce the bug. Error messages and
**System Info**
Describe the characteristic of your environment:
* Describe how Gym was installed (pip, docker, source, ...)
* Describe how Gymnasium was installed (pip, docker, source, ...)
* What OS/version of Linux you're using. Note that while we will accept PRs to improve Window's support, we do not officially support it.
* Python version

View File

@@ -12,6 +12,6 @@ jobs:
- run: |
docker build -f py.Dockerfile \
--build-arg PYTHON_VERSION=${{ matrix.python-version }} \
--tag gym-docker .
--tag gymnasium-docker .
- name: Run tests
run: docker run gym-docker pytest
run: docker run gymnasium-docker pytest

View File

@@ -15,7 +15,7 @@ repos:
hooks:
- id: flake8
args:
- '--per-file-ignores=*/__init__.py:F401 gym/envs/registration.py:E704'
- '--per-file-ignores=*/__init__.py:F401 gymnasium/envs/registration.py:E704'
- --ignore=E203,W503,E741
- --max-complexity=30
- --max-line-length=456
@@ -30,7 +30,7 @@ repos:
rev: 6.1.1 # pick a git hash / tag to point to
hooks:
- id: pydocstyle
exclude: ^(gym/version.py)|(gym/envs/)|(tests/)
exclude: ^(gymnasium/version.py)|(gymnasium/envs/)|(tests/)
args:
- --source
- --explain

View File

@@ -1,21 +1,15 @@
# Gym Contribution Guidelines
# Gymnasium Contribution Guidelines
At this time we are currently accepting the current forms of contributions:
- Bug reports (keep in mind that changing environment behavior should be minimized as that requires releasing a new version of the environment and makes results hard to compare across versions)
- Pull requests for bug fixes
- Documentation improvements
- Features
Notably, we are not accepting these forms of contributions:
- New environments
- New features
This may change in the future.
If you wish to make a Gym environment, follow the instructions in [Creating Environments](https://github.com/openai/gym/blob/master/docs/creating_environments.md). When your environment works, you can make a PR to add it to the bottom of the [List of Environments](https://github.com/openai/gym/blob/master/docs/third_party_environments.md).
Edit July 27, 2021: Please see https://github.com/openai/gym/issues/2259 for new contributing standards
# Development
This section contains technical instructions & hints for the contributors.
@@ -33,7 +27,7 @@ the list of included, excluded and strict files can be found in pyproject.toml (
To run `pyright` for the project, run the pre-commit process (`pre-commit run --all-files`) or `pyright`
## Git hooks
The CI will run several checks on the new code pushed to the Gym repository. These checks can also be run locally without waiting for the CI by following the steps below:
The CI will run several checks on the new code pushed to the Gymnasium repository. These checks can also be run locally without waiting for the CI by following the steps below:
1. [install `pre-commit`](https://pre-commit.com/#install),
2. Install the Git hooks by running `pre-commit install`.

View File

@@ -4,9 +4,9 @@
### Due to issues with the domain registration, the documentation has been moved to [https://www.gymlibrary.dev/](https://www.gymlibrary.dev/) as opposed to the old .ml address.
## Gym
## Gymnasium
Gym is an open source Python library for developing and comparing reinforcement learning algorithms by providing a standard API to communicate between learning algorithms and environments, as well as a standard set of environments compliant with that API. Since its release, Gym's API has become the field standard for doing this.
Gymnasium is an open source Python library for developing and comparing reinforcement learning algorithms by providing a standard API to communicate between learning algorithms and environments, as well as a standard set of environments compliant with that API. Since its release, Gym's API has become the field standard for doing this.
Gym documentation website is at [https://www.gymlibrary.dev/](https://www.gymlibrary.dev/), and you can propose fixes and changes to it [here](https://github.com/Farama-Foundation/gym-docs).
@@ -25,13 +25,13 @@ We support Python 3.7, 3.8, 3.9 and 3.10 on Linux and macOS. We will accept PRs
The Gym API's API models environments as simple Python `env` classes. Creating environment instances and interacting with them is very simple- here's an example using the "CartPole-v1" environment:
```python
import gym
import gymnasium as gym
env = gym.make("CartPole-v1")
observation, info = env.reset(seed=42)
for _ in range(1000):
action = env.action_space.sample()
observation, reward, terminated, truncarted, info = env.step(action)
observation, reward, terminated, truncated, info = env.step(action)
if terminated or truncated:
observation, info = env.reset()
@@ -43,7 +43,7 @@ env.close()
* [Stable Baselines 3](https://github.com/DLR-RM/stable-baselines3) is a learning library based on the Gym API. It is designed to cater to complete beginners in the field who want to start learning things quickly.
* [RL Baselines3 Zoo](https://github.com/DLR-RM/rl-baselines3-zoo) builds upon SB3, containing optimal hyperparameters for Gym environments as well as code to easily find new ones.
* [Tianshou](https://github.com/thu-ml/tianshou) is a learning library that's geared towards very experienced users and is design to allow for ease in complex algorithm modifications.
* [RLlib](https://docs.ray.io/en/latest/rllib/index.html) is a learning library that allows for distributed training and inferencing and supports an extraordinarily large number of features throughout the reinforcement learning space.
* [RLlib](https://docs.ray.io/en/latest/rllib/index.html) is a learning library that allows for distributed training and inference and supports an extraordinarily large number of features throughout the reinforcement learning space.
* [PettingZoo](https://github.com/Farama-Foundation/PettingZoo) is like Gym, but for environments with multiple agents.
## Environment Versioning
@@ -52,8 +52,8 @@ Gym keeps strict versioning for reproducibility reasons. All environments end in
## MuJoCo Environments
The latest "\_v4" and future versions of the MuJoCo environments will no longer depend on `mujoco-py`. Instead `mujoco` will be the required dependency for future gym MuJoCo environment versions. Old gym MuJoCo environment versions that depend on `mujoco-py` will still be kept but unmaintained.
To install the dependencies for the latest gym MuJoCo environments use `pip install gym[mujoco]`. Dependencies for old MuJoCo environments can still be installed by `pip install gym[mujoco_py]`.
The latest "\_v4" and future versions of the MuJoCo environments will no longer depend on `mujoco-py`. Instead `mujoco` will be the required dependency for future gymnasiumMuJoCo environment versions. Old gymnasiumMuJoCo environment versions that depend on `mujoco-py` will still be kept but unmaintained.
To install the dependencies for the latest gymnasium MuJoCo environments use `pip install gym[mujoco]`. Dependencies for old MuJoCo environments can still be installed by `pip install gym[mujoco_py]`.
## Citation
@@ -70,4 +70,4 @@ A whitepaper from when Gym just came out is available https://arxiv.org/pdf/1606
## Release Notes
There used to be release notes for all the new Gym versions here. New release notes are being moved to [releases page](https://github.com/openai/gym/releases) on GitHub, like most other libraries do. Old notes can be viewed [here](https://github.com/openai/gym/blob/31be35ecd460f670f0c4b653a14c9996b7facc6c/README.rst).
There used to be release notes for all the new Gym versions here. New release notes are being moved to [releases page](https://github.com/Farama-Foundation/Gymnasium/releases) on GitHub, like most other libraries do.

View File

@@ -1,3 +0,0 @@
from gym.envs.box2d.bipedal_walker import BipedalWalker, BipedalWalkerHardcore
from gym.envs.box2d.car_racing import CarRacing
from gym.envs.box2d.lunar_lander import LunarLander, LunarLanderContinuous

View File

@@ -1,5 +0,0 @@
from gym.envs.classic_control.acrobot import AcrobotEnv
from gym.envs.classic_control.cartpole import CartPoleEnv
from gym.envs.classic_control.continuous_mountain_car import Continuous_MountainCarEnv
from gym.envs.classic_control.mountain_car import MountainCarEnv
from gym.envs.classic_control.pendulum import PendulumEnv

View File

@@ -1,19 +0,0 @@
from gym.envs.mujoco.mujoco_env import MujocoEnv, MuJocoPyEnv # isort:skip
from gym.envs.mujoco.mujoco_rendering import ( # isort:skip
RenderContextOffscreen,
Viewer,
)
# ^^^^^ so that user gets the correct error
# message if mujoco is not installed correctly
from gym.envs.mujoco.ant import AntEnv
from gym.envs.mujoco.half_cheetah import HalfCheetahEnv
from gym.envs.mujoco.hopper import HopperEnv
from gym.envs.mujoco.humanoid import HumanoidEnv
from gym.envs.mujoco.humanoidstandup import HumanoidStandupEnv
from gym.envs.mujoco.inverted_double_pendulum import InvertedDoublePendulumEnv
from gym.envs.mujoco.inverted_pendulum import InvertedPendulumEnv
from gym.envs.mujoco.pusher import PusherEnv
from gym.envs.mujoco.reacher import ReacherEnv
from gym.envs.mujoco.swimmer import SwimmerEnv
from gym.envs.mujoco.walker2d import Walker2dEnv

View File

@@ -1,4 +0,0 @@
from gym.envs.toy_text.blackjack import BlackjackEnv
from gym.envs.toy_text.cliffwalking import CliffWalkingEnv
from gym.envs.toy_text.frozen_lake import FrozenLakeEnv
from gym.envs.toy_text.taxi import TaxiEnv

View File

@@ -1,23 +0,0 @@
"""Module for gym vector utils."""
from gym.vector.utils.misc import CloudpickleWrapper, clear_mpi_env_vars
from gym.vector.utils.numpy_utils import concatenate, create_empty_array
from gym.vector.utils.shared_memory import (
create_shared_memory,
read_from_shared_memory,
write_to_shared_memory,
)
from gym.vector.utils.spaces import _BaseGymSpaces # pyright: reportPrivateUsage=false
from gym.vector.utils.spaces import BaseGymSpaces, batch_space, iterate
__all__ = [
"CloudpickleWrapper",
"clear_mpi_env_vars",
"concatenate",
"create_empty_array",
"create_shared_memory",
"read_from_shared_memory",
"write_to_shared_memory",
"BaseGymSpaces",
"batch_space",
"iterate",
]

View File

@@ -1,23 +0,0 @@
"""Module of wrapper classes."""
from gym import error
from gym.wrappers.atari_preprocessing import AtariPreprocessing
from gym.wrappers.autoreset import AutoResetWrapper
from gym.wrappers.clip_action import ClipAction
from gym.wrappers.filter_observation import FilterObservation
from gym.wrappers.flatten_observation import FlattenObservation
from gym.wrappers.frame_stack import FrameStack, LazyFrames
from gym.wrappers.gray_scale_observation import GrayScaleObservation
from gym.wrappers.human_rendering import HumanRendering
from gym.wrappers.normalize import NormalizeObservation, NormalizeReward
from gym.wrappers.order_enforcing import OrderEnforcing
from gym.wrappers.record_episode_statistics import RecordEpisodeStatistics
from gym.wrappers.record_video import RecordVideo, capped_cubic_video_schedule
from gym.wrappers.render_collection import RenderCollection
from gym.wrappers.rescale_action import RescaleAction
from gym.wrappers.resize_observation import ResizeObservation
from gym.wrappers.step_api_compatibility import StepAPICompatibility
from gym.wrappers.time_aware_observation import TimeAwareObservation
from gym.wrappers.time_limit import TimeLimit
from gym.wrappers.transform_observation import TransformObservation
from gym.wrappers.transform_reward import TransformReward
from gym.wrappers.vector_list_info import VectorListInfo

View File

@@ -1,21 +1,21 @@
"""Root __init__ of the gym module setting the __all__ of gym modules."""
"""Root __init__ of the gymnasium module setting the __all__ of gymnasium modules."""
# isort: skip_file
from gym import error
from gym.version import VERSION as __version__
from gymnasium import error
from gymnasium.version import VERSION as __version__
from gym.core import (
from gymnasium.core import (
Env,
Wrapper,
ObservationWrapper,
ActionWrapper,
RewardWrapper,
)
from gym.spaces import Space
from gym.envs import make, spec, register
from gym import logger
from gym import vector
from gym import wrappers
from gymnasium.spaces import Space
from gymnasium.envs import make, spec, register
from gymnasium import logger
from gymnasium import vector
from gymnasium import wrappers
import os
import sys

View File

@@ -15,16 +15,16 @@ from typing import (
import numpy as np
from gym import spaces
from gym.logger import warn
from gym.utils import seeding
from gymnasium import spaces
from gymnasium.logger import warn
from gymnasium.utils import seeding
if TYPE_CHECKING:
from gym.envs.registration import EnvSpec
from gymnasium.envs.registration import EnvSpec
if sys.version_info[0:2] == (3, 6):
warn(
"Gym minimally supports python 3.6 as the python foundation not longer supports the version, please update your version to 3.7+"
"Gymnasium minimally supports python 3.6 as the python foundation not longer supports the version, please update your version to 3.7+"
)
ObsType = TypeVar("ObsType")
@@ -33,7 +33,7 @@ RenderFrame = TypeVar("RenderFrame")
class Env(Generic[ObsType, ActType]):
r"""The main OpenAI Gym class.
r"""The main Gymnasium class.
It encapsulates an environment with arbitrary behind-the-scenes dynamics.
An environment can be partially or fully observed.
@@ -51,7 +51,7 @@ class Env(Generic[ObsType, ActType]):
- :attr:`action_space` - The Space object corresponding to valid actions
- :attr:`observation_space` - The Space object corresponding to valid observations
- :attr:`reward_range` - A tuple corresponding to the minimum and maximum possible rewards
- :attr:`spec` - An environment spec that contains the information used to initialise the environment from `gym.make`
- :attr:`spec` - An environment spec that contains the information used to initialise the environment from `gymnasium.make`
- :attr:`metadata` - The metadata of the environment, i.e. render modes
- :attr:`np_random` - The random number generator for the environment
@@ -188,7 +188,7 @@ class Env(Generic[ObsType, ActType]):
"""Returns the base non-wrapped environment.
Returns:
Env: The base non-wrapped gym.Env instance
Env: The base non-wrapped gymnasium.Env instance
"""
return self
@@ -362,7 +362,7 @@ class ObservationWrapper(Wrapper):
``observation["target_position"] - observation["agent_position"]``. For this, you could implement an
observation wrapper like this::
class RelativePosition(gym.ObservationWrapper):
class RelativePosition(gymnasium.ObservationWrapper):
def __init__(self, env):
super().__init__(env)
self.observation_space = Box(shape=(2,), low=-np.inf, high=np.inf)
@@ -370,7 +370,7 @@ class ObservationWrapper(Wrapper):
def observation(self, obs):
return obs["target"] - obs["agent"]
Among others, Gym provides the observation wrapper :class:`TimeAwareObservation`, which adds information about the
Among others, Gymnasium provides the observation wrapper :class:`TimeAwareObservation`, which adds information about the
index of the timestep to the observation.
"""
@@ -402,7 +402,7 @@ class RewardWrapper(Wrapper):
because it is intrinsic), we want to clip the reward to a range to gain some numerical stability.
To do that, we could, for instance, implement the following wrapper::
class ClipReward(gym.RewardWrapper):
class ClipReward(gymnasium.RewardWrapper):
def __init__(self, env, min_reward, max_reward):
super().__init__(env)
self.min_reward = min_reward
@@ -433,10 +433,10 @@ class ActionWrapper(Wrapper):
In that case, you need to specify the new action space of the wrapper by setting :attr:`self.action_space` in
the :meth:`__init__` method of your wrapper.
Lets say you have an environment with action space of type :class:`gym.spaces.Box`, but you would only like
Lets say you have an environment with action space of type :class:`gymnasium.spaces.Box`, but you would only like
to use a finite subset of actions. Then, you might want to implement the following wrapper::
class DiscreteActions(gym.ActionWrapper):
class DiscreteActions(gymnasium.ActionWrapper):
def __init__(self, env, disc_to_cont):
super().__init__(env)
self.disc_to_cont = disc_to_cont
@@ -446,13 +446,13 @@ class ActionWrapper(Wrapper):
return self.disc_to_cont[act]
if __name__ == "__main__":
env = gym.make("LunarLanderContinuous-v2")
env = gymnasium.make("LunarLanderContinuous-v2")
wrapped_env = DiscreteActions(env, [np.array([1,0]), np.array([-1,0]),
np.array([0,1]), np.array([0,-1])])
print(wrapped_env.action_space) #Discrete(4)
Among others, Gym provides the action wrappers :class:`ClipAction` and :class:`RescaleAction`.
Among others, Gymasnium provides the action wrappers :class:`ClipAction` and :class:`RescaleAction`.
"""
def step(self, action):

View File

@@ -1,5 +1,5 @@
from gym.envs.registration import load_env_plugins as _load_env_plugins
from gym.envs.registration import make, register, registry, spec
from gymnasium.envs.registration import load_env_plugins as _load_env_plugins
from gymnasium.envs.registration import make, register, registry, spec
# Hook to load plugins from entry points
_load_env_plugins()
@@ -10,41 +10,41 @@ _load_env_plugins()
register(
id="CartPole-v0",
entry_point="gym.envs.classic_control.cartpole:CartPoleEnv",
entry_point="gymnasium.envs.classic_control.cartpole:CartPoleEnv",
max_episode_steps=200,
reward_threshold=195.0,
)
register(
id="CartPole-v1",
entry_point="gym.envs.classic_control.cartpole:CartPoleEnv",
entry_point="gymnasium.envs.classic_control.cartpole:CartPoleEnv",
max_episode_steps=500,
reward_threshold=475.0,
)
register(
id="MountainCar-v0",
entry_point="gym.envs.classic_control.mountain_car:MountainCarEnv",
entry_point="gymnasium.envs.classic_control.mountain_car:MountainCarEnv",
max_episode_steps=200,
reward_threshold=-110.0,
)
register(
id="MountainCarContinuous-v0",
entry_point="gym.envs.classic_control.continuous_mountain_car:Continuous_MountainCarEnv",
entry_point="gymnasium.envs.classic_control.continuous_mountain_car:Continuous_MountainCarEnv",
max_episode_steps=999,
reward_threshold=90.0,
)
register(
id="Pendulum-v1",
entry_point="gym.envs.classic_control.pendulum:PendulumEnv",
entry_point="gymnasium.envs.classic_control.pendulum:PendulumEnv",
max_episode_steps=200,
)
register(
id="Acrobot-v1",
entry_point="gym.envs.classic_control.acrobot:AcrobotEnv",
entry_point="gymnasium.envs.classic_control.acrobot:AcrobotEnv",
reward_threshold=-100.0,
max_episode_steps=500,
)
@@ -54,14 +54,14 @@ register(
register(
id="LunarLander-v2",
entry_point="gym.envs.box2d.lunar_lander:LunarLander",
entry_point="gymnasium.envs.box2d.lunar_lander:LunarLander",
max_episode_steps=1000,
reward_threshold=200,
)
register(
id="LunarLanderContinuous-v2",
entry_point="gym.envs.box2d.lunar_lander:LunarLander",
entry_point="gymnasium.envs.box2d.lunar_lander:LunarLander",
kwargs={"continuous": True},
max_episode_steps=1000,
reward_threshold=200,
@@ -69,14 +69,14 @@ register(
register(
id="BipedalWalker-v3",
entry_point="gym.envs.box2d.bipedal_walker:BipedalWalker",
entry_point="gymnasium.envs.box2d.bipedal_walker:BipedalWalker",
max_episode_steps=1600,
reward_threshold=300,
)
register(
id="BipedalWalkerHardcore-v3",
entry_point="gym.envs.box2d.bipedal_walker:BipedalWalker",
entry_point="gymnasium.envs.box2d.bipedal_walker:BipedalWalker",
kwargs={"hardcore": True},
max_episode_steps=2000,
reward_threshold=300,
@@ -84,7 +84,7 @@ register(
register(
id="CarRacing-v2",
entry_point="gym.envs.box2d.car_racing:CarRacing",
entry_point="gymnasium.envs.box2d.car_racing:CarRacing",
max_episode_steps=1000,
reward_threshold=900,
)
@@ -94,13 +94,13 @@ register(
register(
id="Blackjack-v1",
entry_point="gym.envs.toy_text.blackjack:BlackjackEnv",
entry_point="gymnasium.envs.toy_text.blackjack:BlackjackEnv",
kwargs={"sab": True, "natural": False},
)
register(
id="FrozenLake-v1",
entry_point="gym.envs.toy_text.frozen_lake:FrozenLakeEnv",
entry_point="gymnasium.envs.toy_text.frozen_lake:FrozenLakeEnv",
kwargs={"map_name": "4x4"},
max_episode_steps=100,
reward_threshold=0.70, # optimum = 0.74
@@ -108,7 +108,7 @@ register(
register(
id="FrozenLake8x8-v1",
entry_point="gym.envs.toy_text.frozen_lake:FrozenLakeEnv",
entry_point="gymnasium.envs.toy_text.frozen_lake:FrozenLakeEnv",
kwargs={"map_name": "8x8"},
max_episode_steps=200,
reward_threshold=0.85, # optimum = 0.91
@@ -116,12 +116,12 @@ register(
register(
id="CliffWalking-v0",
entry_point="gym.envs.toy_text.cliffwalking:CliffWalkingEnv",
entry_point="gymnasium.envs.toy_text.cliffwalking:CliffWalkingEnv",
)
register(
id="Taxi-v3",
entry_point="gym.envs.toy_text.taxi:TaxiEnv",
entry_point="gymnasium.envs.toy_text.taxi:TaxiEnv",
reward_threshold=8, # optimum = 8.46
max_episode_steps=200,
)
@@ -133,119 +133,119 @@ register(
register(
id="Reacher-v2",
entry_point="gym.envs.mujoco:ReacherEnv",
entry_point="gymnasium.envs.mujoco:ReacherEnv",
max_episode_steps=50,
reward_threshold=-3.75,
)
register(
id="Reacher-v4",
entry_point="gym.envs.mujoco.reacher_v4:ReacherEnv",
entry_point="gymnasium.envs.mujoco.reacher_v4:ReacherEnv",
max_episode_steps=50,
reward_threshold=-3.75,
)
register(
id="Pusher-v2",
entry_point="gym.envs.mujoco:PusherEnv",
entry_point="gymnasium.envs.mujoco:PusherEnv",
max_episode_steps=100,
reward_threshold=0.0,
)
register(
id="Pusher-v4",
entry_point="gym.envs.mujoco.pusher_v4:PusherEnv",
entry_point="gymnasium.envs.mujoco.pusher_v4:PusherEnv",
max_episode_steps=100,
reward_threshold=0.0,
)
register(
id="InvertedPendulum-v2",
entry_point="gym.envs.mujoco:InvertedPendulumEnv",
entry_point="gymnasium.envs.mujoco:InvertedPendulumEnv",
max_episode_steps=1000,
reward_threshold=950.0,
)
register(
id="InvertedPendulum-v4",
entry_point="gym.envs.mujoco.inverted_pendulum_v4:InvertedPendulumEnv",
entry_point="gymnasium.envs.mujoco.inverted_pendulum_v4:InvertedPendulumEnv",
max_episode_steps=1000,
reward_threshold=950.0,
)
register(
id="InvertedDoublePendulum-v2",
entry_point="gym.envs.mujoco:InvertedDoublePendulumEnv",
entry_point="gymnasium.envs.mujoco:InvertedDoublePendulumEnv",
max_episode_steps=1000,
reward_threshold=9100.0,
)
register(
id="InvertedDoublePendulum-v4",
entry_point="gym.envs.mujoco.inverted_double_pendulum_v4:InvertedDoublePendulumEnv",
entry_point="gymnasium.envs.mujoco.inverted_double_pendulum_v4:InvertedDoublePendulumEnv",
max_episode_steps=1000,
reward_threshold=9100.0,
)
register(
id="HalfCheetah-v2",
entry_point="gym.envs.mujoco:HalfCheetahEnv",
entry_point="gymnasium.envs.mujoco:HalfCheetahEnv",
max_episode_steps=1000,
reward_threshold=4800.0,
)
register(
id="HalfCheetah-v3",
entry_point="gym.envs.mujoco.half_cheetah_v3:HalfCheetahEnv",
entry_point="gymnasium.envs.mujoco.half_cheetah_v3:HalfCheetahEnv",
max_episode_steps=1000,
reward_threshold=4800.0,
)
register(
id="HalfCheetah-v4",
entry_point="gym.envs.mujoco.half_cheetah_v4:HalfCheetahEnv",
entry_point="gymnasium.envs.mujoco.half_cheetah_v4:HalfCheetahEnv",
max_episode_steps=1000,
reward_threshold=4800.0,
)
register(
id="Hopper-v2",
entry_point="gym.envs.mujoco:HopperEnv",
entry_point="gymnasium.envs.mujoco:HopperEnv",
max_episode_steps=1000,
reward_threshold=3800.0,
)
register(
id="Hopper-v3",
entry_point="gym.envs.mujoco.hopper_v3:HopperEnv",
entry_point="gymnasium.envs.mujoco.hopper_v3:HopperEnv",
max_episode_steps=1000,
reward_threshold=3800.0,
)
register(
id="Hopper-v4",
entry_point="gym.envs.mujoco.hopper_v4:HopperEnv",
entry_point="gymnasium.envs.mujoco.hopper_v4:HopperEnv",
max_episode_steps=1000,
reward_threshold=3800.0,
)
register(
id="Swimmer-v2",
entry_point="gym.envs.mujoco:SwimmerEnv",
entry_point="gymnasium.envs.mujoco:SwimmerEnv",
max_episode_steps=1000,
reward_threshold=360.0,
)
register(
id="Swimmer-v3",
entry_point="gym.envs.mujoco.swimmer_v3:SwimmerEnv",
entry_point="gymnasium.envs.mujoco.swimmer_v3:SwimmerEnv",
max_episode_steps=1000,
reward_threshold=360.0,
)
register(
id="Swimmer-v4",
entry_point="gym.envs.mujoco.swimmer_v4:SwimmerEnv",
entry_point="gymnasium.envs.mujoco.swimmer_v4:SwimmerEnv",
max_episode_steps=1000,
reward_threshold=360.0,
)
@@ -253,68 +253,68 @@ register(
register(
id="Walker2d-v2",
max_episode_steps=1000,
entry_point="gym.envs.mujoco:Walker2dEnv",
entry_point="gymnasium.envs.mujoco:Walker2dEnv",
)
register(
id="Walker2d-v3",
max_episode_steps=1000,
entry_point="gym.envs.mujoco.walker2d_v3:Walker2dEnv",
entry_point="gymnasium.envs.mujoco.walker2d_v3:Walker2dEnv",
)
register(
id="Walker2d-v4",
max_episode_steps=1000,
entry_point="gym.envs.mujoco.walker2d_v4:Walker2dEnv",
entry_point="gymnasium.envs.mujoco.walker2d_v4:Walker2dEnv",
)
register(
id="Ant-v2",
entry_point="gym.envs.mujoco:AntEnv",
entry_point="gymnasium.envs.mujoco:AntEnv",
max_episode_steps=1000,
reward_threshold=6000.0,
)
register(
id="Ant-v3",
entry_point="gym.envs.mujoco.ant_v3:AntEnv",
entry_point="gymnasium.envs.mujoco.ant_v3:AntEnv",
max_episode_steps=1000,
reward_threshold=6000.0,
)
register(
id="Ant-v4",
entry_point="gym.envs.mujoco.ant_v4:AntEnv",
entry_point="gymnasium.envs.mujoco.ant_v4:AntEnv",
max_episode_steps=1000,
reward_threshold=6000.0,
)
register(
id="Humanoid-v2",
entry_point="gym.envs.mujoco:HumanoidEnv",
entry_point="gymnasium.envs.mujoco:HumanoidEnv",
max_episode_steps=1000,
)
register(
id="Humanoid-v3",
entry_point="gym.envs.mujoco.humanoid_v3:HumanoidEnv",
entry_point="gymnasium.envs.mujoco.humanoid_v3:HumanoidEnv",
max_episode_steps=1000,
)
register(
id="Humanoid-v4",
entry_point="gym.envs.mujoco.humanoid_v4:HumanoidEnv",
entry_point="gymnasium.envs.mujoco.humanoid_v4:HumanoidEnv",
max_episode_steps=1000,
)
register(
id="HumanoidStandup-v2",
entry_point="gym.envs.mujoco:HumanoidStandupEnv",
entry_point="gymnasium.envs.mujoco:HumanoidStandupEnv",
max_episode_steps=1000,
)
register(
id="HumanoidStandup-v4",
entry_point="gym.envs.mujoco.humanoidstandup_v4:HumanoidStandupEnv",
entry_point="gymnasium.envs.mujoco.humanoidstandup_v4:HumanoidStandupEnv",
max_episode_steps=1000,
)

View File

@@ -0,0 +1,3 @@
from gymnasium.envs.box2d.bipedal_walker import BipedalWalker, BipedalWalkerHardcore
from gymnasium.envs.box2d.car_racing import CarRacing
from gymnasium.envs.box2d.lunar_lander import LunarLander, LunarLanderContinuous

View File

@@ -5,10 +5,10 @@ from typing import TYPE_CHECKING, List, Optional
import numpy as np
import gym
from gym import error, spaces
from gym.error import DependencyNotInstalled
from gym.utils import EzPickle
import gymnasium
from gymnasium import error, spaces
from gymnasium.error import DependencyNotInstalled
from gymnasium.utils import EzPickle
try:
import Box2D
@@ -21,7 +21,9 @@ try:
revoluteJointDef,
)
except ImportError:
raise DependencyNotInstalled("box2D is not installed, run `pip install gym[box2d]`")
raise DependencyNotInstalled(
"box2D is not installed, run `pip install gymnasium[box2d]`"
)
if TYPE_CHECKING:
@@ -98,7 +100,7 @@ class ContactDetector(contactListener):
leg.ground_contact = False
class BipedalWalker(gym.Env, EzPickle):
class BipedalWalker(gymnasium.Env, EzPickle):
"""
### Description
This is a simple 4-joint walker robot environment.
@@ -112,7 +114,7 @@ class BipedalWalker(gym.Env, EzPickle):
A heuristic is provided for testing. It's also useful to get demonstrations
to learn from. To run the heuristic:
```
python gym/envs/box2d/bipedal_walker.py
python gymnasium/envs/box2d/bipedal_walker.py
```
### Action Space
@@ -142,8 +144,8 @@ class BipedalWalker(gym.Env, EzPickle):
To use to the _hardcore_ environment, you need to specify the
`hardcore=True` argument like below:
```python
import gym
env = gym.make("BipedalWalker-v3", hardcore=True)
import gymnasium
env = gymnasium.make("BipedalWalker-v3", hardcore=True)
```
### Version History
@@ -611,7 +613,7 @@ class BipedalWalker(gym.Env, EzPickle):
from pygame import gfxdraw
except ImportError:
raise DependencyNotInstalled(
"pygame is not installed, run `pip install gym[box2d]`"
"pygame is not installed, run `pip install gymnasium[box2d]`"
)
if self.screen is None and self.render_mode == "human":
@@ -758,8 +760,8 @@ class BipedalWalkerHardcore:
raise error.Error(
"Error initializing BipedalWalkerHardcore Environment.\n"
"Currently, we do not support initializing this mode of environment by calling the class directly.\n"
"To use this environment, instead create it by specifying the hardcore keyword in gym.make, i.e.\n"
'gym.make("BipedalWalker-v3", hardcore=True)'
"To use this environment, instead create it by specifying the hardcore keyword in gymnasium.make, i.e.\n"
'gymnasium.make("BipedalWalker-v3", hardcore=True)'
)

View File

@@ -12,12 +12,14 @@ import math
import Box2D
import numpy as np
from gym.error import DependencyNotInstalled
from gymnasium.error import DependencyNotInstalled
try:
from Box2D.b2 import fixtureDef, polygonShape, revoluteJointDef
except ImportError:
raise DependencyNotInstalled("box2D is not installed, run `pip install gym[box2d]`")
raise DependencyNotInstalled(
"box2D is not installed, run `pip install gymnasium[box2d]`"
)
SIZE = 0.02

View File

@@ -5,17 +5,19 @@ from typing import Optional, Union
import numpy as np
import gym
from gym import spaces
from gym.envs.box2d.car_dynamics import Car
from gym.error import DependencyNotInstalled, InvalidAction
from gym.utils import EzPickle
import gymnasium
from gymnasium import spaces
from gymnasium.envs.box2d.car_dynamics import Car
from gymnasium.error import DependencyNotInstalled, InvalidAction
from gymnasium.utils import EzPickle
try:
import Box2D
from Box2D.b2 import contactListener, fixtureDef, polygonShape
except ImportError:
raise DependencyNotInstalled("box2D is not installed, run `pip install gym[box2d]`")
raise DependencyNotInstalled(
"box2D is not installed, run `pip install gymnasium[box2d]`"
)
try:
# As pygame is necessary for using the environment (reset and step) even without a render mode
@@ -24,7 +26,7 @@ try:
from pygame import gfxdraw
except ImportError:
raise DependencyNotInstalled(
"pygame is not installed, run `pip install gym[box2d]`"
"pygame is not installed, run `pip install gymnasium[box2d]`"
)
@@ -102,7 +104,7 @@ class FrictionDetector(contactListener):
obj.tiles.remove(tile)
class CarRacing(gym.Env, EzPickle):
class CarRacing(gymnasium.Env, EzPickle):
"""
### Description
The easiest control task to learn from pixels - a top-down
@@ -113,7 +115,7 @@ class CarRacing(gym.Env, EzPickle):
steering wheel position, and gyroscope.
To play yourself (it's rather fast for humans), type:
```
python gym/envs/box2d/car_racing.py
python gymnasium/envs/box2d/car_racing.py
```
Remember: it's a powerful rear-wheel drive car - don't press the accelerator
and turn at the same time.
@@ -157,7 +159,7 @@ class CarRacing(gym.Env, EzPickle):
`domain_randomize` must be `True` on init for this argument to work.
Example usage:
```py
env = gym.make("CarRacing-v1", domain_randomize=True)
env = gymnasium.make("CarRacing-v1", domain_randomize=True)
# normal reset, this changes the colour scheme by default
env.reset()

View File

@@ -6,11 +6,11 @@ from typing import TYPE_CHECKING, Optional
import numpy as np
import gym
from gym import error, spaces
from gym.error import DependencyNotInstalled
from gym.utils import EzPickle, colorize
from gym.utils.step_api_compatibility import step_api_compatibility
import gymnasium
from gymnasium import error, spaces
from gymnasium.error import DependencyNotInstalled
from gymnasium.utils import EzPickle, colorize
from gymnasium.utils.step_api_compatibility import step_api_compatibility
try:
import Box2D
@@ -23,7 +23,9 @@ try:
revoluteJointDef,
)
except ImportError:
raise DependencyNotInstalled("box2d is not installed, run `pip install gym[box2d]`")
raise DependencyNotInstalled(
"box2d is not installed, run `pip install gymnasium[box2d]`"
)
if TYPE_CHECKING:
@@ -72,7 +74,7 @@ class ContactDetector(contactListener):
self.env.legs[i].ground_contact = False
class LunarLander(gym.Env, EzPickle):
class LunarLander(gymnasium.Env, EzPickle):
"""
### Description
This environment is a classic rocket trajectory optimization problem.
@@ -88,7 +90,7 @@ class LunarLander(gym.Env, EzPickle):
To see a heuristic landing, run:
```
python gym/envs/box2d/lunar_lander.py
python gymnasium/envs/box2d/lunar_lander.py
```
<!-- To play yourself, run: -->
<!-- python examples/agents/keyboard_agent.py LunarLander-v2 -->
@@ -139,8 +141,8 @@ class LunarLander(gym.Env, EzPickle):
To use to the _continuous_ environment, you need to specify the
`continuous=True` argument like below:
```python
import gym
env = gym.make(
import gymnasium
env = gymnasium.make(
"LunarLander-v2",
continuous: bool = False,
gravity: float = -10.0,
@@ -605,7 +607,7 @@ class LunarLander(gym.Env, EzPickle):
from pygame import gfxdraw
except ImportError:
raise DependencyNotInstalled(
"pygame is not installed, run `pip install gym[box2d]`"
"pygame is not installed, run `pip install gymnasium[box2d]`"
)
if self.screen is None and self.render_mode == "human":
@@ -800,8 +802,8 @@ class LunarLanderContinuous:
raise error.Error(
"Error initializing LunarLanderContinuous Environment.\n"
"Currently, we do not support initializing this mode of environment by calling the class directly.\n"
"To use this environment, instead create it by specifying the continuous keyword in gym.make, i.e.\n"
'gym.make("LunarLander-v2", continuous=True)'
"To use this environment, instead create it by specifying the continuous keyword in gymnasium.make, i.e.\n"
'gymnasium.make("LunarLander-v2", continuous=True)'
)

View File

@@ -0,0 +1,7 @@
from gymnasium.envs.classic_control.acrobot import AcrobotEnv
from gymnasium.envs.classic_control.cartpole import CartPoleEnv
from gymnasium.envs.classic_control.continuous_mountain_car import (
Continuous_MountainCarEnv,
)
from gymnasium.envs.classic_control.mountain_car import MountainCarEnv
from gymnasium.envs.classic_control.pendulum import PendulumEnv

View File

@@ -4,8 +4,8 @@ from typing import Optional
import numpy as np
from numpy import cos, pi, sin
from gym import core, spaces
from gym.error import DependencyNotInstalled
from gymnasium import core, spaces
from gymnasium.error import DependencyNotInstalled
__copyright__ = "Copyright 2013, RLPy http://acl.mit.edu/RLPy"
__credits__ = [
@@ -20,7 +20,7 @@ __author__ = "Christoph Dann <cdann@cdann.de>"
# SOURCE:
# https://github.com/rlpy/rlpy/blob/master/rlpy/Domains/Acrobot.py
from gym.envs.classic_control import utils
from gymnasium.envs.classic_control import utils
class AcrobotEnv(core.Env):
@@ -97,7 +97,7 @@ class AcrobotEnv(core.Env):
No additional arguments are currently supported.
```
env = gym.make('Acrobot-v1')
env = gymnasium.make('Acrobot-v1')
```
By default, the dynamics of the acrobot follow those described in Sutton and Barto's book
@@ -126,7 +126,7 @@ class AcrobotEnv(core.Env):
- v1: Maximum number of steps increased from 200 to 500. The observation space for v0 provided direct readings of
`theta1` and `theta2` in radians, having a range of `[-pi, pi]`. The v1 observation space as described here provides the
sine and cosine of each angle instead.
- v0: Initial versions release (1.0.0) (removed from gym for v1)
- v0: Initial versions release (1.0.0) (removed from gymnasium for v1)
### References
- Sutton, R. S. (1996). Generalization in Reinforcement Learning: Successful Examples Using Sparse Coarse Coding.
@@ -282,7 +282,7 @@ class AcrobotEnv(core.Env):
from pygame import gfxdraw
except ImportError:
raise DependencyNotInstalled(
"pygame is not installed, run `pip install gym[classic_control]`"
"pygame is not installed, run `pip install gymnasium[classic_control]`"
)
if self.screen is None:

View File

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@@ -8,13 +8,13 @@ from typing import Optional, Union
import numpy as np
import gym
from gym import logger, spaces
from gym.envs.classic_control import utils
from gym.error import DependencyNotInstalled
import gymnasium
from gymnasium import logger, spaces
from gymnasium.envs.classic_control import utils
from gymnasium.error import DependencyNotInstalled
class CartPoleEnv(gym.Env[np.ndarray, Union[int, np.ndarray]]):
class CartPoleEnv(gymnasium.Env[np.ndarray, Union[int, np.ndarray]]):
"""
### Description
@@ -75,7 +75,7 @@ class CartPoleEnv(gym.Env[np.ndarray, Union[int, np.ndarray]]):
### Arguments
```
gym.make('CartPole-v1')
gymnasium.make('CartPole-v1')
```
No additional arguments are currently supported.
@@ -212,7 +212,7 @@ class CartPoleEnv(gym.Env[np.ndarray, Union[int, np.ndarray]]):
from pygame import gfxdraw
except ImportError:
raise DependencyNotInstalled(
"pygame is not installed, run `pip install gym[classic_control]`"
"pygame is not installed, run `pip install gymnasium[classic_control]`"
)
if self.screen is None:

View File

@@ -7,7 +7,7 @@ A merge between two sources:
of Jose Antonio Martin H. (version 1.0), adapted by 'Tom Schaul, tom@idsia.ch'
and then modified by Arnaud de Broissia
* the gym MountainCar environment
* the gymnasium MountainCar environment
itself from
http://incompleteideas.net/sutton/MountainCar/MountainCar1.cp
permalink: https://perma.cc/6Z2N-PFWC
@@ -18,13 +18,13 @@ from typing import Optional
import numpy as np
import gym
from gym import spaces
from gym.envs.classic_control import utils
from gym.error import DependencyNotInstalled
import gymnasium
from gymnasium import spaces
from gymnasium.envs.classic_control import utils
from gymnasium.error import DependencyNotInstalled
class Continuous_MountainCarEnv(gym.Env):
class Continuous_MountainCarEnv(gymnasium.Env):
"""
### Description
@@ -32,7 +32,7 @@ class Continuous_MountainCarEnv(gym.Env):
at the bottom of a sinusoidal valley, with the only possible actions being the accelerations
that can be applied to the car in either direction. The goal of the MDP is to strategically
accelerate the car to reach the goal state on top of the right hill. There are two versions
of the mountain car domain in gym: one with discrete actions and one with continuous.
of the mountain car domain in gymnasium: one with discrete actions and one with continuous.
This version is the one with continuous actions.
This MDP first appeared in [Andrew Moore's PhD Thesis (1990)](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-209.pdf)
@@ -92,7 +92,7 @@ class Continuous_MountainCarEnv(gym.Env):
### Arguments
```
gym.make('MountainCarContinuous-v0')
gymnasium.make('MountainCarContinuous-v0')
```
### Version History
@@ -112,7 +112,7 @@ class Continuous_MountainCarEnv(gym.Env):
self.max_position = 0.6
self.max_speed = 0.07
self.goal_position = (
0.45 # was 0.5 in gym, 0.45 in Arnaud de Broissia's version
0.45 # was 0.5 in gymnasium, 0.45 in Arnaud de Broissia's version
)
self.goal_velocity = goal_velocity
self.power = 0.0015
@@ -194,7 +194,7 @@ class Continuous_MountainCarEnv(gym.Env):
from pygame import gfxdraw
except ImportError:
raise DependencyNotInstalled(
"pygame is not installed, run `pip install gym[classic_control]`"
"pygame is not installed, run `pip install gymnasium[classic_control]`"
)
if self.screen is None:

View File

@@ -7,13 +7,13 @@ from typing import Optional
import numpy as np
import gym
from gym import spaces
from gym.envs.classic_control import utils
from gym.error import DependencyNotInstalled
import gymnasium
from gymnasium import spaces
from gymnasium.envs.classic_control import utils
from gymnasium.error import DependencyNotInstalled
class MountainCarEnv(gym.Env):
class MountainCarEnv(gymnasium.Env):
"""
### Description
@@ -21,7 +21,7 @@ class MountainCarEnv(gym.Env):
at the bottom of a sinusoidal valley, with the only possible actions being the accelerations
that can be applied to the car in either direction. The goal of the MDP is to strategically
accelerate the car to reach the goal state on top of the right hill. There are two versions
of the mountain car domain in gym: one with discrete actions and one with continuous.
of the mountain car domain in gymnasium: one with discrete actions and one with continuous.
This version is the one with discrete actions.
This MDP first appeared in [Andrew Moore's PhD Thesis (1990)](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-209.pdf)
@@ -87,7 +87,7 @@ class MountainCarEnv(gym.Env):
### Arguments
```
gym.make('MountainCar-v0')
gymnasium.make('MountainCar-v0')
```
### Version History
@@ -172,7 +172,7 @@ class MountainCarEnv(gym.Env):
from pygame import gfxdraw
except ImportError:
raise DependencyNotInstalled(
"pygame is not installed, run `pip install gym[classic_control]`"
"pygame is not installed, run `pip install gymnasium[classic_control]`"
)
if self.screen is None:

View File

@@ -5,16 +5,16 @@ from typing import Optional
import numpy as np
import gym
from gym import spaces
from gym.envs.classic_control import utils
from gym.error import DependencyNotInstalled
import gymnasium
from gymnasium import spaces
from gymnasium.envs.classic_control import utils
from gymnasium.error import DependencyNotInstalled
DEFAULT_X = np.pi
DEFAULT_Y = 1.0
class PendulumEnv(gym.Env):
class PendulumEnv(gymnasium.Env):
"""
### Description
@@ -77,7 +77,7 @@ class PendulumEnv(gym.Env):
The default value is g = 10.0 .
```
gym.make('Pendulum-v1', g=9.81)
gymnasium.make('Pendulum-v1', g=9.81)
```
### Version History
@@ -110,7 +110,7 @@ class PendulumEnv(gym.Env):
high = np.array([1.0, 1.0, self.max_speed], dtype=np.float32)
# This will throw a warning in tests/envs/test_envs in utils/env_checker.py as the space is not symmetric
# or normalised as max_torque == 2 by default. Ignoring the issue here as the default settings are too old
# to update to follow the openai gym api
# to update to follow the openai gymnasium api
self.action_space = spaces.Box(
low=-self.max_torque, high=self.max_torque, shape=(1,), dtype=np.float32
)
@@ -168,7 +168,7 @@ class PendulumEnv(gym.Env):
from pygame import gfxdraw
except ImportError:
raise DependencyNotInstalled(
"pygame is not installed, run `pip install gym[classic_control]`"
"pygame is not installed, run `pip install gymnasium[classic_control]`"
)
if self.screen is None:

View File

@@ -0,0 +1,19 @@
from gymnasium.envs.mujoco.mujoco_env import MujocoEnv, MuJocoPyEnv # isort:skip
from gymnasium.envs.mujoco.mujoco_rendering import ( # isort:skip
RenderContextOffscreen,
Viewer,
)
# ^^^^^ so that user gets the correct error
# message if mujoco is not installed correctly
from gymnasium.envs.mujoco.ant import AntEnv
from gymnasium.envs.mujoco.half_cheetah import HalfCheetahEnv
from gymnasium.envs.mujoco.hopper import HopperEnv
from gymnasium.envs.mujoco.humanoid import HumanoidEnv
from gymnasium.envs.mujoco.humanoidstandup import HumanoidStandupEnv
from gymnasium.envs.mujoco.inverted_double_pendulum import InvertedDoublePendulumEnv
from gymnasium.envs.mujoco.inverted_pendulum import InvertedPendulumEnv
from gymnasium.envs.mujoco.pusher import PusherEnv
from gymnasium.envs.mujoco.reacher import ReacherEnv
from gymnasium.envs.mujoco.swimmer import SwimmerEnv
from gymnasium.envs.mujoco.walker2d import Walker2dEnv

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
class AntEnv(MuJocoPyEnv, utils.EzPickle):

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"distance": 4.0,

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MujocoEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MujocoEnv
from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"distance": 4.0,
@@ -143,13 +143,13 @@ class AntEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported in v2 and lower.
```
env = gym.make('Ant-v2')
env = gymnasium.make('Ant-v2')
```
v3 and v4 take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
v3 and v4 take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
```
env = gym.make('Ant-v4', ctrl_cost_weight=0.1, ...)
env = gymnasium.make('Ant-v4', ctrl_cost_weight=0.1, ...)
```
| Parameter | Type | Default |Description |
@@ -166,7 +166,7 @@ class AntEnv(MujocoEnv, utils.EzPickle):
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
* v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0)

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
class HalfCheetahEnv(MuJocoPyEnv, utils.EzPickle):

View File

@@ -2,9 +2,9 @@ __credits__ = ["Rushiv Arora"]
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"distance": 4.0,

View File

@@ -2,9 +2,9 @@ __credits__ = ["Rushiv Arora"]
import numpy as np
from gym import utils
from gym.envs.mujoco import MujocoEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MujocoEnv
from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"distance": 4.0,
@@ -106,13 +106,13 @@ class HalfCheetahEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported in v2 and lower.
```
env = gym.make('HalfCheetah-v2')
env = gymnasium.make('HalfCheetah-v2')
```
v3 and v4 take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
v3 and v4 take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
```
env = gym.make('HalfCheetah-v4', ctrl_cost_weight=0.1, ....)
env = gymnasium.make('HalfCheetah-v4', ctrl_cost_weight=0.1, ....)
```
| Parameter | Type | Default | Description |
@@ -126,7 +126,7 @@ class HalfCheetahEnv(MujocoEnv, utils.EzPickle):
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
* v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0)

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
class HopperEnv(MuJocoPyEnv, utils.EzPickle):

View File

@@ -2,9 +2,9 @@ __credits__ = ["Rushiv Arora"]
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"trackbodyid": 2,

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MujocoEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MujocoEnv
from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"trackbodyid": 2,
@@ -107,13 +107,13 @@ class HopperEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported in v2 and lower.
```
env = gym.make('Hopper-v2')
env = gymnasium.make('Hopper-v2')
```
v3 and v4 take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
v3 and v4 take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
```
env = gym.make('Hopper-v4', ctrl_cost_weight=0.1, ....)
env = gymnasium.make('Hopper-v4', ctrl_cost_weight=0.1, ....)
```
| Parameter | Type | Default | Description |
@@ -132,7 +132,7 @@ class HopperEnv(MujocoEnv, utils.EzPickle):
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
* v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0)

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
def mass_center(model, sim):

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"trackbodyid": 1,

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MujocoEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MujocoEnv
from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"trackbodyid": 1,
@@ -182,13 +182,13 @@ class HumanoidEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported in v2 and lower.
```
env = gym.make('Humanoid-v4')
env = gymnasium.make('Humanoid-v4')
```
v3 and v4 take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
v3 and v4 take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
```
env = gym.make('Humanoid-v4', ctrl_cost_weight=0.1, ....)
env = gymnasium.make('Humanoid-v4', ctrl_cost_weight=0.1, ....)
```
| Parameter | Type | Default | Description |
@@ -206,7 +206,7 @@ class HumanoidEnv(MujocoEnv, utils.EzPickle):
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
* v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0)

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
class HumanoidStandupEnv(MuJocoPyEnv, utils.EzPickle):

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MujocoEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MujocoEnv
from gymnasium.spaces import Box
class HumanoidStandupEnv(MujocoEnv, utils.EzPickle):
@@ -162,17 +162,17 @@ class HumanoidStandupEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported.
```
env = gym.make('HumanoidStandup-v4')
env = gymnasium.make('HumanoidStandup-v4')
```
There is no v3 for HumanoidStandup, unlike the robot environments where a v3 and
beyond take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
beyond take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
* v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0)

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
class InvertedDoublePendulumEnv(MuJocoPyEnv, utils.EzPickle):

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MujocoEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MujocoEnv
from gymnasium.spaces import Box
class InvertedDoublePendulumEnv(MujocoEnv, utils.EzPickle):
@@ -97,16 +97,16 @@ class InvertedDoublePendulumEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported.
```
env = gym.make('InvertedDoublePendulum-v4')
env = gymnasium.make('InvertedDoublePendulum-v4')
```
There is no v3 for InvertedPendulum, unlike the robot environments where a v3 and
beyond take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
beyond take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
* v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks (including inverted pendulum)
* v0: Initial versions release (1.0.0)

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
class InvertedPendulumEnv(MuJocoPyEnv, utils.EzPickle):

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MujocoEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MujocoEnv
from gymnasium.spaces import Box
class InvertedPendulumEnv(MujocoEnv, utils.EzPickle):
@@ -68,16 +68,16 @@ class InvertedPendulumEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported.
```
env = gym.make('InvertedPendulum-v4')
env = gymnasium.make('InvertedPendulum-v4')
```
There is no v3 for InvertedPendulum, unlike the robot environments where a
v3 and beyond take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
v3 and beyond take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
* v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks (including inverted pendulum)
* v0: Initial versions release (1.0.0)

View File

@@ -3,9 +3,9 @@ from typing import Optional, Union
import numpy as np
import gym
from gym import error, logger, spaces
from gym.spaces import Space
import gymnasium
from gymnasium import error, logger, spaces
from gymnasium.spaces import Space
MUJOCO_PY_NOT_INSTALLED = False
MUJOCO_NOT_INSTALLED = False
@@ -26,7 +26,7 @@ except ImportError as e:
DEFAULT_SIZE = 480
class BaseMujocoEnv(gym.Env):
class BaseMujocoEnv(gymnasium.Env):
"""Superclass for all MuJoCo environments."""
def __init__(
@@ -395,15 +395,17 @@ class MujocoEnv(BaseMujocoEnv):
def _get_viewer(
self, mode
) -> Union["gym.envs.mujoco.Viewer", "gym.envs.mujoco.RenderContextOffscreen"]:
) -> Union[
"gymnasium.envs.mujoco.Viewer", "gymnasium.envs.mujoco.RenderContextOffscreen"
]:
self.viewer = self._viewers.get(mode)
if self.viewer is None:
if mode == "human":
from gym.envs.mujoco import Viewer
from gymnasium.envs.mujoco import Viewer
self.viewer = Viewer(self.model, self.data)
elif mode in {"rgb_array", "depth_array"}:
from gym.envs.mujoco import RenderContextOffscreen
from gymnasium.envs.mujoco import RenderContextOffscreen
self.viewer = RenderContextOffscreen(self.model, self.data)
else:

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
class PusherEnv(MuJocoPyEnv, utils.EzPickle):

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MujocoEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MujocoEnv
from gymnasium.spaces import Box
class PusherEnv(MujocoEnv, utils.EzPickle):
@@ -113,11 +113,11 @@ class PusherEnv(MujocoEnv, utils.EzPickle):
(or by changing the path to a modified XML file in another folder)..
```
env = gym.make('Pusher-v4')
env = gymnasium.make('Pusher-v4')
```
There is no v3 for Pusher, unlike the robot environments where a v3 and
beyond take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
beyond take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
### Version History

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
class ReacherEnv(MuJocoPyEnv, utils.EzPickle):

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MujocoEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MujocoEnv
from gymnasium.spaces import Box
class ReacherEnv(MujocoEnv, utils.EzPickle):
@@ -103,11 +103,11 @@ class ReacherEnv(MujocoEnv, utils.EzPickle):
(or by changing the path to a modified XML file in another folder)..
```
env = gym.make('Reacher-v4')
env = gymnasium.make('Reacher-v4')
```
There is no v3 for Reacher, unlike the robot environments where a v3 and
beyond take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
beyond take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
### Version History

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
class SwimmerEnv(MuJocoPyEnv, utils.EzPickle):

View File

@@ -2,9 +2,9 @@ __credits__ = ["Rushiv Arora"]
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {}

View File

@@ -2,9 +2,9 @@ __credits__ = ["Rushiv Arora"]
import numpy as np
from gym import utils
from gym.envs.mujoco import MujocoEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MujocoEnv
from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {}
@@ -97,13 +97,13 @@ class SwimmerEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported in v2 and lower.
```
gym.make('Swimmer-v4')
gymnasium.make('Swimmer-v4')
```
v3 and v4 take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
v3 and v4 take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
```
env = gym.make('Swimmer-v4', ctrl_cost_weight=0.1, ....)
env = gymnasium.make('Swimmer-v4', ctrl_cost_weight=0.1, ....)
```
| Parameter | Type | Default | Description |
@@ -118,7 +118,7 @@ class SwimmerEnv(MujocoEnv, utils.EzPickle):
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
* v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0)

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
class Walker2dEnv(MuJocoPyEnv, utils.EzPickle):

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MuJocoPyEnv
from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"trackbodyid": 2,

View File

@@ -1,8 +1,8 @@
import numpy as np
from gym import utils
from gym.envs.mujoco import MujocoEnv
from gym.spaces import Box
from gymnasium import utils
from gymnasium.envs.mujoco import MujocoEnv
from gymnasium.spaces import Box
DEFAULT_CAMERA_CONFIG = {
"trackbodyid": 2,
@@ -112,13 +112,13 @@ class Walker2dEnv(MujocoEnv, utils.EzPickle):
No additional arguments are currently supported in v2 and lower.
```
env = gym.make('Walker2d-v4')
env = gymnasium.make('Walker2d-v4')
```
v3 and beyond take gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
v3 and beyond take gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc.
```
env = gym.make('Walker2d-v4', ctrl_cost_weight=0.1, ....)
env = gymnasium.make('Walker2d-v4', ctrl_cost_weight=0.1, ....)
```
| Parameter | Type | Default | Description |
@@ -137,7 +137,7 @@ class Walker2dEnv(MujocoEnv, utils.EzPickle):
### Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3
* v3: support for gym.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v3: support for gymnasium.make kwargs such as xml_file, ctrl_cost_weight, reset_noise_scale etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0)

View File

@@ -21,15 +21,15 @@ from typing import (
import numpy as np
from gym.wrappers import (
from gymnasium.wrappers import (
AutoResetWrapper,
HumanRendering,
OrderEnforcing,
RenderCollection,
TimeLimit,
)
from gym.wrappers.compatibility import EnvCompatibility
from gym.wrappers.env_checker import PassiveEnvChecker
from gymnasium.wrappers.compatibility import EnvCompatibility
from gymnasium.wrappers.env_checker import PassiveEnvChecker
if sys.version_info < (3, 10):
import importlib_metadata as metadata # type: ignore
@@ -41,7 +41,7 @@ if sys.version_info >= (3, 8):
else:
from typing_extensions import Literal
from gym import Env, error, logger
from gymnasium import Env, error, logger
ENV_ID_RE = re.compile(
r"^(?:(?P<namespace>[\w:-]+)\/)?(?:(?P<name>[\w:.-]+?))(?:-v(?P<version>\d+))?$"
@@ -116,17 +116,17 @@ def get_env_id(ns: Optional[str], name: str, version: Optional[int]) -> str:
@dataclass
class EnvSpec:
"""A specification for creating environments with `gym.make`.
"""A specification for creating environments with `gymnasium.make`.
* id: The string used to create the environment with `gym.make`
* id: The string used to create the environment with `gymnasium.make`
* entry_point: The location of the environment to create from
* reward_threshold: The reward threshold for completing the environment.
* nondeterministic: If the observation of an environment cannot be repeated with the same initial state, random number generator state and actions.
* max_episode_steps: The max number of steps that the environment can take before truncation
* order_enforce: If to enforce the order of `reset` before `step` and `render` functions
* autoreset: If to automatically reset the environment on episode end
* disable_env_checker: If to disable the environment checker wrapper in `gym.make`, by default False (runs the environment checker)
* kwargs: Additional keyword arguments passed to the environments through `gym.make`
* disable_env_checker: If to disable the environment checker wrapper in `gymnasium.make`, by default False (runs the environment checker)
* kwargs: Additional keyword arguments passed to the environments through `gymnasium.make`
"""
id: str
@@ -263,7 +263,7 @@ def find_highest_version(ns: Optional[str], name: str) -> Optional[int]:
return max(version, default=None)
def load_env_plugins(entry_point: str = "gym.envs") -> None:
def load_env_plugins(entry_point: str = "gymnasium.envs") -> None:
# Load third-party environments
for plugin in metadata.entry_points(group=entry_point):
# Python 3.8 doesn't support plugin.module, plugin.attr
@@ -284,7 +284,7 @@ def load_env_plugins(entry_point: str = "gym.envs") -> None:
finally:
if attr is None:
raise error.Error(
f"Gym environment plugin `{module}` must specify a function to execute, not a root module"
f"Gymnasium environment plugin `{module}` must specify a function to execute, not a root module"
)
context = namespace(plugin.name)
@@ -414,7 +414,7 @@ def _check_spec_register(spec: EnvSpec):
f"`{spec.id}` when the versioned environment "
f"`{latest_versioned_spec.id}` of the same name "
f"already exists. Note: the default behavior is "
f"that `gym.make` with the unversioned environment "
f"that `gymnasium.make` with the unversioned environment "
f"will return the latest versioned environment"
)
@@ -443,7 +443,7 @@ def register(
apply_api_compatibility: bool = False,
**kwargs,
):
"""Register an environment with gym.
"""Register an environment with gymnasium.
The `id` parameter corresponds to the name of the environment, with the syntax as follows:
`(namespace)/(env_name)-v(version)` where `namespace` is optional.
@@ -509,7 +509,7 @@ def make(
) -> Env:
"""Create an environment according to the given ID.
To find all available environments use `gym.envs.registry.keys()` for all valid ids.
To find all available environments use `gymnasium.envs.registry.keys()` for all valid ids.
Args:
id: Name of the environment. Optionally, a module to import can be included, eg. 'module:Env-v0'

View File

@@ -0,0 +1,4 @@
from gymnasium.envs.toy_text.blackjack import BlackjackEnv
from gymnasium.envs.toy_text.cliffwalking import CliffWalkingEnv
from gymnasium.envs.toy_text.frozen_lake import FrozenLakeEnv
from gymnasium.envs.toy_text.taxi import TaxiEnv

View File

@@ -3,9 +3,9 @@ from typing import Optional
import numpy as np
import gym
from gym import spaces
from gym.error import DependencyNotInstalled
import gymnasium
from gymnasium import spaces
from gymnasium.error import DependencyNotInstalled
def cmp(a, b):
@@ -46,7 +46,7 @@ def is_natural(hand): # Is this hand a natural blackjack?
return sorted(hand) == [1, 10]
class BlackjackEnv(gym.Env):
class BlackjackEnv(gymnasium.Env):
"""
Blackjack is a card game where the goal is to beat the dealer by obtaining cards
that sum to closer to 21 (without going over 21) than the dealers cards.
@@ -94,7 +94,7 @@ class BlackjackEnv(gym.Env):
### Arguments
```
gym.make('Blackjack-v1', natural=False, sab=False)
gymnasium.make('Blackjack-v1', natural=False, sab=False)
```
<a id="nat">`natural=False`</a>: Whether to give an additional reward for
@@ -194,7 +194,7 @@ class BlackjackEnv(gym.Env):
import pygame
except ImportError:
raise DependencyNotInstalled(
"pygame is not installed, run `pip install gym[toy_text]`"
"pygame is not installed, run `pip install gymnasium[toy_text]`"
)
player_sum, dealer_card_value, usable_ace = self._get_obs()

View File

@@ -5,9 +5,9 @@ from typing import Optional
import numpy as np
from gym import Env, spaces
from gym.envs.toy_text.utils import categorical_sample
from gym.error import DependencyNotInstalled
from gymnasium import Env, spaces
from gymnasium.envs.toy_text.utils import categorical_sample
from gymnasium.error import DependencyNotInstalled
UP = 0
RIGHT = 1
@@ -55,7 +55,7 @@ class CliffWalkingEnv(Env):
### Arguments
```
gym.make('CliffWalking-v0')
gymnasium.make('CliffWalking-v0')
```
### Version History
@@ -173,7 +173,7 @@ class CliffWalkingEnv(Env):
import pygame
except ImportError:
raise DependencyNotInstalled(
"pygame is not installed, run `pip install gym[toy_text]`"
"pygame is not installed, run `pip install gymnasium[toy_text]`"
)
if self.window_surface is None:
pygame.init()

View File

@@ -5,9 +5,9 @@ from typing import List, Optional
import numpy as np
from gym import Env, spaces, utils
from gym.envs.toy_text.utils import categorical_sample
from gym.error import DependencyNotInstalled
from gymnasium import Env, spaces, utils
from gymnasium.envs.toy_text.utils import categorical_sample
from gymnasium.error import DependencyNotInstalled
LEFT = 0
DOWN = 1
@@ -105,7 +105,7 @@ class FrozenLakeEnv(Env):
### Arguments
```
gym.make('FrozenLake-v1', desc=None, map_name="4x4", is_slippery=True)
gymnasium.make('FrozenLake-v1', desc=None, map_name="4x4", is_slippery=True)
```
`desc`: Used to specify custom map for frozen lake. For example,
@@ -115,9 +115,9 @@ class FrozenLakeEnv(Env):
A random generated map can be specified by calling the function `generate_random_map`. For example,
```
from gym.envs.toy_text.frozen_lake import generate_random_map
from gymnasium.envs.toy_text.frozen_lake import generate_random_map
gym.make('FrozenLake-v1', desc=generate_random_map(size=8))
gymnasium.make('FrozenLake-v1', desc=generate_random_map(size=8))
```
`map_name`: ID to use any of the preloaded maps.
@@ -277,7 +277,7 @@ class FrozenLakeEnv(Env):
import pygame
except ImportError:
raise DependencyNotInstalled(
"pygame is not installed, run `pip install gym[toy_text]`"
"pygame is not installed, run `pip install gymnasium[toy_text]`"
)
if self.window_surface is None:

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 43 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Some files were not shown because too many files have changed in this diff Show More