Thread Rating:

chemistry
chemistry
  • Threads: 1
  • Posts: 13
Joined: Aug 13, 2013
August 13th, 2013 at 2:19:37 PM permalink
Hello everyone!

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
beachbumbabs
beachbumbabs
  • Threads: 101
  • Posts: 14268
Joined: May 21, 2013
August 13th, 2013 at 5:33:26 PM permalink
There's something wrong with your 4OAK number. I think it's the 1 in front of the first decimal. I also think there's something screwy in the full house. Numbers, reading bottom to top, should be smaller at each step, but those 2 are out of whack somehow. Your paytable seems to be in the right order, but those 2 numbers can't be correct.
If the House lost every hand, they wouldn't deal the game.
beachbumbabs
beachbumbabs
  • Threads: 101
  • Posts: 14268
Joined: May 21, 2013
August 13th, 2013 at 5:50:52 PM permalink
Looking at it even more, the number next to 4oak is about right for the straight number, the number next to straight is about right for the flush. (proportionately to each other, anyway; no idea if it's a simple scramble of the correct numbers).
If the House lost every hand, they wouldn't deal the game.
chemistry
chemistry
  • Threads: 1
  • Posts: 13
Joined: Aug 13, 2013
August 13th, 2013 at 6:24:26 PM permalink
Thanks 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/.
beachbumbabs
beachbumbabs
  • Threads: 101
  • Posts: 14268
Joined: May 21, 2013
August 13th, 2013 at 6:37:33 PM permalink
Thanks! I see that as well. Sorry I couldn'tt help; thought it was maybe a simple clerical error.
If the House lost every hand, they wouldn't deal the game.
rdw4potus
rdw4potus
  • Threads: 80
  • Posts: 7237
Joined: Mar 11, 2010
August 13th, 2013 at 6:37:47 PM permalink
Quote: chemistry

Thanks 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.)
"So as the clock ticked and the day passed, opportunity met preparation, and luck happened." - Maurice Clarett
chemistry
chemistry
  • Threads: 1
  • Posts: 13
Joined: Aug 13, 2013
August 13th, 2013 at 7:04:06 PM permalink
It should. I rolled through all the possible combinations and checked the results of my hand evaluator with the list from Cactus Kev's website: http://www.suffecool.net/poker/wild.html.

My listing comes out to the following.

Natural Royal Flush4
Four Deuces48
Wild Royal Flush480
Five of a Kind624
Straight Flush2068
Four of a Kind31552
Full House12672
Flush14472
Straight62232
Three of a Kind355080
Two Pair95040
One Pair1225008
High Card799680


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.
beachbumbabs
beachbumbabs
  • Threads: 101
  • Posts: 14268
Joined: May 21, 2013
August 13th, 2013 at 7:05:31 PM permalink
Natural Royal Flush 8421732
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 the House lost every hand, they wouldn't deal the game.
chemistry
chemistry
  • Threads: 1
  • Posts: 13
Joined: Aug 13, 2013
August 13th, 2013 at 7:19:41 PM permalink
My check (rather cruedly) for straights is as follows:

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.
rdw4potus
rdw4potus
  • Threads: 80
  • Posts: 7237
Joined: Mar 11, 2010
August 13th, 2013 at 7:26:22 PM permalink
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.
"So as the clock ticked and the day passed, opportunity met preparation, and luck happened." - Maurice Clarett
chemistry
chemistry
  • Threads: 1
  • Posts: 13
Joined: Aug 13, 2013
August 13th, 2013 at 7:35:36 PM permalink
Oh whoops. I forgot to explain one step. I check if there are only single non-deuce ranks before doing the whole straight check :)
beachbumbabs
beachbumbabs
  • Threads: 101
  • Posts: 14268
Joined: May 21, 2013
August 13th, 2013 at 7:36:41 PM permalink
You know what another factor might be, because I divided all the values, and every one is off one way or the other by less than 1%, I think maybe 3 of your 4 deuces are wild, but the 4th deuce might be natural when it goes with the other cards as if it weren't wild but would complete a hand, and that natural deuce could be the wraparound and also not counting as wild in making flushes or 3-4oak. Can you break down the "nothings" into 1 pair, 2 pair, and 5 non-matched cards? That might show you better than anything else where the problem is.
If the House lost every hand, they wouldn't deal the game.
beachbumbabs
beachbumbabs
  • Threads: 101
  • Posts: 14268
Joined: May 21, 2013
August 13th, 2013 at 7:41:51 PM permalink
Natural Royal Flush 8421732 1.019131484
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.
If the House lost every hand, they wouldn't deal the game.
rdw4potus
rdw4potus
  • Threads: 80
  • Posts: 7237
Joined: Mar 11, 2010
August 13th, 2013 at 7:47:34 PM permalink
Quote: chemistry

Oh 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?
"So as the clock ticked and the day passed, opportunity met preparation, and luck happened." - Maurice Clarett
chemistry
chemistry
  • Threads: 1
  • Posts: 13
Joined: Aug 13, 2013
August 13th, 2013 at 7:49:40 PM permalink
I did that for the list of possible starting hand combinations and it matches with the list I found.

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.
Ibeatyouraces
Ibeatyouraces
  • Threads: 68
  • Posts: 11933
Joined: Jan 12, 2010
August 13th, 2013 at 7:50:17 PM permalink
deleted
DUHHIIIIIIIII HEARD THAT!
chemistry
chemistry
  • Threads: 1
  • Posts: 13
Joined: Aug 13, 2013
August 13th, 2013 at 7:53:19 PM permalink
Quote: rdw4potus

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?



In this situation it will become 4K aces unless it's a Straight Flush in which case it'll stay a Straight Flush.
chemistry
chemistry
  • Threads: 1
  • Posts: 13
Joined: Aug 13, 2013
August 13th, 2013 at 8:07:02 PM permalink
Quote: rdw4potus

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?



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
miplet
miplet 
  • Threads: 5
  • Posts: 2142
Joined: Dec 1, 2009
August 13th, 2013 at 8:10:48 PM permalink
Quote: chemistry

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


If you get those on the deal, what cards are you holding?
“Man Babes” #AxelFabulous
chemistry
chemistry
  • Threads: 1
  • Posts: 13
Joined: Aug 13, 2013
August 13th, 2013 at 8:45:35 PM permalink
Quote: miplet

If 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.
beachbumbabs
beachbumbabs
  • Threads: 101
  • Posts: 14268
Joined: May 21, 2013
August 13th, 2013 at 9:36:05 PM permalink
Ok.

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.
If the House lost every hand, they wouldn't deal the game.
beachbumbabs
beachbumbabs
  • Threads: 101
  • Posts: 14268
Joined: May 21, 2013
August 14th, 2013 at 8:52:56 AM permalink
So 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?
If the House lost every hand, they wouldn't deal the game.
CrystalMath
CrystalMath
  • Threads: 8
  • Posts: 1911
Joined: May 10, 2011
August 14th, 2013 at 9:34:55 AM permalink
I'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.
I heart Crystal Math.
chemistry
chemistry
  • Threads: 1
  • Posts: 13
Joined: Aug 13, 2013
August 14th, 2013 at 9:57:58 AM permalink
Quote: CrystalMath

I'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?
CrystalMath
CrystalMath
  • Threads: 8
  • Posts: 1911
Joined: May 10, 2011
August 14th, 2013 at 10:15:38 AM permalink
Quote: chemistry

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?



You're welcome.

Yes, it only shows the optimal EV.
I heart Crystal Math.
chemistry
chemistry
  • Threads: 1
  • Posts: 13
Joined: Aug 13, 2013
August 14th, 2013 at 10:20:03 AM permalink
Quote: beachbumbabs

So 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...
chemistry
chemistry
  • Threads: 1
  • Posts: 13
Joined: Aug 13, 2013
August 14th, 2013 at 2:47:18 PM permalink
I think I found the issue. For almost every EV check my script works but there is one weird one in there that gives a negative amount for a possibility of 4Ds with keeping 5s, Js, 2c. Very weird....
beachbumbabs
beachbumbabs
  • Threads: 101
  • Posts: 14268
Joined: May 21, 2013
August 14th, 2013 at 3:02:33 PM permalink
Progress!! Good for you.
If the House lost every hand, they wouldn't deal the game.
chemistry
chemistry
  • Threads: 1
  • Posts: 13
Joined: Aug 13, 2013
August 14th, 2013 at 3:55:29 PM permalink
WOW! Incredible. I used the wrong indexing function (handIndex2 instead of handIndex3) when doing the + / - for throwing away all cards. I can't believe I didn't see that one before! One small typo is keeping me at this for four days now...

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 :)
JB
Administrator
JB
  • Threads: 334
  • Posts: 2089
Joined: Oct 14, 2009
August 14th, 2013 at 7:39:54 PM permalink
Quote: chemistry

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 :)


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!
  • Jump to: