mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-22 07:02:19 +00:00
* add pygame GUI for frozen_lake.py env * add new line at EOF * pre-commit reformat * improve graphics * new images and dynamic window size * darker tile borders and fix ICC profile * pre-commit hook * adjust elf and stool size * Update frozen_lake.py * reformat * fix #2600 * #2600 * add rgb_array support * reformat * test render api change on FrozenLake * add render support for reset on frozenlake * add clock on pygame render * new render api for blackjack * new render api for cliffwalking * new render api for Env class * update reset method, lunar and Env * fix wrapper * fix reset lunar * new render api for box2d envs * new render api for mujoco envs * fix bug * new render api for classic control envs * fix tests * add render_mode None for CartPole * new render api for test fake envs * pre-commit hook * fix FrozenLake * fix FrozenLake * more render_mode to super - frozenlake * remove kwargs from frozen_lake new * pre-commit hook * add deprecated render method * add backwards compatibility * fix test * add _render * move pygame.init() (avoid pygame dependency on init) * fix pygame dependencies * remove collect_render() maintain multi-behaviours .render() * add type hints * fix renderer * don't call .render() with None * improve docstring * add single_rgb_array to all envs * remove None from metadata["render_modes"] * add type hints to test_env_checkers * fix lint * add comments to renderer * add comments to single_depth_array and single_state_pixels * reformat * add deprecation warnings and env.render_mode declaration * fix lint * reformat * fix tests * add docs * fix car racing determinism * remove warning test envs, customizable modes on renderer * remove commments and add todo for env_checker * fix car racing * replace render mode check with assert * update new mujoco * reformat * reformat * change metaclass definition * fix tests * implement mark suggestions (test, docs, sets) * check_render Co-authored-by: J K Terry <jkterry0@gmail.com>
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
from typing import Optional
|
|
|
|
import numpy as np
|
|
import pytest
|
|
|
|
import gym
|
|
from gym.spaces import Box, Dict, Discrete
|
|
from gym.utils.env_checker import check_env
|
|
|
|
|
|
class ActionDictTestEnv(gym.Env):
|
|
action_space = Dict({"position": Discrete(1), "velocity": Discrete(1)})
|
|
observation_space = Box(low=-1.0, high=2.0, shape=(3,), dtype=np.float32)
|
|
|
|
def __init__(self, render_mode: Optional[str] = None):
|
|
self.render_mode = render_mode
|
|
|
|
def step(self, action):
|
|
observation = np.array([1.0, 1.5, 0.5])
|
|
reward = 1
|
|
done = True
|
|
return observation, reward, done
|
|
|
|
def reset(self, *, seed: Optional[int] = None, options: Optional[dict] = None):
|
|
super().reset(seed=seed)
|
|
return np.array([1.0, 1.5, 0.5])
|
|
|
|
def render(self, mode: Optional[str] = "human"):
|
|
pass
|
|
|
|
|
|
def test_check_env_dict_action():
|
|
# Environment.step() only returns 3 values: obs, reward, done. Not info!
|
|
test_env = ActionDictTestEnv()
|
|
|
|
with pytest.raises(AssertionError) as errorinfo:
|
|
check_env(env=test_env, warn=True)
|
|
assert (
|
|
str(errorinfo.value)
|
|
== "The `step()` method must return four values: obs, reward, done, info"
|
|
)
|