mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-09-03 02:52:01 +00:00
* Consolidate LunarLander and BipedalWalker envs * Update LunarLander tests * Add type hints * Add detailed error message on instantiating deprecated environments * Fix formatting with black pre-commit Co-authored-by: Andrew Tan Jin Shen <andrew.tanjs@shopee.com>
27 lines
685 B
Python
27 lines
685 B
Python
import pytest
|
|
|
|
try:
|
|
import Box2D
|
|
from gym.envs.box2d.lunar_lander import (
|
|
LunarLander,
|
|
demo_heuristic_lander,
|
|
)
|
|
except ImportError:
|
|
Box2D = None
|
|
|
|
|
|
@pytest.mark.skipif(Box2D is None, reason="Box2D not installed")
|
|
def test_lunar_lander():
|
|
_test_lander(LunarLander(), seed=0)
|
|
|
|
|
|
@pytest.mark.skipif(Box2D is None, reason="Box2D not installed")
|
|
def test_lunar_lander_continuous():
|
|
_test_lander(LunarLander(continuous=True), seed=0)
|
|
|
|
|
|
@pytest.mark.skipif(Box2D is None, reason="Box2D not installed")
|
|
def _test_lander(env, seed=None, render=False):
|
|
total_reward = demo_heuristic_lander(env, seed=seed, render=render)
|
|
assert total_reward > 100
|