Poker Documentation Release 0.30.0

Poker Documentation Release 0.30.0

Poker Documentation Release 0.30.0 Kiss György Sep 09, 2019 Contents 1 Contents 3 1.1 Installation................................................3 1.2 Basic operations.............................................3 1.2.1 Card suits............................................3 1.2.2 Card ranks............................................4 1.2.3 Cards..............................................4 1.2.4 Implementing a deck......................................4 1.2.5 Operations with Hands and Combos..............................4 1.3 Range parsing..............................................5 1.3.1 Defining ranges.........................................5 1.3.2 Normalization..........................................6 1.3.3 Printing the range as an HTML table..............................7 1.3.4 Printing the range as an ASCII table..............................7 1.4 Hand history parsing...........................................7 1.4.1 Parsing from hand history text.................................8 1.4.2 Parsing from file........................................8 1.4.3 Example.............................................8 1.4.4 API...............................................9 1.4.5 About hand history changes..................................9 1.5 Getting information from poker related websites............................9 1.5.1 PokerStars status........................................9 1.5.2 List of upcoming tournaments from PokerStars........................9 1.5.3 Information about a Two plus two forum member....................... 10 1.5.4 Getting the top 100 players from Pocketfives.......................... 11 1.6 Room specific operations........................................ 11 1.6.1 Manipulating PokerStars player notes............................. 11 1.7 Development............................................... 12 1.7.1 Git repository.......................................... 12 1.7.2 Versioning............................................ 12 1.7.3 Coding style........................................... 12 1.7.4 Dates and times......................................... 12 1.7.5 New hand history parser.................................... 13 1.7.6 Testing............................................. 13 1.8 Glossary................................................. 14 1.9 License.................................................. 15 i 2 API 17 2.1 Card API................................................. 17 2.1.1 Suit............................................... 17 2.1.2 Rank............................................... 17 2.1.3 Card............................................... 18 2.2 Hand API................................................. 18 2.2.1 Shape.............................................. 18 2.2.2 Hand.............................................. 18 2.2.3 Combo............................................. 19 2.2.4 Range.............................................. 20 2.3 Hand history parsing API........................................ 21 2.3.1 Constant values......................................... 21 2.3.2 Base classes........................................... 23 2.3.3 PokerStars............................................ 25 2.3.4 Full Tilt Poker.......................................... 25 2.3.5 PKR............................................... 26 2.4 Room specific classes API........................................ 26 2.4.1 Pokerstars player notes..................................... 26 2.5 Website API............................................... 27 2.5.1 Two Plus Two Forum API................................... 28 2.5.2 Pocketfives API......................................... 28 2.5.3 PokerStars website API..................................... 29 3 Repo and contact 31 4 Indices and tables 33 Python Module Index 35 Index 37 ii Poker Documentation, Release 0.30.0 A Python framework for poker related operations. It contains classes for parsing card Suits, Cards, Hand combinations (called Combos), construct hand Ranges and check for syntax, parse Hand histories. It can get information from poker related websites like Pocketfives, TwoplusTwo Forum, or PokerStars website by scraping them. In the long term, it will have a fast hand evaluator and an equity calculator. It uses the MIT license, so its code can be used in any product without legal consequences. It aims for quality, fully tested code and easy usability with nice APIs, suitable for beginners to play with. Contents 1 Poker Documentation, Release 0.30.0 2 Contents CHAPTER 1 Contents 1.1 Installation The package requires Python 3.6+ only from version 0.30.0. Simple from PYPI: $ pip install poker Advanced, directly from package in development mode: $ git clone [email protected]:pokerregion/poker.git $ cd poker $ pip install -e . 1.2 Basic operations 1.2.1 Card suits Enumeration of suits: >>> from poker import Suit >>> list(Suit) [Suit(''), Suit(''), Suit(''), Suit('')] Suits are comparable: >>> Suit.CLUBS< Suit.DIAMONDS True 3 Poker Documentation, Release 0.30.0 1.2.2 Card ranks Enumeration of ranks: >>> from poker import Rank >>> list(Rank) [Rank('2'), Rank('3'), Rank('4'), Rank('5'), Rank('6'), Rank('7'), Rank('8'), Rank('9 ,!'), Rank('T'), Rank('J'), Rank('Q'), Rank('K'), Rank('A')] Ranks are comparable: >>> Rank('2')< Rank('A') True Making a random Rank: >> Rank.make_random() Rank('2') 1.2.3 Cards Making a random Card: >>> Card.make_random() Card('As') Comparing Cards: >>> Card('As')> Card('Ks') True >>> Card('Tc')< Card('Td') True 1.2.4 Implementing a deck A deck is just a list of poker.card.Cards. Making a new deck and simulating shuffling is easy: import random from poker import Card deck= list(Card) random.shuffle(deck) flop= [deck.pop() for __ in range(3)] turn= deck.pop() river= deck.pop() 1.2.5 Operations with Hands and Combos >>> from poker.hand import Hand, Combo List of all hands: 4 Chapter 1. Contents Poker Documentation, Release 0.30.0 >>> list(Hand) [Hand('32o'), Hand('32s'), Hand('42o'), Hand('42s'), Hand('43o'), Hand('43s'), Hand( ,!'52o'), ..., Hand('JJ'), Hand('QQ'), Hand('KK'), Hand('AA')] Comparing: >>> Hand('AAd')> Hand('KK') True >>> Combo('7s6s')> Combo('6d5d') True Sorting: >>> sorted([Hand('22'), Hand('66'), Hand('76o')]) [Hand('76o'), Hand('22'), Hand('66')] Making a random hand: >>> Hand.make_random() Hand('AJs') 1.3 Range parsing The poker.hand.Range class parses human readable (text) ranges like "22+ 54s 76s 98s AQo+" to a set of Hands and hand Combos. Can parse ranges and compose parsed ranges into human readable form again. It’s very fault-tolerant, so it’s easy and fast to write ranges manually. Can normalize unprecise human readable ranges into a precise human readable form, like "22+ AQo+ 33 AKo" –> "22+ AQo+" Can tell how big a range is by Percentage or number of Combos. 1.3.1 Defining ranges Atomic signs X means “any card” AKQJT98765432 Ace, King, Queen, Jack, Ten, 9, . , deuce “s” or “o” after hands like AKo or 76s suited and offsuit. Pairs have no suit ('') - hands worse, down to deuces + hands better, up to pairs Available formats for defining ranges: Format Parsed range 22 one pair 44+ all pairs better than 33 66- all pairs worse than 77 55-33 55, 44, 33 1.3. Range parsing 5 Poker Documentation, Release 0.30.0 None of these below select pairs (for unambiguity): AKo, J9o offsuit hands AKs, 72s suited hands AJo+ offsuit hands above this: AJo, AQo, AKo Q8o, Q9o, QTo, QJo Q8o+ AJs+ same as offsuit 76s+ this is valid, although “+” is not neccessary, because there are no suited cards above 76s A5o- offsuit hands; A5o-A2o A5s- suited hands; A5s-A2s K7 suited and offsuited version of hand; K7o, K7s J8o-J4o J8o, J7o, J6o, J5o, J4o 76s-74s 76s, 75s, 74s J8-J4 both ranges in suited an offsuited form; J8o, J7o, J6o, J5o, J4o, J8s, J7s, J6s, J5s, J4s A5+ either suited or offsuited hands that contains an Ace and the other is bigger than 5. Same as “A5o+ A5s+”. A5- downward, same as above XX every hand (100% range) In this special case, pairs are also included (but only this) AX Any hand that contains an ace either suited or offsuit (no pairs) AXo Any offsuit hand that contains an Ace (equivalent to A2o+) AXs Any suited hand that contains an Ace (equivalent to A2s+) QX+ Any hand that contains a card bigger than a Jack; Q2+, K2+, A2+ 5X- any hand that contains a card lower than 6 KXs+ Any suited hand that contains a card bigger than a Queen KXo+ same as above with offsuit hands 7Xs- same as above 8Xo- same as above 2s2h, exact hand Combos AsKc Note: “Q+” and “Q-” are invalid ranges, because in Hold’em, there are two hands to start with not one. Ranges are case insensitive, so "AKs" and "aks" and "aKS" means the same. Also the order of the cards doesn’t matter. "AK" is the same as "KA". Hands can be separated by space (even multiple), comma, colon or semicolon, and Combo of them (multiple spaces, etc.). 1.3.2 Normalization Ranges should be rearranged and parsed according to these rules: • hands separated with one space only in repr, with “, ” in str representation • in any given hand the first card is bigger than second (except pairs of course) • pairs first, if hyphened, bigger first • suited hands after pairs, descending by rank • offsuited hands at the end 6 Chapter 1. Contents Poker Documentation, Release 0.30.0 1.3.3 Printing the range as an HTML table Range has a method to_html(). When you print the result of that, you get a simple HTML table representation of it. Range('XX').to_html() looks like this: You can format it with CSS, you only need to define td.pair, td.offsuit and td.suited selectors. It’s easy to recreate

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    43 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us