Files
Gymnasium/tests/envs/test_lunar_lander.py
Andrew Tan Jin Shen 4fe7efaacd Consolidate LunarLander and BipedalWalker envs (#2522)
* 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>
2021-12-22 13:25:07 -05:00

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