Skip to content

Commit 00e0b83

Browse files
authored
Add repeated poker. (#435)
1 parent 88079b8 commit 00e0b83

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

kaggle_environments/envs/open_spiel/open_spiel.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,13 +553,37 @@ def _register_game_envs(games_list: list[str]) -> dict[str, Any]:
553553
return registered_envs
554554

555555

556+
DEFAULT_UNIVERSAL_POKER_GAME_STRING = (
557+
"universal_poker("
558+
"betting=nolimit,"
559+
"bettingAbstraction=fullgame,"
560+
"blind=2 1,"
561+
"firstPlayer=2 1 1 1,"
562+
"numBoardCards=0 3 1 1,"
563+
"numHoleCards=2,"
564+
"numPlayers=2,"
565+
"numRanks=13,"
566+
"numRounds=4,"
567+
"numSuits=4,"
568+
"stack=400 400)"
569+
)
570+
571+
DEFAULT_REPEATED_POKER_GAME_STRING = (
572+
"repeated_poker("
573+
"max_num_hands=20,"
574+
"reset_stacks=True,"
575+
"rotate_dealer=True,"
576+
f"universal_poker_game_string={DEFAULT_UNIVERSAL_POKER_GAME_STRING})"
577+
)
578+
556579
GAMES_LIST = [
557580
"chess",
558581
"connect_four",
559582
"gin_rummy",
560583
"go(board_size=9)",
561584
"tic_tac_toe",
562-
"universal_poker(betting=nolimit,bettingAbstraction=fullgame,blind=2 1,firstPlayer=2 1 1 1,numBoardCards=0 3 1 1,numHoleCards=2,numPlayers=2,numRanks=13,numRounds=4,numSuits=4,stack=400 400)",
585+
DEFAULT_UNIVERSAL_POKER_GAME_STRING,
586+
DEFAULT_REPEATED_POKER_GAME_STRING,
563587
]
564588

565589
ENV_REGISTRY = _register_game_envs(GAMES_LIST)

kaggle_environments/envs/open_spiel/test_open_spiel.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,21 @@ def test_chess_openings_configured_with_seed(self):
186186
self.assertEqual(env.configuration["imageConfig"]["pieceSet"], "cardinal")
187187
self.assertTrue("imageConfig" in env.state[0]["observation"])
188188

189+
def test_repeated_poker(self):
190+
envs = open_spiel_env._register_game_envs(
191+
[open_spiel_env.DEFAULT_REPEATED_POKER_GAME_STRING]
192+
)
193+
env = make(envs['open_spiel_repeated_poker'])
194+
env.reset()
195+
env.step([{"submission": -1}, {"submission": -1}]) # Initial setup step.
196+
for i in range(20):
197+
if i % 2 == 0:
198+
env.step([{"submission": -1}, {"submission": 0}])
199+
else:
200+
env.step([{"submission": 0}, {"submission": -1}])
201+
self.assertTrue(env.done)
202+
self.assertEqual(env.toJSON()["rewards"], [0.0, 0.0])
203+
189204

190205
if __name__ == "__main__":
191206
absltest.main()

0 commit comments

Comments
 (0)