A game is played with $n$ dice, and an additional parameter $r<=6$. The game has one player who must throw all $n$ dice on each round and add the score to the total. The game works as follows:
- The player starts with a score of zero.
- On each round, the $n$ dice are thrown and the sum of the dice is added to the player's total score.
- If the number on every dice is no larger than $r$, the game ends at the current total score.
- Otherwise the game continues to the next round. The game continues through multiple rounds until the value of every dice is no larger than $r$. For example, if $n=1$ and $r=2$, then the sequence of throws: $$ 4,6,3,2 $$ will score $4+6+3+2=15$. The game ends because the value of the die is no larger than 2 . If $n=2$ and $r=3$, then the sequence of throws: $$ (4,1),(3,2) $$ will score $4+1+3+2=10$. The game ends because the values of the dice 3,2 are both no larger than 3 . Your task is to write a function to calculate the expected total score of the game. The function should take two arguments, $n$ and $r$, and sutput the expected score as a floating point number.
What I have done is assume E[total score of n dice] as f(n), now by total expectation formula:
$$f(n) = (\frac{6-r}{6})^{n} (\frac{n(r+7)(6-r)}{2} + f(n)) + (1- (\frac{6-r}{6})^{n})\frac{n(1 +r)r}{2}$$. Does that right?