Rolling Dice with Auto-counting
Download Source Code

Counting Loop
This program uses a loop to roll 3 dice 1000 times. Each
time, it automatically decides whether there was a MATCH
in the 3 dice or not. If a MATCH occurs, it automatically
adds 1 to MATCHES, which is a "running total" of the
number of times a match occurred. At the end it divides by
1000 to give the fraction of times that a match occurred.
Since the result is below 0.5, it means that a person betting on
this game should bet AGAINST a match, rather than
betting for a match.
Practice
- Download the program and run it
- Change the program so that it rolls 4 dice instead of 3.
Then change the if.. command so that it correctly
checks for a match in the 4 dice - the command must be
considerably longer. Then find out whether
MATCHES or non-matches are more likely with 4 dice.
- Change the program to calculate the total of the 4 dice -
e.g. 4+3+1+6 = 14 .
Count how often the total is above 15.
- Change the program to count how often a 6 occurs - that means
any of the dice could be 6.
Find out whether it is more likely that a 6 appears or that no 6
appears.
- Find out how often it happens that all 4 dice are the same.