Skip to content

Commit

Permalink
🔗 Fix links and add badge for license
Browse files Browse the repository at this point in the history
  • Loading branch information
Skripkon committed Jan 5, 2025
1 parent 9ffb4d5 commit 80792f8
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 72 deletions.
1 change: 1 addition & 0 deletions PokerBots/images/MIT_license.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
</h1><br>

<div style="display: flex; align-items: center; gap: 30px;">
<img src="https://img.shields.io/pypi/pyversions/pokerkit" height="50" alt="Supported Python versions">
<a href="https://pypi.org/project/PokerBots/" target="_blank">
<img src="https://img.shields.io/pypi/pyversions/pokerkit" height="50" alt="Supported Python versions">
</a>
<a href="https://pepy.tech/projects/pokerbots" target="_blank">
<img src="https://static.pepy.tech/badge/pokerbots" height="50" alt="PyPI Downloads">
</a>
<a href="https://github.com/Skripkon/PokerBots/blob/main/LICENSE" target="_blank">
<img src="https://raw.githubusercontent.com/Skripkon/PokerBots/27bba4cc02db1a785a9c6623f807f7e138ebbbf7/PokerBots/images/MIT_license.svg" height="50" alt="MIT License">
</a>
</div>

# Test your bots in no-limit hold'em tournaments!
Expand Down Expand Up @@ -39,7 +44,7 @@ print(game.state.stacks) # [27500, 35000, 27500]
```

> [!TIP]
> If you want to see a detailed output during the games, then set ```verbose=True```:
> If you want to see a detailed output during the games, then set ```verbose=True```.
## 3. Create Your Own Bot

Expand Down
140 changes: 70 additions & 70 deletions tests/test_players.py
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
from PokerBots import Game
from PokerBots import CallingPlayer, RandomPlayer


def simulate_game(players, rounds=100, verbose: bool = False):
"""
Simulates a single poker game with the given players.
Args:
players (list): A list of player objects.
rounds (int): Maximum number of rounds to play in the game.
verbose (bool): If positive, prints logs.
"""
# Set up the game with an initial stack for each player
game = Game(players=players, initial_stack=50_000)

# Play up to the specified number of rounds
for _ in range(rounds):
if game.play_round(verbose=verbose):
break


def simulate_multiple_games(players, num_simulations=100, rounds=100, verbose: bool = False):
"""
Simulates multiple poker games with the given players.
Args:
players (list): A list of player objects.
num_simulations (int): Number of games to simulate.
rounds (int): Maximum number of rounds to play in each game.
verbose (bool): If positive, prints logs.
"""
for _ in range(num_simulations):
simulate_game(players, rounds, verbose=verbose)


def create_calling_players():
"""
Creates a list of CallingPlayer objects with predefined names.
Returns:
list: A list of CallingPlayer objects.
"""
players = [CallingPlayer(), CallingPlayer(), CallingPlayer()]
players[0].name, players[1].name, players[2].name = "Ivan", "Daniel", "Andrew"
return players


def create_random_players():
"""
Creates a list of RandomPlayer objects with predefined names.
Returns:
list: A list of RandomPlayer objects.
"""
players = [RandomPlayer(), RandomPlayer(), RandomPlayer()]
players[0].name, players[1].name, players[2].name = "Ivan", "Daniel", "Andrew"
return players


# Test with calling players
def test_multiple_game_simulations_with_calling_players(num_simulations=10, rounds=10):
simulate_multiple_games(create_calling_players(), num_simulations, rounds, verbose=True)
simulate_multiple_games(create_calling_players(), num_simulations, rounds, verbose=False)


# Test with random players
def test_multiple_game_simulations_with_random_players(num_simulations=10, rounds=10):
simulate_multiple_games(create_random_players(), num_simulations, rounds, verbose=True)
simulate_multiple_games(create_random_players(), num_simulations, rounds, verbose=False)
from PokerBots import Game
from PokerBots import CallingPlayer, RandomPlayer


def simulate_game(players, rounds=100, verbose: bool = False):
"""
Simulates a single poker game with the given players.
Args:
players (list): A list of player objects.
rounds (int): Maximum number of rounds to play in the game.
verbose (bool): If positive, prints logs.
"""
# Set up the game with an initial stack for each player
game = Game(players=players, initial_stack=50_000)

# Play up to the specified number of rounds
for _ in range(rounds):
if game.play_round(verbose=verbose):
break


def simulate_multiple_games(players, num_simulations=100, rounds=100, verbose: bool = False):
"""
Simulates multiple poker games with the given players.
Args:
players (list): A list of player objects.
num_simulations (int): Number of games to simulate.
rounds (int): Maximum number of rounds to play in each game.
verbose (bool): If positive, prints logs.
"""
for _ in range(num_simulations):
simulate_game(players, rounds, verbose=verbose)


def create_calling_players():
"""
Creates a list of CallingPlayer objects with predefined names.
Returns:
list: A list of CallingPlayer objects.
"""
players = [CallingPlayer(), CallingPlayer(), CallingPlayer()]
players[0].name, players[1].name, players[2].name = "Ivan", "Daniel", "Andrew"
return players


def create_random_players():
"""
Creates a list of RandomPlayer objects with predefined names.
Returns:
list: A list of RandomPlayer objects.
"""
players = [RandomPlayer(), RandomPlayer(), RandomPlayer()]
players[0].name, players[1].name, players[2].name = "Ivan", "Daniel", "Andrew"
return players


# Test with calling players
def test_multiple_game_simulations_with_calling_players(num_simulations=10, rounds=10):
simulate_multiple_games(create_calling_players(), num_simulations, rounds, verbose=True)
simulate_multiple_games(create_calling_players(), num_simulations, rounds, verbose=False)


# Test with random players
def test_multiple_game_simulations_with_random_players(num_simulations=10, rounds=10):
simulate_multiple_games(create_random_players(), num_simulations, rounds, verbose=True)
simulate_multiple_games(create_random_players(), num_simulations, rounds, verbose=False)

0 comments on commit 80792f8

Please sign in to comment.