Thread Rating:
I'm trying to build my own odds calculator for Video Poker games. By using the Wizard's methodology i've got my program to correctly calculate the odds for Jacks or Better. But when I use the same system to calculate Deuces Wild it's not quite right. For DW "Full Pay" 100.76% my percentage actually comes to 100.6445%. If I check the amount of hand types for the starting hands it's all correct.
I've also randomly picked hands of various types (with and without deuces) and checked their best possible values and they all seemed to check out.
Anybody have any idea what I could be doing wrong? Thanks!
I get the following results per hand type:
Natural Royal Flush | 448.624.488 |
Four Deuces | 4.053.686.064 |
Wild Royal Flush | 36.049.009.344 |
Five of a Kind | 63.750.284.976 |
Straight Flush | 82.011.042.180 |
Four of a kind | 1.291.624.655.700 |
Full House | 422.743.243.968 |
Flush | 333.545.676.144 |
Straight | 1.123.965.512.016 |
Three of a kind | 5.655.113.890.644 |
Nothing | 10.919.924.891.676 | Total | 19.933.230.517.200 |
Quote: chemistryThanks for looking at it but i'm afraid that's the way it's supposed to be ordered. The wild's make it all screwy. At first I thought the same thing but then I looked again at the paytables on Wizard of Odds: https://wizardofodds.com/games/video-poker/tables/deuces-wild/.
Your listing should exactly match the Wiz's FP table. Are you handling the wilds correctly in cases where a hand contains more than one paying combination? (3 deuces and 2 clubs is quads AND a flush, 2 deuces and a pair is both 4OAK and a full house, etc.)
My listing comes out to the following.
Natural Royal Flush | 4 |
Four Deuces | 48 |
Wild Royal Flush | 480 |
Five of a Kind | 624 |
Straight Flush | 2068 |
Four of a Kind | 31552 |
Full House | 12672 |
Flush | 14472 |
Straight | 62232 |
Three of a Kind | 355080 |
Two Pair | 95040 |
One Pair | 1225008 |
High Card | 799680 |
It's really strange because after I couldn't find any fault in the way my script calculates all the hands I checked it with the information from this book sample: http://www.math.utah.edu/~ethier/sample.pdf. I got my script to calculate the numbers from several starting hand combinations that are given as an example and compared them. They completely matched up! Even when I made sure my script was using the least volatile way to calculate the best combination, the number stayed exactly the same. I've even changed the combination of similar hands (like in the Methodology, to the one in the book sample and i've run through all 2.5M+ hands instead of using the narrowed down list with multipliers. In every situation the numbers never change.
The only thing I can think of is that i'm doing something wrong with my lookup arrays in combination with the Wild Deuces and that, in some situations, the script doesn't use the optimal discard. I just can't figure out where it goes wrong. It works perfectly for JoB.
Four Deuces -6776760
Wild Royal Flush 252051648
Five of a Kind -68024880
Straight Flush -1076927100
Four of a kind -2802774876
Full House -422053272
Flush -1015604580
Straight 6301246260
Three of a kind -19670888868
Nothing 18501330696
Total 0
Positive numbers mean your table is higher than the Wiz.
Negative numbers mean your table is lower than the Wiz.
I would guess, since straights, Wild royals, and natural royals are all way over, nothings are way over, and the rest are way short, that your wild cards are not correctly counting as pairs-3-4oak and flushes when more than 1 deuce is in there; I think you've got a "wraparound" in your straights calculations where there needs to be a truncation at the ace in both ends, because the deuces are wild and by themselves do "wrap" or substitute. But it's like it's counting, say 3AQ22 as a wraparound straight instead of a 3oak, and doing the same to royals, where a deuce of hearts is part of a natural wraparound royal, not wild, and it's counting as royals things that should just be a straight flush, like 9-k. Not that I know anything, just think the truncation's not in there properly when it comes to either wilds or naturals.
If I have 4 deuces, I don't check for anything else and the hand value gets fixed.
Then I check if it's a flush by some clever bitmasking from Cactus Kev (My deuces have all suit bits turned on).
I do a reverse sort of the card ranks.
If my highest card is an Ace then i check if the second highest card is lower or equal to a 5. If so, it's always a straight 2,3,4,5,A.
If not then I check if my highest card - my lowest (non deuce) card is less than 5. If so it's also a straight.
If it's also a flush, Straight Flushes, Natural Royal Flushes and Wild Royal Flushes get marked.
If it's a Natural Royal Flush or Wild Royal Flush I stop checking for hand values.
Then I go for the non-unique card hands. Five of a Kind, Full House, etc.. avoiding to overwrite the original hand value if the new hand value would be lower than the already set hand value.
This way I don't believe wrap around straights are possible :(.
And the strange thing is the numbers add up to the list I found.
Quote: chemistry
If my highest card is an Ace then i check if the second highest card is lower or equal to a 5. If so, it's always a straight 2,3,4,5,A.
If not then I check if my highest card - my lowest (non deuce) card is less than 5. If so it's also a straight.
I don't think I follow your logic here. I think you probably just skipped steps in the explanation and not in the program, but there are lots and lots of hands that are A,x,x,x,5 and are not straights. A,2,3,3,5 is trip 3s and not a straight, for example.
Four Deuces -6776760 0.998331038
Wild Royal Flush 252051648 1.007041147
Five of a Kind -68024880 0.998934085
Straight Flush -1076927100 0.987038712
Four of a kind -2802774876 0.997834738
Full House -422053272 0.999002628
Flush -1015604580 0.996964369
Straight 6301246260 1.00563787
Three of a kind -19670888868 0.996533633
Nothing 18501330696 1.001697148
Total 0
Here's the table with the percentages of error added: sorry the format doesn't copy into this thread.
Quote: chemistryOh whoops. I forgot to explain one step. I check if there are only single non-deuce ranks before doing the whole straight check :)
There are definitely too many straights. Is the check for higher hands correct? A,2,2,2,5 is quad aces and not a straight?
My check for non-unique hands like 4K etc.. is as follows: (4 deuces, Natural Royals and Wild Royals are excluded from this check)
Of course, if the hand value is lower than the current hand value, the hand value doesn't change.
I check if the count of any rank is more than 1 if so:
If the highest count of any rank is four i set the hand value to 4K. If the hand has deuces (that can only be 1 or 4, I don't check for the amount only if it exists). It becomes 5K.
Else,
If the highest count of any rank is three. I check if the second highest rank count is two. If so i set the hand value to FH. If there are any deuces i set the hand value to 5K. If the second highest rank count isn't 2, i set the hand value to 3K. If there are any deuces, I set the hand value to 4K.
Else,
If the highest count of the rank is two. I check if the total amount of unique ranks is 4. If so, I set the hand value to 1P. If there are any deuces, I set the hand value to 3K. If the total amount of unique ranks is 3 I set the hand value to 2P. If there is one deuce in the hand the hand value becomes FH, if there are two deuces the hand value becomes 4K.
Else,
If the hand value is still HC and all cards are unique with a deuce, i set the hand value to 1P.
Quote: rdw4potusThere are definitely too many straights. Is the check for higher hands correct? A,2,2,2,5 is quad aces and not a straight?
In this situation it will become 4K aces unless it's a Straight Flush in which case it'll stay a Straight Flush.
Quote: rdw4potusThere are definitely too many straights. Is the check for higher hands correct? A,2,2,2,5 is quad aces and not a straight?
I've tested this with my script and this situation is checked correctly:
Ad, 2d, 2c, 2h, 5c ==> 4K
Ad, 2d, 2c, 2h, 5d ==> SF
Quote: chemistryI've tested this with my script and this situation is checked correctly:
Ad, 2d, 2c, 2h, 5c ==> 4K
Ad, 2d, 2c, 2h, 5d ==> SF
If you get those on the deal, what cards are you holding?
Quote: mipletIf you get those on the deal, what cards are you holding?
This was just a check of the hand value to make sure that my hand evaluator works correctly. Not the draw.
I went to bed and dreamed about this, so I had to get up and write it down.
1. There are 2 hands which do not account for wild cards. 1 is Natural Royal. The other is 4 deuces. Because, if they're all wild, they don't make anything else lower, and they're not included in a natural royal.
2. Looking at the Wizard's several tables with several probabilities, I noticed that some of them had the same number of possible combinations for these two hands, but most didn't match on either one. However, the number of natural royals doesn't depend on any wilds, so it should match the comparable number of JOB hands, but it doesn't match those either. Which tells me that for different paytables, a player must change their draw strategy to get the maximum out of each different DW machine, even if the basic strategy is similar.
3. Based on the differing number, and the fact that you get the exact number of possible hands matching, to me that indicates you have the cards' rank and relative hands' rank programmed correctly. What's missing has to be programming the hands for optimal play in every single case. The simulator somehow is differing in a hold preference when deciding what to hold and what to discard. If they were all strategized the same, the combinations for royals and 4 deuces would be constant. So, someplace in the optimal logic, you haven't programmed an exception or 3 to some rule like, "If you have 2 to a royal, and they are QJ, hold them above an outside straight, except when there's a penalty card from a SF that's a gap of only 2; then hold 3 to the SF." And then there's an asterisk beside that for a further exception when the moon is full. (Just kidding, Wiz...). But it's a strategy error for the draw, not a card value issue.
10.You should now have the number of combinations of all possible outcomes for all 32 ways to play the hand. Determine the expected value of each. For the play resulting in the greatest expected value, add to an array for the overall possible outcomes of the game the possible outcomes of that play. Remember to multiply by the associated weighting for the hand on the deal.
How are you determining the expected value of each? Manually?
Is the play resulting in the greatest expected value always the one being added to the array? Maybe two very similar options in a play are being chosen differently by you and the Wiz. How do you break first level ties, if 2 possible plays end up with the same highest hand rank at the same percentage, but have different secondary results?
How do you multiply in the weighting? Is it manual (more subject to clerical error)? Is the weighting scale he refers to here always a factor, and maybe missing on a subset of hands?
AS KS TC 8D 2D -- -- -- -- 2D 1.0337566226557902 2 s
AS KS TC 8D 2H -- -- -- -- 2H 1.0337566226557902 2 s
AS KS TC 7S 7C -- -- -- 7S 7C 0.5602220166512488 77 u
AS KS TC 7S 7D -- -- -- 7S 7D 0.5602220166512488 77 u
AS KS TC 7S 6S AS KS -- 7S 6S 0.5106382978723404 AK76 s
AS KS TC 7S 6C -- -- -- -- -- 0.3225460725622075 nothing s
AS KS TC 7S 6D -- -- -- -- -- 0.32199259553345994 nothing s
The first 5 are the dealt cards, the second 5 is the hold, then the ev for this hold, then a description of what is held. The last letter indicates whether the cards held were suited or non-suited.
Quote: CrystalMathI'm going to send you a PM with my email address. If you want, I'll send you a file with this format, containing all unique hands (and some extra):
AS KS TC 8D 2D -- -- -- -- 2D 1.0337566226557902 2 s
AS KS TC 8D 2H -- -- -- -- 2H 1.0337566226557902 2 s
AS KS TC 7S 7C -- -- -- 7S 7C 0.5602220166512488 77 u
AS KS TC 7S 7D -- -- -- 7S 7D 0.5602220166512488 77 u
AS KS TC 7S 6S AS KS -- 7S 6S 0.5106382978723404 AK76 s
AS KS TC 7S 6C -- -- -- -- -- 0.3225460725622075 nothing s
AS KS TC 7S 6D -- -- -- -- -- 0.32199259553345994 nothing s
The first 5 are the dealt cards, the second 5 is the hold, then the ev for this hold, then a description of what is held. The last letter indicates whether the cards held were suited or non-suited.
That's great. Thanks a lot! :) This will give me a great comparison tool for checking my results. I'm assuming it's only the optimal EV right?
Quote: chemistryThat's great. Thanks a lot! :) This will give me a great comparison tool for checking my results. I'm assuming it's only the optimal EV right?
You're welcome.
Yes, it only shows the optimal EV.
Quote: beachbumbabsSo reading the programming instructions, step 10 seems like it could be the culprit:
10.You should now have the number of combinations of all possible outcomes for all 32 ways to play the hand. Determine the expected value of each. For the play resulting in the greatest expected value, add to an array for the overall possible outcomes of the game the possible outcomes of that play. Remember to multiply by the associated weighting for the hand on the deal.
How are you determining the expected value of each? Manually?
Is the play resulting in the greatest expected value always the one being added to the array? Maybe two very similar options in a play are being chosen differently by you and the Wiz. How do you break first level ties, if 2 possible plays end up with the same highest hand rank at the same percentage, but have different secondary results?
How do you multiply in the weighting? Is it manual (more subject to clerical error)? Is the weighting scale he refers to here always a factor, and maybe missing on a subset of hands?
That's what i'm doing. I get the expected value from my predefined arrays that Wiz talks about in his methodology. I've got my array of 134,459 unique hands with multipliers and even tried with 102,359 unique hands with multipliers (you can bundle the deuce hands see: http://www.math.utah.edu/~ethier/sample.pdf). Adding up all unique hands * multiplier gives me the 2.5m+ unique hands.
When there are multiple choices of discards with equal EV I choose the least volatile one (throwing away less cards), if in this situation there are still multiple ways of discarding that amount of cards I just pick the first one that I found. Actually.. might that be an issue? Because I was thinking that in that scenario it actually wouldn't matter but I might be wrong on that one...
Thanks all! CrystalMath in particular for helping me out with the holds file. :)
My percentage is exactly the same but I think i'm doing something different / wrong with the volatility so my results per type aren't exactly the same but I can live with that :)
Quote: chemistryMy percentage is exactly the same but I think i'm doing something different / wrong with the volatility so my results per type aren't exactly the same but I can live with that :)
Having the return match exactly, but the hand probabilities and overall variance/standard deviation differ, is normal with FPDW. It is because there are hands where two plays are tied for the "best play" but the two plays have a different variance. Unless you specifically calculate the variance for each play and go with the least volatile play, the end result (other than the return) is likely to differ. There are other games where this situation arises as well.
So, it sounds like you fixed the problem. Congratulations!