3

In an effort to create the fastest possible monte carlo texas hold'em hand analyzer with C++, I am currently looking into the subject of hand evaluation.

As many of you may know, there are quite a number of hand evaluators, open source, out there. After giving it some thought, I settled on the "Two Plus Two hand evaluator" (so named since it was first introduced on the two plus two forum).

This is one of the fastest known evaluators out there, and uses array lookups to quickly find the value of a hand.

Now, for the function, you need to pass in an array with the cards you are interested in. Example:

int Cards[] = { 3, 5, 10, 17, 23, 24, 32 };
int hv = HandValue(Cards);

With values between 1 and 52. Now, my question is: What cards do these integers correspond to? Is a 3 an ace of spades? A three of hearts? I have scoured google, the two + two forum, various pages where hand evaluators are presented, the source file for the build-up of the array. All in vain. So I am hoping that someone here can point me in the right direction of where I can find this information, or give it to me outright.

The source where the evaluators are taken from is this excellent article: http://www.codingthewheel.com/archives/poker-hand-evaluator-roundup#cactus_kev Which explains all the evaluators individually.

Mark Anderson
  • 2,399
  • 3
  • 15
  • 21
  • 3
    I'd guess 1-13 is one color, and so on. Then the actual numbers doesn't really matter. 1,14,27,39 are all aces of different colours. – dutt Feb 12 '13 at 21:26
  • If you include a URL for the source, we'd know which eval you meant. – Mel Nicholson Feb 12 '13 at 21:31
  • Hi dutt, just tested it, and that can't be right. Also, knowing the correct number is important if the user wishes to enter a specific color (say: spades) – Mark Anderson Feb 12 '13 at 21:42
  • well typically you would have two things to store: value and suit. Typically we use 1-12 to represent Ace-King and 1-4 to represent suits however you want. The rest of the logic is based on the rest of your code – Dan Bradbury Feb 12 '13 at 21:44
  • use an enumeration for the card rank (ace, 2, 3... king) and another for the suit (heart...clubs). like Dan says – Sellorio Feb 12 '13 at 21:51
  • ... or a bitfield - 4 bits for rank and 2 for suit with one of the invalid rank values usable for jokers... There are many different and valid ways to represent a deck of cards. We'd need to see the actual source code you're referencing to know what was used there... – twalberg Feb 12 '13 at 21:55
  • Use the source, Luke. Or at least give us a link so we can. – Robᵩ Feb 12 '13 at 21:56
  • I understand the TwoPlusTwo (aka. RayW) algorithm needs to traverse hands in order. How can you traverse all 133+ million hands in order when you're taking random samples with Monte Carlo? – étale-cohomology Apr 21 '16 at 18:02

1 Answers1

4

I didn't verify this, but it appears to be:

"2c": 1,
"2d": 2,
"2h": 3,
"2s": 4,
"3c": 5,
"3d": 6,
...
"kh": 47,
"ks": 48,
"ac": 49,
"ad": 50,
"ah": 51,
"as": 52

ref: https://github.com/chenosaurus/poker-evaluator/blob/master/lib/PokerEvaluator.js

Robᵩ
  • 163,533
  • 20
  • 239
  • 308
  • I believe this would be used as a definition for the object that I had proposed earlier. The object would be 2 enums first for rank and second for suit. You can see that a function to look up this definitive value would not be difficult to write. If wanted I can write up a formal answer – Dan Bradbury Feb 12 '13 at 22:21
  • Hi! I have tested what you have provided, and as far as I can tell, this is the right combination! Thank you very much indeed. I don't know how you found this. Kudos to you! – Mark Anderson Feb 13 '13 at 08:24