Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

short deck evaluation #23

Open
travisstaloch opened this issue Jun 29, 2020 · 2 comments
Open

short deck evaluation #23

travisstaloch opened this issue Jun 29, 2020 · 2 comments

Comments

@travisstaloch
Copy link
Contributor

Hello. I'm attempting to add support for short deck poker (9 rank deck 6-A rather than 13 rank 2-A). Right now I'm stuck trying to generate flush_sd and nonflush_sd look up tables (LUTs). I believe creating separate LUTs for this game is necessary because a flush beats a full house and A6789 is a straight in short deck. Would you agree that this is the best course? If so, can you recommend a strategy for creating these LUTs? I'm planning to submit a PR if i can figure out how to get this working.

I have calculated the number of distinct hands possible for each category as:

straight_flush:6,
four_kind: 72,
full_house:72,
flush:120,
straight:6,
three_kind:252,
two_pair:252,
one_pair:504,
high_card:120

Which gives these offsets:

6,78,150,270,276,528,780,1284,1404

I'm using the existing evaluate_5_cards method to find the correct rank/category. But I'm not sure how to construct the rest of the rank. Do you have any suggestions?

@HenryRLee
Copy link
Owner

HenryRLee commented Jun 30, 2020

Hi, @travisstaloch. If you allow some space in the value distribution (i.e. some value has no matching short deck poker hand), there is a much easier solution.

This is the standard deck 5-card hand distribution, with Full House better than Flush.

Hand Value Distinct Offset
Straight Flush 10 0
Four of a Kind 156 10
Full House 156 166
Flush 1277 322
Straight 10 1599
Three of a Kind 858 1609
Two Pair 858 2467
One Pair 2860 3325
High Card 1277 6185
7462

We can turn that distribution into the following, so that Flush beats Full House:

Hand Value Distinct Offset
Straight Flush 10 0
Four of a Kind 156 10
Flush 1277 166
Full House 156 1443
Straight 10 1599
Three of a Kind 858 1609
Two Pair 858 2467
One Pair 2860 3325
High Card 1277 6185
7462

Basically what you need to do is: after getting the value from evaluate_5_cards, if the value falls between 166 and 321 inclusively (which is a Full House), add an offset 1277 (subtract 166 from 1443) to the value. Else if the value is between 322 and 1598 inclusively (which is a Flush), add an offset -156 (subtract 322 from 166) to the value.

Now, we need to solve the edge case: the A 9 8 7 6 hand. Note that it can be a Straight or a Straight Flush. According to the 7426 table, the value of a suited A 9 8 7 6 hand is 747. Once you find out the value is 747 (before the flush/full house adjustment), adjust it to be 6. Similarly, once you get the value 6610 (the unsuited A 9 8 7 6), adjust it to be 1605.

@travisstaloch
Copy link
Contributor Author

Thanks so much for the advice. I'll be working on this soon. Sounds fairly easy as you described. I think I need to adjust the card ids I'm using so that 2 => 6 and T => A before evaluating so that the ranks will begin at the category beginning. Will let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants