sirrender00 / texasholdem Goto Github PK
View Code? Open in Web Editor NEWA pure python package for Texas Hold 'Em poker
Home Page: https://github.com/SirRender00/texasholdem/
License: MIT License
A pure python package for Texas Hold 'Em poker
Home Page: https://github.com/SirRender00/texasholdem/
License: MIT License
Right now, storing the entire state of random
python module.
AC:
seed
such that random.seed(seed)
will replay the hand
History
object that contains information about the outcome
TextGUI is a mess of spaghetti code
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.
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.
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
As is, the python random
module is not rated for cryptography or large entropy. Suggests implementing the randomness with the secrets
module.
We can add things like: call_strategy
and random_strategy
to start
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
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.
Modules that need tests:
Extra... but when initializing the game can give an argument enable_showdown_actions
which allows players to MUCK
or SHOW
cards during showdown.
Related issues: #19
Hello,
Sometimes I get this error :
ValueError: Betting round is over at this point, can only CALL or FOLD.
I would like to know when it happens. Because in no-limit hold'em, players have the option to raise at any point in the hand (as long as they have chips remaining).
Appears to have too many singleton classes: ActionType
, HandPhase
.
AC:
__init__.py
s for better aliasingActionType
--> 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?
thanks
This will facilitate changes to the PGN format (by porting old versions to new versions)
Lot of repeated work for going to next phase: (check if hand over, if so SETTLE; set next player to be left of button; etc.)
Since it's not a full hand, will return the probability of winning against any random hands.
https://web.archive.org/web/20200715014447/http://www.natesholdem.com/pre-flop-odds.php
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
Idea is to have a cash game option where:
Idea: Have a Table
Class in furtherance of this abstraction
Currently, need support for python 3.11 in the windows-curses
module zephyrproject-rtos/windows-curses#31 .
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
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!
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.
Excuse me, after each round, how do you know who has won?
No corresponding function or variable found
How to know what type of hand the winning player has, such as a straight, two pair
thanks
Building of native poker clients that can run on MacOS, Windows, & Linux.
Should host external documentation, perhaps using the readthedocs
style.
AC:
Perhaps the TexasHoldEm
class can have a method like game.view(i)
that shows what player i
knows.
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.
Should display basic action information in the text gui such as
The internal turn iterator is very awkward. Instead we should move forward the state in the take_action
method.
Bug: Currently, the type-hinting implies python >=3.9 but package states it supports python 3.8.
Work:
list -> List
, dict -> Dict
, etc.)cc: @AnsonHong703
Version: 0.4.4
Context here #39
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.