Jump to content
BrainDen.com - Brain Teasers
  • 0

Dice Game


BMAD
 Share

Question

Two students play a game based on the total roll of two standard dice. Student A says that a 12 will be rolled first. Student B says that two consecutive 7s will be rolled first. The students keep rolling until one of them wins. What is the probability that A will win?

Link to comment
Share on other sites

20 answers to this question

Recommended Posts

  • 0

Use This simulaton on your microsoft office macro and you will get p = 1/2 as the answer

Use This code in your microsoft office 2010 and you will get p = 1/2

Sub DiceGameTest()
Randomize
Dim NewValue1 As Single
Dim NewValue2 As Single
Dim LastValue1 As Single
Dim LastValue2 As Single
Dim StudentAwin As Single
Dim StudentBwin As Single
Dim Winner As Single

For i = 1 To 5000000
   LastValue1 = 0
   LastValue2 = 0
   Winner = 0
   While Winner = 0
      LastValue1 = NewValue1
      LastValue2 = NewValue2
      NewValue1 = Int((6 * Rnd) + 1)
      NewValue2 = Int((6 * Rnd) + 1)
      If NewValue1 = 6 And NewValue2 = 6 Then Winner = 1
      If NewValue1 + NewValue2 = 7 And LastValue1 + LastValue2 = 7 Then Winner = 2
   Wend
   If Winner = 1 Then StudentAwin = StudentAwin + 1
   If Winner = 2 Then StudentBwin = StudentBwin + 1
   Winner = 0
Next i
total = StudentBwin + StudentAwin
Selection.TypeText Text:=str(StudentAwin / total)
End Sub

 

 

Link to comment
Share on other sites

  • 2

I have found two ways to solve this problem analytically - the first not so rigorous and the second more rigorous.  

First method: Let A be the event student A rolls a twelve which has a probability of 1/36.  Then the expected number of rolls for A to roll a 12 is 36 which can easily be calculated from the following equation:  

(1) E(A trials) = 1/36 + 35/36*[ E(A trials)+1]   solving this equation leads to E(A trials)=36.  in general if the probability per trial is p the expected number of trials till success is 1/p.

For B the calculation is a little more complicated:

(2) E(B trials) = 1/6*[1/6 * 2 + 5/6 * (E(B trials) + 2)] + 5/6* [E(B trials)+1] solving this equation leads to E(B trials) = 42.

Now comes the non-rigorous part - effectively the expected value of B rolling consecutive 7's being equal to 42 rolls corresponds to a 1/42 chance on each roll even though this does not correspond to the actual B events (for example B can't win on the first roll).  So using these relative probabilities in a standard way:

P(A) = 1/36

P(B) = 1/42

P(A)/[P(A)+P(B)] = 7/13 probability A wins before B wins.  This is the correct answer 0.538461 as the simulations confirm.

 

