On Two Plus two poker hand evaluators, how do you get the best combination of 5 cards from 7 that you passed to her?

Is it possible to extract this information from an equivalence value?

I understand that the higher the equivalence value, the better. Category and rank can also be extracted from the equivalence value. But is there any way to find out what are the best 5-card combinations of 7 that you passed to him?

Twoplustwo is the fastest poker hand evaluator (14-15 million hands valued per second). You give your 7 cards, and he spills out the value of hand equivalence. The higher the value, the better the map.

Here's a great summary on twoplustwo: http://www.codingthewheel.com/archives/poker-hand-evaluator-roundup#2p2

The cached version of the link above: http://web.archive.org/web/20130116102452/http://www.codingthewheel.com/archives/poker-hand-evaluator-roundup

+6
source share
4 answers

(disclaimer: I am working on poker software, which in particular evaluates hands)

You give you 7 cards and splash out the value of hand equivalence.

There are several evaluators who do this, and if I'm not mistaken, some of them calculate more than one hundred million hands per second (!). These evaluators basically reduce to 7 array requests in a gigantic array, and only a few cycles are required to evaluate a hand (despite cache misses). I do not think that 14-15 million per second is anywhere. The CactusKev evaluator is 10 times faster if I'm not mistaken.

Now, to answer your question:

how do you get the best combination of 5 cards from 7 that you switched to it?

Well, this does not tell you, but once you have the strength of the hand, it can become very simple: you do not need to reinvent the wheel.

You can use force to simplify your "top five out of seven" calculations.

You can also use other libraries, giving you the five best cards at once (and not just their strength), or you can use the power to find the top five cards yourself.

I will give some examples ...

  • You know that you have a full house (aka “boat”), then you know that you are looking for three cards with the same rank, and then the best pairs (if there are two pairs, but you will definitely find at least one, because the evaluator told you that you have a boat).

  • You know that you have a straight line: find five cards that follow each other, starting with the best (beware of the case with a special case).

    You can also take a little part in the stream: you could take on all the forces and compare the forces that the evaluator gives you. If it matches, say, ten high, just find any card T, 9, 8, 7 and 6 (no matter what suit).

  • You know you don't have a pair: just take the five highest cards you find

  • and etc.

There are only a few different ranks ... They can be, for example:

NO_PAIR ONE_PAIR TWO_PAIRS SET STRAIGHT FLUSH FULL_HOUSE FOUR_OF_A_KIND STRAIGHT_FLUSH 

(you could, of course, create intermediate “direct wheels” and “direct flush wheels” and “royal flushes” if you like, etc.)

Once you know what type of hand you have (thanks to the quick evaluator you use), just switch to a piece of code that will find the top five out of seven for that particular hand.

I think this is a good way to continue working because you are using an ultrafast evaluator and then greatly simplify your logic.

At startup, you will need to evaluate strth once, for example, by computing:

 HIGHEST_NO_PAIR_HAND = ultraFastEvaluator( "As Kd Qh Jc 9d 5s 2c" ); HIGHEST_FULL_HOUSE = ultraFastEvaluator( "As Ac Ad Kh Ks 8s 2h" ); 

I'm certainly not a proponent of using strings here. This is just an example ...

Then you could find the five best for each hand:

  • calculate strength using a quick evaluator
  • this is & lt; = HIGHEST_NO_PAIR_HAND?
    • yes: take five high cards
    • no: this is & lt; = HIGHEST_ONE_PAIR_HAND? yes: take the highest pair + the highest three cards no: this & lt; = HIGHEST_TWO_PAIRS_HAND?
      • and etc.

So, in my opinion, you can reuse an API that immediately finds the five best of seven or completely rewrites your own, but it will be faster if you use the result of a quick analyzer to simplify your logic.

EDIT note that there is not necessarily one way to make the "five best of seven." For example, with As Ac on the Kc Kd Qh Qs 2c board, both As Ac Kc Kd Qh and As Ac Kc Kd Qs are the “five best” (the last queen costume doesn't matter).

+7
source

No, it is impossible to extract this information. The lookup table contains only equivalence values ​​that are broken down into the type and rank of the hand; no other information is stored.

If you need to evaluate millions of hands per second and get a winning combination for each, and not just the rank, you will need to use a different evaluator. If you only need to extract a winning hand rarely, you can use this evaluator and resort to a slower method of finding the best 5 cards if necessary.

+4
source

Old post, but I will give him a chance. If you use a table search (for example, the arrays with 7 maps mentioned above, as well as the Ray Wotton method), create a second table with your target information in the same slots. Example: I got into slot 167,452 to find my mark, now I will look at my other array in slot 167,452 to find my hand with 5 cards.

One card can be represented by 6 bits - 2 for a suit and 4 for a rank. 30 bits will give you the whole hand with 5 cards. It may not be so simple, but it is a general idea. I used this exact technique for some things that I did some time ago.

Alternatively, you can use all the 7-select-5-card combinations (21 of them, I think) and find out what corresponds to the original estimate.

+2
source

A two-hand appraiser can evaluate five cards. Here is the code for this in C #:

 int LookupFiveCardHand(int[] cards) { //assert cards size is 5 int p = HR[53 + cards[i++]]; p = HR[p + cards[i++]]; p = HR[p + cards[i++]]; p = HR[p + cards[i++]]; p = HR[p + cards[i++]]; return HR[p]; } 

Note that there are 6 arrays, despite 5 maps.

In any case, since the appraiser is very fast, you can simply compare each possible combination of 5 cards. A hand containing 7 cards will have 21 combinations of 5 cards. Code in C #:

 List<int> GetBestFiveCards(List<int> sevenCardHand) { List<List<int>> fiveCardHandCombos = new List<List<int>>(); // adds all combinations of five cards to fiveCardHandCombos for (int i = 0; i < sevenCardHand.Count; i++) { for (int j = i+1; j < sevenCardHand.Count; j++) { List<int> fiveCardCombo = new List<int>(sevenCardHand); fiveCardHandCombos.RemoveAt(j); // j > i, so remove j first fiveCardHandCombos.RemoveAt(i); fiveCardHandCombos.Add(fiveCardCombo); } } Dictionary<List<int>, int> comboToValue = new Dictionary<List<int>, int>(); for (int i = 0; i < fiveCardHandCombos.Count; i++) { comboToValue.Add(fiveCardHandCombos[i], LookupFiveCardHand(fiveCardHandCombos[i])); } int maxValue = comboToValue.Values.Max(); return comboToValue.Where(x => x.Value == maxValue).Select(x => x.Key).First(); //grab only the first combo in the event there is a tie } 
0
source

Source: https://habr.com/ru/post/911999/


All Articles