Skip to Content
 

Need help with dice probabilities.

25 replies [Last post]
Louard
Louard's picture
Offline
Joined: 02/09/2010

Things are going really well with my latest game Shake Out! (thanks again to AndyGB for the name), my testers are having fun, the numbers are gelling much better, the rules are looking good and full of helpful graphics BUUUUT!.. I'm afraid I've been lead astray!

I poked around the internet and ended up asking a mathier friend of mine for help with coming up with the single roll probabilities of rolling each possible combination used in the game on five dice. Here's my problem.. something doesn't add up and I'm afraid my ranking is wrong!
So, here are the different combinations as they are ranked now, from easiest to hardest to roll.
-Pair
-Three of A Kind
-Three Straight
-Four Straight
-Five Straight
-Four of A Kind
-Five of A Kind

The problem is, I'm pretty darn sure we calculated something wrong because a Three of a Kind should NOT be more probable than a Three Strait!

Please help me!

PS:If all goes well (including fixing this little issue) I should have this game available through The Game Crafter by mid December! YAY!

TLEberle
Offline
Joined: 08/10/2008
What are the odds you got for

What are the odds you got for each, and how did you arrive at them? Getting three straight shouldn't be terribly difficult because you can make that four ways, and you have a 1/6 or so chance of rolling three of a kind with 5d6.

veenstra
Offline
Joined: 03/27/2009
I think he's right.

I won't do the full calculation, but I think the point can be proven with a simple calculation assuming you are only throwing three die, one at a time. This will help to break down the probability:
When looking for a three of a kind, the first # can be anything, but the next two HAVE to be the same, there is only one acceptable number after the first one has been rolled... so it's 1/6 x 1/6 =1/36

When looking for a straight, the probability would be the same if the first number is a 1 (or 6)... one number has to be a 2 (or 5) and one has to be a 3 (or 4)...1/6 x 1/6 = 1/36

