Ok, so I am making a Texas Hold\'em AI for my senior project. I\'ve created the gui and betting/dealing procedures, but I have reached the part where I need to determine who
The method used in ralu's post is by far the best alternative I've seen. I used this method in my own project, and its very fast.
Cliffs:
Do some preprocessing, to generate a table, containing one value for each distinct poker-hand. Make sure the table is sorted by hand-strength.
Each card-value has a corresponding prime-value. The table is indexed by the multiplication of each card-value in the hand. So to find the value of the hand AAAAK, you calculate the prime multiplication and use this as index for the table:
int prime = getPrime(hand); // Calculates A.getPrime()...*K.getPrime();
int value = table[prime];
(Sorry for the java syntax).
This way, AAAAK is the same hand as KAAAA, and you dont need a 5-dim table.
Note that you need to go through all combinations of the best 5 card hand, with the 7 cards you can choose from, to find the largest value, which is the real value of the hand.
You use a different table for flushes.
The table gets pretty beefy, as there are lots of wasted cells by this implementation. To counter this, you can create a map during preprocessing, which maps the large prime values to integer values, and use this as you source instead.