mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-23 15:04:20 +00:00
Formated doctest and added more consistency (#281)
This commit is contained in:
@@ -97,14 +97,15 @@ Wrappers are a convenient way to modify an existing environment without having t
|
||||
In order to wrap an environment, you must first initialize a base environment. Then you can pass this environment along with (possibly optional) parameters to the wrapper's constructor:
|
||||
|
||||
```python
|
||||
>>> import gymnasium
|
||||
>>> from gymnasium.wrappers import RescaleAction
|
||||
>>> base_env = gymnasium.make("BipedalWalker-v3")
|
||||
>>> base_env.action_space
|
||||
Box([-1. -1. -1. -1.], [1. 1. 1. 1.], (4,), float32)
|
||||
>>> wrapped_env = RescaleAction(base_env, min_action=0, max_action=1)
|
||||
>>> wrapped_env.action_space
|
||||
Box([0. 0. 0. 0.], [1. 1. 1. 1.], (4,), float32)
|
||||
>>> import gymnasium as gym
|
||||
>>> from gymnasium.wrappers import FlattenObservation
|
||||
>>> env = gym.make("CarRacing-v2")
|
||||
>>> env.observation_space.shape
|
||||
(96, 96, 3)
|
||||
>>> wrapped_env = FlattenObservation(env)
|
||||
>>> wrapped_env.observation_space.shape
|
||||
(27648,)
|
||||
|
||||
```
|
||||
|
||||
Gymnasium already provides many commonly used wrappers for you. Some examples:
|
||||
@@ -120,9 +121,10 @@ If you have a wrapped environment, and you want to get the unwrapped environment
|
||||
|
||||
```python
|
||||
>>> wrapped_env
|
||||
<RescaleAction<TimeLimit<BipedalWalker<BipedalWalker-v3>>>>
|
||||
<FlattenObservation<TimeLimit<OrderEnforcing<PassiveEnvChecker<CarRacing<CarRacing-v2>>>>>>
|
||||
>>> wrapped_env.unwrapped
|
||||
<gymnasium.envs.box2d.bipedal_walker.BipedalWalker object at 0x7f87d70712d0>
|
||||
<gymnasium.envs.box2d.car_racing.CarRacing object at 0x7f04efcb8850>
|
||||
|
||||
```
|
||||
|
||||
## More information
|
||||
|
Reference in New Issue
Block a user