Run mcts_test.py
to run the Monte-Carlo Tree Search algorithm against 7 other players in 1000 different games. The win/draw rates are reported in the console for each player.
Run python tournament.py
to run the tournament with the players configured in the tournament.py file.
Running python interactive.py
sets up an interactive game for a HumanPlayer
against a few computer strategies.
This repo implements the Bank game logic as the foundation for the tournament ranking algorithm and Monte-Carlo tree search algorithm.
To simplify the player decision logic and Monte-Carlo tree search algorithm, the game is implemented as a turn-based game. After dice roll, each player is asked if they would like to bank. If a player chooses to bank, the decision process restarts, giving unbanked players a chance to change their mind based on the decision of others. The dice is rolled again once all players decide.
BankState
: Represents a single snapshot of a Bank game, containing all information needed to progress to the next state. This includes the current round number, the current player to decide, the pot amount, etc. TheBankState
objects should be treated as immutable.BankGame
: Represents an entire Bank game, containing a history of previous states and events. Mutable, and can progress from state to state with theBankGame.decide
method.BankPlayer
: An abstract base class used to implement different Bank player strategies. TheBankPlayer.get_decision
method accepts aBankGame
object, and makes a decision to bank or to pass given the current state of the game.HumanPlayer
: An implementation ofBankPlayer
. Takes user input from the command-line. Useful for playing against computer strategies.RandomPlayer
: Another implementation ofBankPlayer
. A basic strategy that randomly decides to bank with probabilityp
regardless of the current game state, which is set in the constructor. Defaults top=0.25
.next_state
: Returns the next state using the decision from the current player.play_game
: Accepts a list ofBankPlayer
s, and simulates a game with the players until completion. The game is returned. Theevent_hook
argument allows the caller to handle state and event updates after each decision.