Skip to main content

A Pure Python library to test your Poker Bots in a trivial and simple way.

Project description


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?

See the source code!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pokerbots-2.0.6.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PokerBots-2.0.6-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file pokerbots-2.0.6.tar.gz.

File metadata

  • Download URL: pokerbots-2.0.6.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for pokerbots-2.0.6.tar.gz
Algorithm Hash digest
SHA256 1b60cb6bbf5df4378c789727b669b0b8ca27cc53024d52856666f0de2d7f86ec
MD5 d7125410c7cdea64640bbae10bc65800
BLAKE2b-256 40e959620a94efa3d2383469e044891da87e39c7fc23118697fb245d507bf5eb

See more details on using hashes here.

File details

Details for the file PokerBots-2.0.6-py3-none-any.whl.

File metadata

  • Download URL: PokerBots-2.0.6-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for PokerBots-2.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 55943f3dc127ecf2e03384405a1d51b0b8b2836450a86b3a4aba6d76b3e8769f
MD5 b2822813c6a14fc6379dc1009d4a5809
BLAKE2b-256 008b918785d8e14de7f8f6505209563394bc4503ea8e17db736650bc2fc95dc6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page