HenryRLee / PokerHandEvaluator

Poker-Hand-Evaluator: An efficient poker hand evaluation algorithm and its implementation, supporting 7-card poker and Omaha poker evaluation
Apache License 2.0
375 stars 80 forks source link

winning hand for omaha evaluator #24

Open elvis501 opened 4 years ago

elvis501 commented 4 years ago

Hi

I'm testing this for evaluating omaha winning hand. Everything is fine and I get short wining hand description as eg. "4 4 4 A K".

Is it any way to get or calculate "real" winning hand with ranks and suits from rank number? eg ( "4s 4c 4d Ac Kh" )

It would be very useful to see which are the winning cards from community and player cards.

HenryRLee commented 4 years ago

Hi @elvis501,

I wanted to implement the same idea as you did, but then I had two concerns when designing this API:

  1. We can see that sometimes the result isn't unique.
  2. The evaluator is using a hash function targeting the ranks. Therefore, some information is lost in the process, particularly the suit information. This is somehow a drawback of the perfect hash algorithm.

Having said that, you can still calculate the original cards and tell whether it is from community or player, given the sample hand (e.g. "4 4 4 A K") and the rank category (we need to know whether it is a flush). If it is a flush, simply find the most common suit from the nine cards. Otherwise, for each rank in the sample hand, we can greedily check whether the player set has a card with that rank. If there is, the rank belongs to the player, otherwise, it belongs to the community. And then take that card out of the player/community set before checking the next rank. You won't lose the correct answer in each iteration. Because if you do (i.e. there is a rank supposed to belong to the community, but had been assigned to the player), then eventually they should be able to compose a better 5-card hand, contradicting the fact that the sample hand is the best 5-card hand.

If you have trouble implementing the calculation, let me know and I will help out.

stiv-yakovenko commented 3 years ago

How do I use EvaluateOmahaCards if there are only 3 cards on the table?