Problem 53850. Backgammon #4 - Dice Probabilities
Previous problems in this series have looked at how a backgammon board might be represented, and board positions manipulated and displayed. In this problem we take a break from looking at backgammon boards, and turn our attention to dice throws.
Backgammon is played with two standard six-sided dice.
Sometimes it is necessary to understand the chances of obtaining a particular dice throw, for example when trying to determine the risks of leaving a blot (a single stone), or when considering whether to offer or accept a double.
In this problem you are given a 'required' throw from two dice as an input vector - for example if you need to throw a 3 and a 6, the input vector will be:
[3,6]
You have to return the probablility (between 0 and 1) of obtaining such a throw.
Sometimes you only care about the value of one of the dice, so in that case the value of the other dice will be set to zero - for example if you need to throw at least one 2 on the two dice, and don't care what the other dice is, the input vector will be one of:
[2,0], [0,2]
Again you have to return the probablility (between 0 and 1) of obtaining such a throw.
If the input is not a valid throw, such as:
[0,0], [4,8], [-2,5]
you should return NaN.
Previous problem in series: Problem 53840. Backgammon #3 - Display a Board Position
Next problem in series: Problem 53780. Backgammon #5 - Valid Move?
Regexp cheats and other cheats are not appreciated and will be blocked if you use them.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers12
Suggested Problems
-
4483 Solvers
-
Given an unsigned integer x, find the largest y by rearranging the bits in x
1800 Solvers
-
Arrange Vector in descending order
10947 Solvers
-
172 Solvers
-
737 Solvers
More from this Author17
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!