Skip to content

Latest commit

 

History

History
98 lines (71 loc) · 3.21 KB

PyPI_README.md

File metadata and controls

98 lines (71 loc) · 3.21 KB


Test your bots in no-limit hold'em tournaments!

1. Install the library

$ pip install PokerBots

2. Explore a simple example

from PokerBots import Game, CallingPlayer, RandomPlayer, GamblingPlayer

# Define three vanila players
player1 = GamblingPlayer(name="Igor")
player2 = CallingPlayer(name="Ivan")
player3 = RandomPlayer(name="Maria")

game = Game(players=[player1, player2, player3], initial_stack=30_000)

# See current stacks:
print(game.stacks)  # [30_000, 30_000, 30_000]

# Run 1 round
game.play_round(verbose=False)

# See stacks after one round:
print(game.stacks)  # [27500, 35000, 27500]

If you want to see a detailed output during the games, then set verbose=True.

3. Create Your Own Bot

Creating new bots is a straightforward process:

  • Inherit from the BasePlayer class.
  • Override the play method: it must return an action and the amount of chips to bet, given the state of the game and valid actions.
from PokerBots import BasePlayer
from pokerkit import State

class MyOwnBot(BasePlayer):

    def play(self, valid_actions: dict, state: State) -> tuple[str, float]:
        """
        Implement a strategy to choose an action.
        """
        pass

valid_actions is a dictionary. Keys represent valid actions, and values represent the valid amount of chips. If all actions are valid, it will look like this:

valid_actions["fold"] = 0
valid_actions["check_or_call"] = 1_000
valid_actions["complete_bet_or_raise_to"] = (1_000, 50_000)

valid_actions["complete_bet_or_raise_to"] is a tuple of two numbers: the minimum and maximum raises.

Other information can be obtained from the state parameter.

For instance, the cards on the board can be accessed as follows:

state.board_cards

Or, the player's hole cards:

state.hole_cards[state.actor_index]

All official bots can be found in PokerBots/players/

Any questions? Want to contribute or merely give my repo a star?