Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests for blackjack edge cases #1088

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
22 changes: 21 additions & 1 deletion tests/envs/test_env_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)
Expand Down
Loading