GithubHelp home page GithubHelp logo

albertajuelo / pokerhand-eval Goto Github PK

View Code? Open in Web Editor NEW

This project forked from irr/lua-pokerhand-eval

0.0 3.0 0.0 685 KB

Poker Texas Hold'em Hand Evaluator using pure Lua

License: MIT License

Lua 100.00%
poker poker-evaluator lua pokerhandevaluator

pokerhand-eval's Introduction

PokerHand-eval

Build Status codecov License

Poker Texas Hold'em Hand Evaluator using pure Lua.

Contents

Overview

This is a pure Lua library to calculate the rank of the best [Texas Holdem] hand out of 5, 6, or 7 cards. It does not run the board for you, or calculate winning percentage, EV, or anything like that. But if you give it two hands and the same board, you will be able to tell which hand wins.

Also there is a two-card ranking/percentile algorithm (Credit to Zach Wissner-Gross).

This is a Lua port from the python library.

Origin

This repository is based on Ivan Ribeiro (@irr) work: https://github.com/irr/lua-pokerhand-eval

Requirements

Lua version required: 5.1 or 5.2.

Basic Usage

If using LuaRocks:

luarocks install pokerhand-eval

Otherwise, download https://github.com/AlberTajuelo/pokerhand-eval/zipball/master.

Alternately, if using GIT:

git clone git://github.com/AlberTajuelo/pokerhand-eval.git

cd pokerhand-eval 

luarocks make

Calculate Hand winning percentile without board cards:

    card = require "holdem.card"
    lookup = require "holdem.lookup"
    analysis = require "holdem.analysis"

    hand = { Card.new(2, 1), Card.new(2, 2) }
    board = {}
    rank, percentile = analysis.evaluate(hand, board)
    print(rank, percentile)
    -- Output: nil	0.52337858220211
    -- For 2 cards, rank will be nil and you must use percentile

Calculate hand winning percentile with three board cards:

    card = require "holdem.card"
    lookup = require "holdem.lookup"
    analysis = require "holdem.analysis"

    hand = { Card.new(2, 1), Card.new(2, 2) }
    board = { Card.new(10, 2), Card.new(14, 2), Card.new(13, 2), Card.new(7, 2) }
    rank, percentile = analysis.evaluate(hand, board)
    print(rank, percentile)
    -- Output: 420  0.6792270531401
    -- ps: less rank is better

Documentation

Card Rank

This table represents given a card rank what index is assigned. Rank is 2-14 representing 2-A (Ace).

Card Rank Index Symbol
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
9 9 9
10 10 T
Jack 11 J
Queen 12 Q
King 13 K
Ace 14 A

Card Suit

This table represents given a card suit what index is assigned. Suit is 1-4 representing in given order Spades, Hearts, Diamonds and Clubs.

Card Suit Index Symbol
Spades (♠) 1 S
Hearts (♥) 2 H
Diamonds (♦) 3 D
Clubs (♣) 4 C

Card Constructor

The Card constructor accepts two arguments, rank, and suit.

    card = require "holdem.card"

    aceOfSpades = card.Card(14, 1)
    twoOfDiamonds = card.Card(2, 3)

    -- or

    aceOfSpades = card.Card("AS")
    twoOfDiamonds = card.Card("2D")

Development

PokerHand-eval is currently in development.

WARNING: Not all corner cases have been tested and documented.

References

The algorithm for 5 cards is just a port of this algorithm.

Six and seven card evaluators using a very similar card representation and applying some of the same ideas with prime numbers. The idea was to strike a balance between lookup table size and speed.

You can search for more info using following references:

pokerhand-eval's People

Contributors

albertajuelo avatar irr avatar

Watchers

 avatar  avatar  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.