Texas Holdem Python
Released:
Holdem Calculator library
Now let’s build a function that returns all possible 5 cards combinations taking into account that order doesn’t matter in Poker. I will do it by using the itertools library together with Numpy fromiter which allows making an array from our itertools combinations list. In addition to my practical Python script for Cisco switch configuration verification, I wrote a purely impractical Texas Hold’em Simulator. I enjoy the game, and it occurred to me that a poker simulator would be a fun way to explore Monte Carlo simulations.
Project description
The Holdem Calculator library calculates the probability that a certain Texas Hold'em hand will win. This probability is approximated by running a Monte Carlo method or calculated exactly by simulating the set of all possible hands. The Holdem Calculator also shows how likely each set of hole cards is to make a certain poker hand. The default Monte Carlo simulations are generally accurate to the nearest percent. Accuracy can be improved by increasing the number of simulations that are run, but this will result in a longer running time.
Command Line Options
Usage
I've listed a few examples showing how to use the Holdem Calculator. Note that you can mix and match command line options to suit your needs. See the bottom example in this section to see how to use the multiprocess Holdem Calculator for faster computations.
Default use case:
Multiplayer use case:
Exact calculation:
Board supplied:
Input file supplied:
In order to calculate multiple hands in a single run, the user has the choice to allow Holdem Calculator to read from an input file. Each line of the input file should represent a single calculation. Hole cards and boards should be separated using a ' ' divider.
Unknown Hole Cards:
Compute how likely a hand is to win against a random pair of hole cards. You can only specify one set of hole cards as unknown.Note: Performing calculations with unknown hole cards takes an excessively long time if community cards are not specified.
Multiprocess Holdem Calculator:
Takes the same command line options but utilizes multicore processors to increase the speed of computation.Windows users: Due to the process forking mechanism in Windows, parallel_holdem_calc might be slower than expected.
Best Free Texas Holdem Download
Library Calls:
If you want to use Holdem Calculator as a library, you can import holdem_calc or parallel_holdem_calc and call calculate(). The order of arguments to calculate() are as follows:
- Board: These are the community cards supplied to the calculation. This is in the form of a list of strings, with each string representing a card. If you do not want to specify community cards, you can set board to be None. Example: ['As', 'Ks', 'Jd']
- Exact: This is a boolean which is True if you want an exact calculation, and False if you want a Monte Carlo simulation.
- Number of Simulations: This is the number of iterations run in the Monte Carlo simulation. Note that this parameter is ignored if Exact is set to True. This number must be positive, even if Exact is set to true.
- Input File: The name of the input file you want Holdem Calculator to read from. Mark as None, if you do not wish to read from a file. If Input File is set, library calls will not return anything.
- Hole Cards: These are the hole cards for each of the players. This is in the form of a list of strings, with each string representing a card. Example: ['As', 'Ks', 'Jd', 'Td']
- Verbose: This is a boolean which is True if you want Holdem Calculator to print the results.
Calls to calculate() return a list of floats. The first element in the list corresponds to the probability that a tie takes place. Each element after that corresponds to the probability one of the hole cards the user provides wins the hand. These probabilities occur in the order in which you list them.
Copyright
Copyright (c) 2013 Kevin Tseng. See LICENSE for details.
Release historyRelease notifications RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size holdem_calc-1.0.0-py3-none-any.whl (14.4 kB) | File type Wheel | Python version py3 | Upload date | Hashes |
Filename, size holdem_calc-1.0.0.tar.gz (15.3 kB) | File type Source | Python version None | Upload date | Hashes |
Hashes for holdem_calc-1.0.0-py3-none-any.whl
Algorithm | Hash digest |
---|---|
SHA256 | b153aeaf57db68efb42b801d617823cddd07898af777a497309cc5874df6cfd1 |
MD5 | c93a59c622217c026573083492626827 |
BLAKE2-256 | ecc5ea3ed2f22ff936a22d9f983ff590e72252e4d505c04fcc7f0358502476e9 |
Hashes for holdem_calc-1.0.0.tar.gz
Algorithm | Hash digest |
---|---|
SHA256 | 28a124902c0b247b8651e326df680c488171325b212aeeb8809bed0d30d8f06a |
MD5 | 46fab1f2d4de43e725a69bb67d2f4500 |
BLAKE2-256 | 4520eeb82fb1d1470f32d97b386cef005a785c6c168b3057336cb29baf8eb736 |
pokercards.cards – Represent cards, decks and hands¶
Represents a single french-design card with it’s rank and suit.
Cards can be compared and ordered by rank. A card, relative toa card of the same rank but different suit, is compared as neitherhigher, lower nor equal.
Free Slots Vegas World
Parameters: |
|
---|---|
Raises : | ValueError |
Create a list of new cards.
Each argument should describe one card with rank and suit together.
Parameters: | args – One or more cards. |
---|---|
Returns: | List of new cards, one for each input parameter. |
Return type: | list of pokercards.cards.Card objects |
Raises : | ValueError |
Represents a single deck of 52 card.Card objects.
The deck could be imagined face down on a table. All internal listsrepresent the cards in order from bottom up. So dealing the topcard means poping last item from the list.
Deal the top card from the deck.
Returns: | pokercards.cards.Card instance |
---|
Shuffle the deck.
Compute the best hand from given cards, implementing traditional“high” poker hand ranks.
The hand object can be given more than five cards (as in TexasHold’em or similar variants) and the evaluation will pick the besthand.
Evaluated pokercards.cards.PokerHand objects arecompared and sorted by the rank of the hand.
Best Free Texas Holdem Game
List of pokercards.cards.Card objects to make the handfrom. The pokercards.cards.PokerHand.evaluate() methodshould be called after manual update to re-evaluate the updatedhand.
Following attributes are available after evaluating the hand.
Readonly rank of the hand (0 = high card to 8 = straight flush)
Readonly list of cards which complete the rank.
Readonly list of extra cards which can break a tie.
Parameters: |
|
---|
Evaluate the rank of the hand.
Should be called either implicitly at start by leavingparameter evaluate True when creating the hand orexplicitly by calling this method later, e.g. after changingthe cards attribute manually.