Is there any easy method to compare two poker hands? I'm going about this pretty naively, so if anybody has experience doing this, it could be helpful.
First sort your cards from lowest to highest 2 to Ace regardless of suit. Then do comparing. If card[0]==card[3] or card[1]==card[4], you have 4 of a kind, ignore next 2 lines. If card[0]==card[2] or card[1]==card[3] or card[2]==card[4], you have 3 of a kind, ignore the next line.
There isn't an easy (and performant) way to do this, especially if you want to evaluate five-card subsets of seven-card hands, like in Texas Hold 'em.
You might want to check out pokersource which has some Java bindings.
Edit - an additional resource is the pokerai forums. I found quite a few Java algorithms there. They are regularly run through benchmarks and are often accompanied by enumeration algorithms for Monte Carlo simulation. This appears to be the main post.
I found this which seems promising.
You can also roll your own.
An example of a ready made Texas Hold'em 7- and 5-card evaluator can be found here with documentation and further explained here. All feedback welcome at the e-mail address found therein.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With