However, the difference with a straight is that often you have two possibilities...if you roll a 3, you can either get a 2 or a 4 (let's say a 2) a ; after that, you still have 2 options: a 1 or a 4. in this case...2/6 x 2/6 = 1/9.

Again, this is not the probabilities for your game, but it should demonstrate why three of a kind is more likely...there are more acceptable outcomes.

Hope that helps?

Maaartin
Offline
Joined: 05/15/2011
Forget math, use a program

There are only 6**5=7776 possible outcomes when counting ordered throws. They're equiprobable, so let a program count how many of them satisfy your criteria. Maybe I could do it for you if you specify precisely what "three straight" means. Maybe I could do the math.

Depending on the definition, I agree that "Three of a Kind should NOT be more probable than a Three Strait".

Louard
Louard's picture
Offline
Joined: 02/09/2010
Thanks guys.

Well, I haven't touched a script or code since high school, so brute forcing it with a program list isn't an option. However I can tell you how I got the (flawed?) probabilities I have now and what they are.
For the Two of A Kind, Three of A Kind, Four of A Kind, Five of A Kind and Five Straight I got the numbers from the Wizard of Odds website. These are:
Two of A Kind= 46.30%
Three of A Kind= 15.43%
Four of A Kind= 1.93%
Five of A Kind= 0.08%
Five Straight= 3.09%
In all these cases, the equation used boils down to figuring out how many permutations of the combination is possible then dividing that by 7776.

I asked a friend to help me with figuring out the two combinations not found on the website, the Three Straight and the Four Straight (BTW, a strait is simply a consecutive series of numbers.. so a Three Straight can be 1-2-3, 2-3-4, 3-4-5 or 4-5-6).
My friend came up with this equation:
((5 ^ (5 - N)) * (6 - (N-1)) * N! / (6^5))*100
Where N is the length of the straight... This, BTW gives the same result as above for a Five Straight, but, these are the probabilities it gives for the missing combinations:
Three Straight= 7.72%
Four Straight= 4.63%

Maaartin
Offline
Joined: 05/15/2011
It must be much more

Louard wrote:
((5 ^ (5 - N)) * (6 - (N-1)) * N! / (6^5))*100

This looks to simple for it to be able to be right.

Louard wrote:
Three Straight= 7.72%

Try throwing dice a couple of times... the probability must be much higher.

My program says it's 0.447530864198. The program is probably quite stupid, because of my limited knowledge of python and other reasons. It might even be wrong...

However, the probability is most probably too high to be of any use, isn't it?

Louard
Louard's picture
Offline
Joined: 02/09/2010
This would make it fit as

This would make it fit as second most likely after a pair.. which I think is actually right... What would your program say the probability is for a Four Straight?

BTW.. your program tries every possible (7776) combination and counts the valid ones?

Maaartin
Offline
Joined: 05/15/2011
Maaartin

Louard wrote:
This would make it fit as second most likely after a pair.. which I think is actually right... What would your program say the probability is for a Four Straight?

Here are the results:

2 straight:   6870 0.883487654321
3 straight:   3480 0.447530864198
4 straight:   1200 0.154320987654
5 straight:    240 0.0308641975309
6 straight:      0 0.0

The new version can be found under the old link.

Louard wrote:
BTW.. your program tries every possible (7776) combination and counts the valid ones?

Sure, the count is very low for a computer.

Tyberius
Offline
Joined: 07/14/2011
Dice probability

I'd love to take a whack at this also.
I need the inputs:
What is the total number of dice you're throwing?
How many faces are on each die?

I assume each dice has different numbers on all the faces, let me know if that's wrong.

Louard
Louard's picture
Offline
Joined: 02/09/2010
So, this is a Python script?

So, this is a Python script? How could I run this myself?

And if you don't mind, I'd be currious to see what you came up with for the other combinations (2 of A Kind, 3 of A Kind, 4 of A Kind and 5 of A kind) if only to cross reference with tht eresults from The Wizard Of Odds.

BTW, your 5 Straight (the only one I could cross refference checked out)

But your results would actually place the Three Straight and Four Straight(!) second and third after the 2 of A Kind!!

Maaartin
Offline
Joined: 05/15/2011
Who knows...

Louard wrote:
So, this is a Python script? How could I run this myself?

No idea... on Linux probably just chmod a+x louard_three_straight.py && ./louard_three_straight.py, on Windows you need to Google it out (I'm using Cygwin).

Louard wrote:
And if you don't mind, I'd be currious to see what you came up with for the other combinations (2 of A Kind, 3 of A Kind, 4 of A Kind and 5 of A kind) if only to cross reference with tht eresults from The Wizard Of Odds.

The problem is that such test won't help at all, since I'd need to add another -- mostly independent -- piece of code.

Louard wrote:
BTW, your 5 Straight (the only one I could cross refference checked out)

I know. My program may be wrong.

Louard wrote:
But your results would actually place the Three Straight and Four Straight(!) second and third after the 2 of A Kind!!

In case your results differ a lot from mine you can throw a couple of dice to verify it. What are your results?

pelle
pelle's picture
Offline
Joined: 08/11/2008
3

I was going to write a script for this when I got home from work, then I saw Maartin beat me to it, but I decided to try anyway. So now there are three different results to choose from. :)

2-same: 69.44 %
2-straight: 52.34 %
3-same: 19.29 %
3-straight: 25.21 %
4-same: 1.93 %
4-straight: 7.72 %
5-same: 0.08 %
5-straight: 3.09 %

I need to check my script again. It is probably very broken. I blame that I used some limited minimal-python that didn't seem to come with useful things like itertools.

BTW the easiest way to run python on any platform is probably simply "python scriptname.py". Or doubleclick the py-file in Windows (if you have the standard Windows-python installed, not cygwin-python)?

pelle
pelle's picture
Offline
Joined: 08/11/2008
Maaartin, I looked at your

Maaartin, I looked at your script now. Does it count a 4-straight also as a 3-straight and a 2-straight? I only counted it as a 4-straight (and same for other lengths).

Same for counting same cards, if there were 3 I wouldn't count it also as a pair.

Not sure what the OP was looking for?

A problem with my script I just realized is that it only looks for the longest possible straight, so if it is a "full house" it will only count the 3-straight, not the 2-straight. This is different from not counting a 3-straight as a 2-straight, but I'm also not sure what the OP intended in this case. Guess it depends on the rules if it matters what the two remaining dice are if 3 are a straight? But if it is a 3-straight and a pair both will count, so my script isn't even very consistent.

Maaartin
Offline
Joined: 05/15/2011
My probabilities are inclusive

pelle wrote:
I was going to write a script for this when I got home from work, then I saw Maartin beat me to it, but I decided to try anyway. So now there are three different results to choose from. :)

