Does anyone know a fast algorithm for evaluating 7 card poker hands? Something which is more efficient than simply brute-force checking a every 21 5-card combination of hands fr
Of course, if you want to do it very fast. The algorithm i put before is too slow.
The table7462 shoul be in an array, not in a file.
Then, you should precalculate every different 7cards hands and store it to a database. There are 133.784.560 different 7cards combinations.
You should use this format (alphabeticall order):
"2c2d2h2s3c3d3h" and rank it
Store every 133.784.560 different combinations. You do 52C7 cicles, rank it and store it in a database. Maybe in a few days you have it ready. When you have it ready, you don´t need 21 combinations anymore, just put your hand sorted alphabetically and search for it in your database.
If you do that, you´ll see that you can calculate your odds against your opponents in real time whenever you need.
Believe me. I am not a programmer and i can do it. I know my odds at the flop in 3 seconds.
May I recommend https://github.com/chenosaurus/poker-evaluator/
It is written in JavaScript and uses a 128 MB HandRanks.dat file.
The code is just a few lines and very easy to port to any other language.
I developed an algorithm for 7-card hand evaluation without iterating all 21 combinations.
Basically, it splits the 7-card hand into two categories: flush and not a flush. If it's a flush, it would be easy to look up the value in a table of 8192 entries. If it's not a flush, it'll run a hash function with techniques of dynamic programming, and then look up the value in a hash table of 49205 entries.
If you are interested, please check my work at github.
https://github.com/HenryRLee/PokerHandEvaluator