All Projects → kennethshackleton → Skpokereval

kennethshackleton / Skpokereval

Licence: gpl-3.0
7-card Texas Hold'em hand evaluator

Programming Languages

cpp
1120 projects

Labels

Projects that are alternatives of or similar to Skpokereval

pokerwars.io-starterbot-python
A starter bot written in python for the pokerwars.io platform. To play: pull this code, register on pokerwars.io, get your API token and play!
Stars: ✭ 37 (-80.83%)
Mutual labels:  poker
Roomai
A toolkit for developing and comparing AI-bots of imperfect information and imcomplete information games.
Stars: ✭ 306 (+58.55%)
Mutual labels:  poker
Node Poker Odds Calculator
A pre-flop and post-flop odds calculator for Texas Holdem.
Stars: ✭ 48 (-75.13%)
Mutual labels:  poker
cypherpoker.js
An open source peer-to-peer poker platform with cryptocurrency integration written in JavaScript.
Stars: ✭ 72 (-62.69%)
Mutual labels:  poker
BitPoker
Decentralised peer to peer poker, using bitcoin
Stars: ✭ 36 (-81.35%)
Mutual labels:  poker
Casino Holdem
PHP 7+ Texas Holdem extension to Cysha/Casino
Stars: ✭ 17 (-91.19%)
Mutual labels:  poker
PokerTexter
SMS App for Poker Odds. Runs on Flask + Twilio + Heroku.
Stars: ✭ 17 (-91.19%)
Mutual labels:  poker
Pluribus
Implementation of Pluribus by Noam Brown & Tuomas Sandholm, a Superhuman AI for 6-MAX No-Limit Holdem Poker Bot.
Stars: ✭ 92 (-52.33%)
Mutual labels:  poker
Neuron poker
Texas holdem OpenAi gym poker environment with reinforcement learning based on keras-rl. Includes virtual rendering and montecarlo for equity calculation.
Stars: ✭ 299 (+54.92%)
Mutual labels:  poker
Pokr
Make agile estimating and planning easy with our online planning or scrum poker tool
Stars: ✭ 44 (-77.2%)
Mutual labels:  poker
Cards.jl
A package for representing hands of cards (quite compactly)
Stars: ✭ 41 (-78.76%)
Mutual labels:  poker
ACE eval
7-card Poker Hand Evaluator in 577 bytes
Stars: ✭ 36 (-81.35%)
Mutual labels:  poker
Poker
Fully functional Pokerbot that works on PartyPoker and PokerStars, scraping tables with Open-CV (adaptable via gui) and making decisions based on a genetic algorithm and montecarlo simulation for poker equity calculation. Binaries can be downloaded with this link:
Stars: ✭ 873 (+352.33%)
Mutual labels:  poker
41poker
a toolset for Texas Hold'em Poker
Stars: ✭ 13 (-93.26%)
Mutual labels:  poker
Texas Hold Em Poker
德州扑克服务器Go实现
Stars: ✭ 53 (-72.54%)
Mutual labels:  poker
scrum-planning-poker
Please feel FREE to try it and give feedback by searching Scrum敏捷估算 in WeChat mini program.
Stars: ✭ 30 (-84.46%)
Mutual labels:  poker
Casino Server
🔥 An online poker game server powered by Redis, node.js and socket.io
Stars: ✭ 721 (+273.58%)
Mutual labels:  poker
Deep Cfr
Scalable Implementation of Deep CFR and Single Deep CFR
Stars: ✭ 158 (-18.13%)
Mutual labels:  poker
Pypokergui
GUI application for PyPokerEngine
Stars: ✭ 72 (-62.69%)
Mutual labels:  poker
Rlcard
Reinforcement Learning / AI Bots in Card (Poker) Games - Blackjack, Leduc, Texas, DouDizhu, Mahjong, UNO.
Stars: ✭ 980 (+407.77%)
Mutual labels:  poker

SKPokerEval

A fast and lightweight 32-bit Texas Hold'em 7-card hand evaluator written in C++.

Travis status

Build Status

How do I use it?

#include <iostream>
#include "SevenEval.h"

int main() {
  // Get the rank of the seven-card spade flush, ace high.
  std::cout << SevenEval::GetRank(0, 4, 8, 12, 16, 20, 24) << std::endl;
  return 0;
}

The implementation being immutable is already thread-safe. There is no initialisation time.

How does it work?

We exploit a key-scheme that gives us just enough uniqueness to correctly identify the integral rank of any 7-card hand, where the greater this rank is the better the hand we hold and two hands of the same rank always draw. We require a memory footprint of just less than 135kB and typically six additions to rank a hand.

To start with we computed by brute force the first thirteen non-negative integers such that the formal sum of exactly seven with each taken at most four times is unique among all such sums: 0, 1, 5, 22, 98, 453, 2031, 8698, 22854, 83661, 262349, 636345 and 1479181. A valid sum might be 0+0+1+1+1+1+5 = 9 or 0+98+98+453+98+98+1 = 846, but invalid sum expressions include 0+262349+0+0+0+1 (too few summands), 1+1+5+22+98+453+2031+8698 (too many summands), 0+1+5+22+98+453+2031+8698 (again too many summands, although 1+5+22+98+453+2031+8698 is a legitimate expression) and 1+1+1+1+1+98+98 (too many 1's). We assign these integers as the card face values and add these together to generate a key for any non-flush 7-card hand. The largest non-flush key we see is 7825759, corresponding to any of the four quad-of-aces-full-of-kings.

Similarly, we assign the integer values 0, 1, 8 and 57 for spade, heart, diamond and club respectively. Any sum of exactly seven values taken from {0, 1, 8, 57} is unique among all such sums. We add up the suits of a 7-card hand to produce a "flush check" key and use this to look up the flush suit value if any. The largest flush key we see is 7999, corresponding to any of the four 7-card straight flushes with ace high, and the largest suit key is 399.

The extraordinarily lucky aspect of this is that the maximum non-flush key we have, 7825759, is a 23-bit integer (note 1<<23 = 8388608) and the largest suit key we find, 57*7 = 399, is a 9-bit integer (note 1<<9 = 512). If we bit-shift each card's flush check and add to this its non-flush face value to make a card key in advance, when we aggregate the resulting card keys over a given 7-card hand we generate a 23+9 = 32-bit integer key for the whole hand. This integer key can only just be accommodated by a standard 32-bit int type and yet still carries enough information to decide if we're looking at a flush and if not to then look up the rank of the hand.

How has the project evolved?

Taking v1.1 as the base line, the sampled relative throughput of random SevenEval access has been seen to have changed as follows (a higher multiple is better).

Version Relative throughput Reason                            
1.1                 1.00                                  
1.4.2               1.18 Hashing.                          
1.6                   1.50 Remove branching from flush case.
1.7                   1.53 Reduce the hash table.            
1.7.1               1.57 Reduce the rank hash table.      
1.8               1.93 Index cards by bytes.      
1.8.1               2.04 Simplify flush key. Smaller offset table.
1.9               2.04 Reduce the hash table.

At some point the cost of the sample for-loop iteration becomes relatively significant.

I want to contribute, how might I profile my change?

The project contains a profiler which might be used to help benchmark your changes.

g++ -c -std=c++11 -O3 Profiler.cpp
g++ -o profile Profiler.o
./profile

For optimisations this starts to be compelling with consistent gains of, say, 30% or more.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].