Very funny situation, indeed. :D

pelle wrote:
I need to check my script again. It is probably very broken. I blame that I used some limited minimal-python that didn't seem to come with useful things like itertools.

My problem is my minimal knowledge of python. :D I was using it quite intensively for maybe one week maybe one year ago, and everything I knew is gone...

pelle wrote:
Maaartin, I looked at your script now. Does it count a 4-straight also as a 3-straight and a 2-straight? I only counted it as a 4-straight (and same for other lengths).

Yes, it does, and I wanted to mention it, but forgot. However, it should be obvious from my figures:

2 straight:   6870 0.883487654321
3 straight:   3480 0.447530864198

Already now the sum exceeds 1.0.

I've modified the program to compute both probabilities. On each line there are exclusive count, exclusive probability (%), and inclusive probability (%):

5 straight:    240   3.086   3.086
4 straight:    960  12.346  15.432
3 straight:   2280  29.321  44.753
2 straight:   3390  43.596  88.349
1 straight:    906  11.651 100.000

The funny think is that "1 straight" is not that easy to get. :D

Our figure look closer now, but they surely differ by a fair amount.

Louard
Louard's picture
Offline
Joined: 02/09/2010
A hand within a hand within a hand.

Yes, ideally, the script should count a hand where a hand can be made.. So 12345 should count as a Three Straight, a Four Straight and a Five Straight.

Likewise 44444 is a two, a three, a four and a five of a kind.

I am a little concerned by the fact your numbers don't match Maaartin's.. and that some of the number do and some don't match what's found on the Wizard of Odds website.

pelle
pelle's picture
Offline
Joined: 08/11/2008
I'm supposed to know python,

I'm supposed to know python, but I haven't used it much in the last 6 months.

My script also output the result for 1-straight. For some reason my results for 1-straight and 5-straight matches your exclusive probabilities, but other than that things are off.

I guess it could be related to the "full house" problem I mentioned. If there is a 3-straight and a 2-straight, or a 4-straight and 1-straight, I think your script count both? Mine only count the longest. But then it's a weird coincidence that 1-straight works out to the same total anyway.

Too tired to think now. Maybe tomorrow night.

pelle
pelle's picture
Offline
Joined: 08/11/2008
Since I didn't (by design)

Since I didn't (by design) count inclusively like was intended, at least I have a reason to rewrite parts of my script anyway, and then I can post it. Since I use different methods to do things than what Maaartin did we get some useful confirmation, once we can get the same results.

Maaartin
Offline
Joined: 05/15/2011
Strange...

Louard wrote:
Yes, ideally, the script should count a hand where a hand can be made.. So 12345 should count as a Three Straight, a Four Straight and a Five Straight.

This corresponds with my inclusive probabilities.

pelle wrote:
I guess it could be related to the "full house" problem I mentioned. If there is a 3-straight and a 2-straight, or a 4-straight and 1-straight, I think your script count both? Mine only count the longest.

And so does mine. So for 12355 (or 12356) I count "123" as length 3 and nothing else for "exclusive". For "inclusive" I count this "3 straight" also as "2 straight" and "1 straight".

Could you post your script?

pelle
pelle's picture
Offline
Joined: 08/11/2008
It needs a big rewrite

