Use what you've learned about unfair dice to create zombie dice.
Download zombieDice.py:
Start IPython:
Now that you have played a few games of Zombie Dice and are familiar with the rules, you can write a program that rolls the dice with the same probability as the game.
Take a moment to think about what influences the result of each roll. Then, open zombieDice.py in gedit to view and edit the program. There are several lines throughout the program that must be completed before it will work. Look for comments in the code (lines starting with #
) for hints.
As you're editing the file, consider the following lines:
pickDice = choice( allDice )
rollResult = choice( pickDice )
What do you think is in the pickDice
variable after the first line is run?
How about rollResult
after the second line is run?
The individual dice rolls appear to behave as expected, but there is one aspect of the game that is still missing. Examine the code closely and compare it with actions you took each turn during the game. Can you determine what is missing? What would you need to change in the program to fix this?
If you're feeling brave, try making the changes to the code. Did your changes work as you expected?
Hint: Remember that the program starts from the beginning each time it is run. What do you need to add to the program in order to support multiple rolls?
Take a screenshot of your code, and answer these questions on your webpage.