Giter VIP home page Giter VIP logo

texasholdem's People

Contributors

dependabot[bot] avatar lucascolas avatar sirrender00 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

texasholdem's Issues

Refactor `History` module

Right now, storing the entire state of random python module.

AC:

  • Only store a seed such that random.seed(seed) will replay the hand
    • Make sure has enough entropy!
  • Make a comprehensive History object that contains information about the outcome
    • Hand id?
    • The winner and how many chips won

Refactor Text GUI

TextGUI is a mess of spaghetti code

  • Should also support 2-9 players

Get the position of a specific player

Hello,
Is it possible to get the position of a specific player.
I know you can get :
-the id of the player who has the button
-The id of the player who has the big blind
-The id of the player who has the small blind
But can we get the id of the other players (UTG, Cut Off, etc.)
Thank you.

Include iterator over all valid moves

Should be able to do things like

  • (ActionType.RAISE, 50) in game.get_all_available_moves()
  • ActionType.CALL in game.get_all_available_moves()
  • (ActionType.CHECK, None) in game.get_all_available_moves()
  • (ActionType.CHECK, 50) in game.get_all_available_moves() # True
  • for action, val in game.get_all_available_moves(): print(action, val)

All in operations should be completed in O(1) time in the number of possible moves and chips.

Add probability functionality to evaluator module

For instance, 2 cards behind, 3 on the board. What's the probability my hand is the best right now? On the turn? On the river?

Should be able to handle 2 cards behind, and 0,3,4, and 5 on the board.

Supercedes #5

"Truly" Random Generation

As is, the python random module is not rated for cryptography or large entropy. Suggests implementing the randomness with the secrets module.

Merge pots when a player folds

Currently, pots are always added and never removed. Even when a player folds and pots can be reduced. i.e. if players 1, 2, 3 are in the main pot, 2,3 are in a side pot and then 3 is in a 3rd pot, when player 2 folds the 2nd and 3rd pots can be merged

Allow to register an agent

This will allow for

game.register(agent, player_id=2)

and then game will automatically call the agent when it is their turn as opposed to doing the canonical loop with a switch statement for agents.

Refactor class / package structure

Appears to have too many singleton classes: ActionType, HandPhase.

AC:

  • Investigate combining certain modules / packages
  • Add certain modules to __init__.pys for better aliasing
  • Rename ActionType --> Action
  • Add useful error exceptions

A question about take_action

I try to do as follows

fake code:
take_action(RAISE, 20)

The next player, let's say it should be CALL 20
take_action(CHECK, 0)

But I call CHECK, CALL, it seems to be successful?

Random Agent does Raise Action when it is not possible

When using the random agent, the raise action is still an available action, even when the player does not have enough chips to raise.

Here's what I tested:

Player_chips      bet_amount      Previous_raise       Expected_chips_to_raise                 Chips_to_raise
500                  10                 5                      15                                      15
500                  550                490                    n/a                                     990
200                  210                200                    n/a                                     410

Support Cash Game Option

Idea is to have a cash game option where:

  • Players can sit down and stand up whenever they want
  • Includes a rake
  • Includes a timeout option where the current player has to fold if no action is given
  • Register AIs

Idea: Have a Table Class in furtherance of this abstraction

The way raise is defined is troublesome

When I raise 5 chips, the amount should be this pot's raised value + 5, not just 5 chips. It's causing many errors and I printed out player info's and pots.raised
image

You can see in the image, player's actions do not map correctly to pot-raised amounts (when player 3 raised 1298 chips, one value in the list below should update to 1298 as the raised amounts) and I have no idea where to locate this bug.
Thanks for the help in advance!

Game logic looks flawed in heads-up case

Hi there,
I did a small test of this library in the heads-up case and was very surprised by
the output. Sorry in advance if I somehow misunderstood it.
This is the small test I tried (with v0.9):

import texasholdem
game = texasholdem.TexasHoldEm(buyin=10000, big_blind=100, small_blind=50, max_players=2)
game.start_hand()
actions = [('b', 200), ('b', 600), ('c', None), ('k', None),\
           ('k', None),('b', 600), ('c', None), ('b', 2400), ('f', None)]
for idx, (action, bet) in enumerate(actions):
    if action == "k":
        game.take_action(texasholdem.ActionType.CHECK)
        print(f"Player {game.current_player}: checks")
    elif action == "c":
        game.take_action(texasholdem.ActionType.CALL)
        print(f"Player {game.current_player}: calls")
    elif action == "f":
        game.take_action(texasholdem.ActionType.FOLD)
        print(f"Player {game.current_player}: folds")
    elif action == "b":
        game.take_action(texasholdem.ActionType.RAISE, total=bet)
        print(f"Player {game.current_player}: bets {bet}")

print(f"Players left in pot {list(game.pots[0].players_in_pot())}")
print(f"Available moves: {game.get_available_moves()}")
print(f"Game state: {game.game_state}")
print(f"Player chips: {game.players[0].chips} {game.players[1].chips}")
print(f"Total chips: {game.players[0].chips+game.players[1].chips+game.pots[0].get_total_amount()}")

I got this output:

Player 1: bets 200
Player 0: bets 600
Player 1: calls
Player 0: checks
Player 1: checks
Player 0: bets 600
Player 1: calls
Player 0: bets 2400
Player 1: folds
Players left in pot [1]
Available moves: MoveIterator({<ActionType.RAISE: 1>: range(2400, 11201), <ActionType.CHECK: 4>: None, <ActionType.FOLD: 5>: None})
Game state: GameState.RUNNING
Player chips: 8800 11200
Total chips: 24800

I have several questions about this.

  • Why is the game still running when player 1 folded? In my opinion the game should end
    when the last player folds, at least it makes no sense that player 0 can still raise or check.
  • Why is player 1 left in pot? He just folded, to my understanding just player 0 should be left in the pot.
  • Why is the pot + player 0 chips + player 1 chips larger than the total chips (20000)?

External Documentation

Should host external documentation, perhaps using the readthedocs style.

AC:

  • Reformat docstrings / ensure they exist

Impossible to play with bots only

Hello,
I would like to try to do a game of poker where every player is a bot. Here is an example of code I did :

from texasholdem.game.game import TexasHoldEm
from texasholdem.gui.text_gui import TextGUI
from texasholdem.agents.basic import random_agent, call_agent
from texasholdem.evaluator.evaluator import *
from texasholdem.card.deck import Deck


max_players = 6
big_blind = 150
small_blind = big_blind // 2
buyin = 1000
game = TexasHoldEm(buyin=buyin, big_blind=big_blind, small_blind=small_blind, max_players=max_players)
gui = TextGUI(game=game, visible_players=[])

while game.is_game_running():

    game.start_hand()
    while game.is_hand_running():
        game.take_action(*random_agent(game))
        gui.run_step()

However sometimes I was asked to play. Every action should be taken by a random agent but sometimes I have to take the action.

Python Dependency Is Wrong

Bug: Currently, the type-hinting implies python >=3.9 but package states it supports python 3.8.

Work:

  • change all type hints to be compatible (e.g. list -> List, dict -> Dict, etc.)

cc: @AnsonHong703

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.