Playing Deterministic Games

Playing Deterministic Games#

By design, the library provides no built-in way to guarantee reproducibility. In general, if you run the same game twice, the outcome will likely differ. If you need reproducible results, you must set the seeds for any pseudo-random number generators yourself.

Running the following block of code again and again would always yield exactly the same outcome.

Note

Needless to say, it you are using LLMs as players, setting the seed only wouldn’t guarantee determinism.

import random
from maverick import Game
from maverick.players import FoldBot, CallBot, AggressiveBot
from maverick import PlayerLike, PlayerState

# Set the random seed for reproducibility
random.seed(42)

game = Game(small_blind=10, big_blind=20, max_hands=2)
players: list[PlayerLike] = [
    CallBot(name="CallBot", state=PlayerState(stack=1000)),
    AggressiveBot(name="AggroBot", state=PlayerState(stack=1000)),
    FoldBot(name="FoldBot", state=PlayerState(stack=1000)),
]

for player in players:
    game.add_player(player)
    
game.start()

for p in players:
    print(f"{p.name} final stack: {p.state.stack}")
CallBot final stack: 1340
AggroBot final stack: 680
FoldBot final stack: 980