WARMUP
Yahtzee is a dice game.
There are 13 rounds. In each round, a player rolls 5 dice. They may pick any of those dice to re-roll, and after that re-roll, they may again re-roll any number of dice on last time.
After completing their rolls, they assign their final five dice to one of 13 scoring categories:
Category | Value | Category | Value |
---|---|---|---|
Aces | sum of 1s | Chance | sum of all dice |
2s | sum of 2s | 3 of a kind | sum of all dice OR 0 |
3s | sum of 3s | 4 of a kind | sum of all dice OR 0 |
4s | sum of 4s | 3 of a kind, 2 of another (Full House) | 25 OR 0 |
5s | sum of 5s | seq. of 4 | 30 OR 0 |
6s | sum of 6s | seq. of 5 | 40 OR 0 |
And a special category, Yahtzee for 5 of a kind, worth 50 OR 0.
Once a category has been used, it is no longer available. The “OR 0” categories award their points if the criteria is met. The Yahtzee is special because of the Yahtzee Bonus: if a player throws 5-of-a-kind and they have already scored a Yahtzee, then they get 100 points + whatever points for the category they assign the roll to, and they may use the roll to satisfy the Full House or Sequence categories.
HW Review
What did people have the most trouble figuring out? ask random
Programming
Thing big: what was this homework about? ask random
Key Research Idea
“Real” random numbers vs. pseudo-random numbers: in scientific research, we will often treat some phenomena as having a random component. Sometimes that means truly random (we’re pretty sure this is what is going on with quantum effects), some times it means random as far as we can tell (maybe we just haven’t measured all the right pieces), sometimes it means random for modeling purposes (chaos can be treated this way).
And that last point brings us round to pseudo-random numbers - they are meant to be “random as far as we can tell”, but also deterministically generable - that’s basically chaos, but with extreme attractor cycle lengths and paths.
Advanced Work
You may or may not have recognized, but you just performed your first Monte Carlo simulation. Now we will do Markov Chain Monte Carlo using Gillespie’s Method on the Lotke-Volterra Equations (a/k/a, the predator-prey model).
Gillespie’s method is about:
- Using rate of any event = sum of rate of all possible events to determine time-between-events, and
- determining which event, with probability proportional to their rates.
So:
The rates are:
event | rate |
---|---|
+x | $\alpha x$ |
-x | $\beta xy$ |
+y | $\delta xy$ |
-y | $\gamma y$ |
so the waiting time for any state is
and the probabilities of which event occurred at that time are
event | rate |
---|---|
+x | ${\alpha x \over \lambda}$ |
-x | ${\beta xy \over \lambda}$ |
+y | ${\delta xy \over \lambda}$ |
-y | ${\gamma y \over \lambda}$ |
HOMEWORK
Go back to your previous homework.
Re-factor (meaning: change to improve, simplify, speed up, etc.) any of them to use:
list
s,dict
s,tuple
s (regular ornamedtuple
s),set
s (regular orfrozenset
s)- comprehensions (search for the word)
- generators (again, search for the word, but this is a good abstract discussion of iteration)
Edit your $USERNAME-hw.md file, noting:
- which scripts you changed
- why