Giter VIP home page Giter VIP logo

pokerlib's Introduction

pokerlib

A library of poker primitives in go

Features:

  • Foundation data types for Card, Hand and Deck
  • Hand ranking. Calculates best 5 card hand out of any set of cards.
  • Hand rank encoding
  • English language hand descriptions Ex: Full house, Kings full of 8's, An Ace high flush, etc.]]
  • Hand evaluation logging
  • Odds calculations

Rank representation:

Each 5 card hand has a unique 32-bit encoding, this value is called the Hand Rank.
The 32 bits contains info about the type of hand (Flush, straight, etc), as well as the index of each of the 5 cards. The encoding is arranged such that a better hand will be represented by bigger value (interpreting the handrank bits as a 32-bit unsigned int with simple BCD encoding)

32 bit encoding:

  bits 27-20 contains the hand kind 
  bits 19-16 card
  bits 15-12 card
  bits 11-8  card
  bits 7-4   card
  bits 3-0   card

Each card in the hand is represented as a 4 bit value. The least signaficant 20 bits of the rank represent the 5 cards in order of hand evaluation signficance. I.e. for a pair, the 2 cards in the pair are the left most 2 cards, no matter if they are Kings or 2's...

Examples:   

            hand:   A♥ A♣ K♦ K♣ Q♥   (2 Pair, Ace's and King's)

            (2 pair)     (Ace)  (Ace)  (King)  (King) (Queen)
    rank:   00000011     1110   1110   1101    1101   1100       = 4124124


            hand:   2♥ 2♣ 2♦ 7♣ 7♥   (2 Pair, Ace's and King's)

            (Full House) (Two)  (Two)  (Two)  (Seven) (Seven)
    rank:   00000111     0010   0010   0010   0111    0111      = 7479927

Hand odds

Win and Tie probabilities can be calculated given a set of hand hole cards, and additionally 0-5 common cards and a deck.

The Monte Carlo method is used.

pokerlib's People

Contributors

rbaderts avatar

Stargazers

Jeff Federman avatar

Watchers

James Cloos avatar

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.