It needs a big rewrite (bigger than you'd expect) to be inclusive. I will post it tomorrow!

pelle
pelle's picture
Offline
Joined: 08/11/2008
I'm not sure the Wizard of

I'm not sure the Wizard of Odds numbers above are inclusive? My new scripts finds 2-of-a-kind to be very likely (given that it also includes all 3-of-a-kind etc). But still only little agreement with Maaartin:

1-of-a-kind: 100.00 %
1-straight: 100.00 %
2-of-a-kind: 90.74 %
2-straight: 88.35 %
3-of-a-kind: 21.30 %
3-straight: 36.01 %
4-of-a-kind: 2.01 %
4-straight: 10.80 %
5-of-a-kind: 0.08 %
5-straight: 3.09 %

The script is a bit of a mess:
http://dl.dropbox.com/u/11540578/bgdfdice.py

I tested it for some smaller sets of dice, like "2d2 or 2d6" and it looked ok to me, but I may have overlooked some number that didn't come out right.

pelle
pelle's picture
Offline
Joined: 08/11/2008
I think my n-of-a-kind

I think my n-of-a-kind calculations are way off though, from some quick calculations. Too tired to think now. At least I posted my script so Maaartin could have a look. :)

Maaartin
Offline
Joined: 05/15/2011
Computation by hand for 4-straight

I'm tired as well and your program is quite complicated for the few minutes I could concentrate. I tried instead to compute the number of 4-straight which are no 5-straight by hand:

In the following let X denote any digit already present, so 1234X is one of 12341, 12342, 12343, and 12344. There are five cases:

  • 12346
  • 13456
  • 1234X
  • 3456X
  • 2345X

The first 2 cases occur in all 5! possible permutations, so we have 2*5!.

The last 3 cases occur for all 4 possible values of X in all 5! possible permutations, but due to the repeated digit X, we get each twice, so we have to divide by 2. So we get 345!/2 = 6*5!.

Altogether, we have (2+6)5! = 8120 = 960 possibilities, which coincides with my exclusive result (the inclusive result can be trivially obtained by adding the count of 5-straight). So I might be right.

pelle
pelle's picture
Offline
Joined: 08/11/2008
The fact that you can come up

The fact that you can come up with a way to calculate a result that is the same as what your script arrives at makes it more likely you are correct. I'm too tired to even think of how to calculate this.

Can you run your script for smaller problems and print out what permutations are counted? 5d6 results in way too many values to quickly look at them and see if any look wrong.

These are the 2-straights I find for 3d3:
set([[1, 1, 2], [1, 3, 2], [2, 3, 2], [3, 2, 1], [2, 2, 3], [2, 1, 2], [2, 3, 1], [1, 2, 3], [3, 2, 2], [1, 2, 1], [3, 2, 3], [2, 3, 3], [2, 1, 1], [1, 2, 2], [2, 1, 3], [3, 3, 2], [3, 1, 2], [2, 2, 1]])

Maybe that way we can identify what cases we are treating differently and finally solve this problem. Of course my script only counts inclusively, so I guess your script would not include the 6 permutations of [1,2,3] in that set.

Although I guess we could also print out everything for 5d6 and diff the results. Later, if nothing is seen for 3d3.

Maaartin
Offline
Joined: 05/15/2011
Let's make a diff

For 3d3 everything is fine. So I created an output of the form

1 [1, 1, 1, 1, 1]
1 [1, 1, 1, 1, 3]
...
5 [6, 5, 4, 3, 2]

The first number is the "straight number" of the following list. The file is sorted, so we can diff easily.

pelle
pelle's picture
Offline
Joined: 08/11/2008
got it!

I did find a problem with my script when looking at this. The way I look for straights is missing many longer than 2, except for 5 (and for d3 it would work for 1,2, and 3, so everything was correct). Stupid error.

My new inclusive numbers:
2-straight: 88.35 %
3-straight: 44.75 %
4-straight: 15.43 %
5-straight: 3.09 %

Exactly the same as Maartin's numbers! Phew. Diff is empty too.

Louard
Louard's picture
Offline
Joined: 02/09/2010
Thank you so much guys.

I had a coder friend have a look too and all your numbers match, which i think is a pretty good sign! I'm a big step closer to having Shake Out! ready for sale on TGC! Very exciting!

Syndicate content


forum | by Dr. Radut