{"id":19171151,"url":"https://github.com/kennethshackleton/skpokereval","last_synced_at":"2026-06-28T11:00:29.366Z","repository":{"id":129403981,"uuid":"2072305","full_name":"kennethshackleton/SKPokerEval","owner":"kennethshackleton","description":"7-card Texas Hold'em hand evaluator","archived":false,"fork":false,"pushed_at":"2026-06-27T07:20:30.000Z","size":3850,"stargazers_count":249,"open_issues_count":1,"forks_count":61,"subscribers_count":19,"default_branch":"main","last_synced_at":"2026-06-27T09:13:29.472Z","etag":null,"topics":["c-plus-plus","cpp","evaluator","poker","poker-evaluator","poker-hands","skpokereval","texasholdem"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kennethshackleton.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-07-19T13:55:40.000Z","updated_at":"2026-06-27T07:20:32.000Z","dependencies_parsed_at":"2023-04-23T14:17:42.424Z","dependency_job_id":null,"html_url":"https://github.com/kennethshackleton/SKPokerEval","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/kennethshackleton/SKPokerEval","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethshackleton%2FSKPokerEval","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethshackleton%2FSKPokerEval/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethshackleton%2FSKPokerEval/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethshackleton%2FSKPokerEval/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kennethshackleton","download_url":"https://codeload.github.com/kennethshackleton/SKPokerEval/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethshackleton%2FSKPokerEval/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34885802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-28T02:00:05.809Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-plus-plus","cpp","evaluator","poker","poker-evaluator","poker-hands","skpokereval","texasholdem"],"created_at":"2024-11-09T09:57:16.501Z","updated_at":"2026-06-28T11:00:29.355Z","avatar_url":"https://github.com/kennethshackleton.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SKPokerEval\n\nA fast and lightweight 32-bit Texas Hold'em 7-card hand evaluator written in C++.\n\n## How do I use it?\n\n```cpp\n#include \u003ciostream\u003e\n#include \"SevenEval.h\"\n\nint main() {\n  // Get the rank of the seven-card spade flush, ace high.\n  std::cout \u003c\u003c SevenEval::GetRank(0, 4, 8, 12, 16, 20, 24) \u003c\u003c std::endl;\n  return 0;\n}\n```\n\nThe implementation being immutable is already thread-safe. There is no initialisation time.\n\n## How does it work?\n\nWe 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 108kB and typically six additions to rank a hand.\n\nTo 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.\n\nSimilarly, 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.\n\nThe extraordinarily lucky aspect of this is that the maximum non-flush key we have, 7825759, is a 23-bit integer (note 1\u003c\u003c23 = 8388608) and the largest suit key we find, 57*7 = 399, is a 9-bit integer (note 1\u003c\u003c9 = 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.\n\n## I want to contribute, how might I profile my change?\n\nThe project contains a [profiler](src/Profiler.cpp) which might be used to help benchmark your changes:\n\n```bash\ng++ -c -std=c++17 -O3 Profiler.cpp\ng++ -o profile Profiler.o\n./profile\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkennethshackleton%2Fskpokereval","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkennethshackleton%2Fskpokereval","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkennethshackleton%2Fskpokereval/lists"}