Now for the more rigorous way.  Essentially this a  Markov chain analysis (For reference see P. 364 Introduction to Probability - Bertsekas, Tsitsiklis).  There are 4 states in the  chain - two are absorbing -  one where A wins I will call a12, the other where B wins I will call a77.  The other two states are transient states, the start state which I will denote by as, and the state where the previous roll was a 7, I will denote by a17.  Each variable (as, a17, a77, a12)  represents the probability of ending in the final state where A wins (i.e. a roll of 12 before two consecutive 7's) given that they are starting in the current state represented by the variable.  The following equations apply:

a12 = 1

a77 =0

a17 = 29/36 * as + 6/36 * a77 + 1/36 * a12

as = 6/36 * a17 + 29/36 * as + 1/36 * a12

 

Solving these equations leads to as = 7/13.

 

 

Link to comment
Share on other sites

  • 0

If anyone understand a bit VBA programming, please check my code, wheather there are some mistake there.

What I do at the simulation is generating random number (1 to 6) twice in each turn, 
Let say dice1 = value1 and dice 2 = value2 than

if value1 = 6 and value2 = 6 then Student A win  (6+6 = 12)
if value1 + value2 = 7 and lastValue1 + lastValue2 = 7 then student B win
if no winner, I repeat until the winner found.

After the winner found, I repeat all the game again 5 million times
After 5 million times I compare student A winning times with student B winning times,
And I find both student have equal chance to win

It take about 10 to 15 second for my computer to do this simulation.

Link to comment
Share on other sites

  • 1

If anyone understand a bit VBA programming, please check my code, wheather there are some mistake there.

What I do at the simulation is generating random number (1 to 6) twice in each turn, 
Let say dice1 = value1 and dice 2 = value2 than

if value1 = 6 and value2 = 6 then Student A win  (6+6 = 12)
if value1 + value2 = 7 and lastValue1 + lastValue2 = 7 then student B win
if no winner, I repeat until the winner found.

After the winner found, I repeat all the game again 5 million times
After 5 million times I compare student A winning times with student B winning times,
And I find both student have equal chance to win

It take about 10 to 15 second for my computer to do this simulation.

I'm not familiar with VBA. But your code from above this post looks familiar enough to me (I use Python), that I think I know where you went wrong.

It doesn't look iike you allow for a roll where player 1 can win and player 2 can't (the first roll). 

Your procedure for a game should be this:

1. Roll two dice. If they total 12, player 1 wins and end

2. If not, store the roll in "last roll", then enter loop.

Loop:

3. Each iteration of loop, roll two dice,  if they total 12 player 1 wins or if (they total 12 AND "last roll" was 7), player 2 wins.

4. If 3 didn't terminate the loop, store the current roll in last roll, and go back to 3 until you get a winner. 

Link to comment
Share on other sites

  • 0

It doesn't look iike you allow for a roll where player 1 can win and player 2 can't (the first roll). 

Your procedure for a game should be this:

While Winner = 0
      LastValue1 = NewValue1   
      LastValue2 = NewValue2
      NewValue1 = Int((6 * Rnd) + 1)
      NewValue2 = Int((6 * Rnd) + 1)
      If NewValue1 = 6 And NewValue2 = 6 Then Winner = 1
      If NewValue1 + NewValue2 = 7 And LastValue1 + LastValue2 = 7 Then Winner = 2
   Wend

I have checked back my code, and I think nothing wrong there. Student A still can win even at first roll.

Link to comment
Share on other sites

  • 0

It doesn't look iike you allow for a roll where player 1 can win and player 2 can't (the first roll). 

Your procedure for a game should be this:

While Winner = 0
      LastValue1 = NewValue1   
      LastValue2 = NewValue2
      NewValue1 = Int((6 * Rnd) + 1)
      NewValue2 = Int((6 * Rnd) + 1)
      If NewValue1 = 6 And NewValue2 = 6 Then Winner = 1
      If NewValue1 + NewValue2 = 7 And LastValue1 + LastValue2 = 7 Then Winner = 2
   Wend

I have checked back my code, and I think nothing wrong there. Student A still can win even at first roll.

In your code, can student B win on the first roll? I don't know VBA, but if you try this:

While Winner = 0
      NewValue1 = Int((6 * Rnd) + 1)
      NewValue2 = Int((6 * Rnd) + 1)
      If NewValue1 = 6 And NewValue2 = 6 Then Winner = 1
      If NewValue1 + NewValue2 = 7 And LastValue1 + LastValue2 = 7 Then Winner = 2

      LastValue1 = NewValue1   
      LastValue2 = NewValue2
   Wend 

Do you get a different result?

markweitzman above, derived a rigorous Markov chain proof of the correct answer. If your code is not getting the same answer there must be something wrong.

Link to comment
Share on other sites

  • 0

On the first roll, p(12)=1/36, p(twice 7)=0

On each consecutive roll, p(12)=1/36 and p(twice 7)=1/36

p(12 wins)=1/36 + x
p(twice 7 wins)=x
p(one of them wins)=1=(1/36 +x) + (x)

=>x=35/72
=>p(12 wins)=37/72=51.39% which does not correspond to the simulation.

Where am I wrong?

Edited by harey
spoiler
Link to comment
Share on other sites

  • 1

 

Hidden Content

The part about each roll after the first having p(student B wins) = 1/36 is wrong. The probability of any roll resulting in student B winning is either 0 or 1/6, depending on whether or not a 7 was rolled just before it. Simplifying to the average doesn't quite work here, because there's a difference between searching for a result of a single roll and searching for a result of two consecutive rolls. Imagine if we were to keep rolling the dice, up to say 36000 rolls. We can easily establish that a 12 will be rolled on average 1000 times, but how many times will two consecutive sevens be rolled? To answer this question we have to decide how to handle groups of more than two consecutive sevens. And this question will be harder to answer.

The proof that markweitzman provided to the OP is correct. I will attempt to rephrase it as to avoid the perhaps unfamiliar concept of Markov chains.

Let x = p(A wins) (i.e. a 12 is rolled first). Let's call any roll other than a 7 or 12 a blank. The probability of a blank is 29/36.

If at any time we roll a blank, we are effectively back at the starting state, so p(A wins) is still x at that point.

There are four distinct ways for A to win:

1 - the first roll is a 12. (p = 1/36)

2 - the first roll is a blank, then A wins from there with probability x. (p = 29/36 * x)

3 - the first roll is a 7, the second is a 12. (p = 1/6 * 1/36)

4 - the first roll is a 7, the second is a blank, then A wins from there with probability x. (p = 1/6 * 29/36 * x)

Since those are the only ways A can win, and there is no overlap, p(A wins) is the sum of those probabilities. So x = 1/36 + 29x/36 + 1/216 + 29x/216, which simplifies to x = 7/13.

Link to comment
Share on other sites

  • 0

Maybe I am looking at this too simplistically

There is one way [out of 36] to make 12 [6,6]. P(12) = 1/36 = ~ 2.77%

There are 6 ways to make 7 [1,6] [2,5] [3,4] [4,3], [5,2] and [6,1]. So P(7) = 6/36 = 1/6

To make 2 consecutive 7's will be P(7) * P(7). So P(7,7) = 1/6 * 1/6 = 1/36 = ~ 2.77%

Thus the odds of making 12 or consecutive 7's are equal.

Therefore the P(A wins) = P(B wins) = 50%

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...