diff --git a/pyproject.toml b/pyproject.toml index 541c1a2d0..66be67324 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ 'Topic :: Scientific/Engineering :: Artificial Intelligence', ] dependencies = [ - "numpy >=1.21.0", + "numpy>=1.21.0,<2.0.0", "cloudpickle >=1.2.0", "importlib-metadata >=4.8.0; python_version < '3.10'", "typing-extensions >=4.3.0", diff --git a/tests/envs/test_env_implementation.py b/tests/envs/test_env_implementation.py index e75982b86..9cb51d446 100644 --- a/tests/envs/test_env_implementation.py +++ b/tests/envs/test_env_implementation.py @@ -6,7 +6,7 @@ import gymnasium as gym from gymnasium.envs.box2d import BipedalWalker, CarRacing from gymnasium.envs.box2d.lunar_lander import demo_heuristic_lander -from gymnasium.envs.toy_text import TaxiEnv +from gymnasium.envs.toy_text import BlackjackEnv, TaxiEnv from gymnasium.envs.toy_text.frozen_lake import generate_random_map @@ -256,6 +256,26 @@ def test_invalid_customizable_resets(env_name: str, low_high: list): env.reset(options={"low": low, "high": high}) +def test_blackjack_edgecases(): + # GH 1011 + # test dealer and player have natural 21 + env = BlackjackEnv() + env.player = [1, 10] + env.dealer = [1, 10] + _obs, reward, terminated, _, _info = env.step(0) + # no payout expected + assert terminated is True + assert reward == 0 + + # test dealer and player have sum 21 but after a hit + env.reset() + env.player = [2, 10, 9] + env.dealer = [2, 10, 4, 5] + _obs, reward, terminated, _, _info = env.step(0) + assert terminated is True + assert reward == 0 + + def test_cartpole_vector_equiv(): env = gym.make("CartPole-v1") envs = gym.make_vec("CartPole-v1", num_envs=1)