# Moose Hunting Probability Game
[[Red Bull Data Scientist]]
>[!Problem]
>A linear game board has 12 spaces. A moose starts on space 7, and a hunter on space 1. On each game turn. a 6-sided die is rolled. On a result of 1 to 4, the moose moves that many spaces forward. On a result of 5 or 6, the hunter moves that many spaces forward. The moose wins if it reaches space 12 (or more). The hunter wins if she catches the moose (i.e. the same or higher space).
>
![[moose_hunting_game.jpg]]
>[!Questions]
>1. What are the probabilities of winning for the moose and the hunter?
>2. What is the probability distribution associated with this game?
>3. What is the expected number of die throws until the game ends?
>[!Note]
>In the best case scenario, this probelm is solved with [[Markov Chains]]
## Moose Hunting -- A Markov Chain
>[!question]
>How can we represent the *Moose Hunting* problem using a [[Markov Chains]]?
## A Probabilistic Model
$
\begin{align}
P(h, g) &= \frac{1}{6} \bigg(P(h,m+1) + P(h, m+2) + P(h, m+3) + P(h, m+4) + P(h+5, m) + P(h+6, m) \bigg) \\
\\
\text{With:}\\
&P(h, m) = 1 \text{ when } m \geq 12 \\
\\
&P(h, m) = 0 \text{ when } h \geq m
\end{align}
$
### Solution via Recurrsion
```python
def moose_game(hunter_pos, moose_pos, move_num):
if hunter_pos >= moose_pos:
return 1/6**move_num
if moose_pos >= 12:
return 0
prob = 0
for pos in [5, 6]:
prob += moose_game(hunter_pos+pos, moose_pos, move_num+1)
for pos in [1, 2, 3, 4]:
prob += moose_game(hunter_pos, moose_pos+pos, move_num+1)
return prob
moose_game(1, 7, 0)
```
### R Version
```R
moose_hunter <- function(hunter_pos, moose_pos, move_num){
if (hunter_pos >= moose_pos){
return(1/(6^move_num))
}
if (moose_pos >= 12){
return(0)
}
# Init
prob = 0.0
for (choice in list(5, 6)){
# Hunter Moves
prob = prob + moose_hunter(hunter_pos+choice, moose_pos, move_num+1)
}
for (choice in list(1, 2, 3, 4)){
# Moose Moves
prob = prob + moose_hunter(hunter_pos, moose_pos+choice, move_num+1)
}
return(prob)
}
res = moose_hunter(1, 7, 0)
cat("Probability of Hunter winning: ", res*100, "%\n")
cat("Probability of Moose winning: ", (1-res)*100, "%\n")
```
### Linked Notes
[[Markov Chains]]
### Resources
- [Python probability game puzzle for data scientists](https://biolactosil.medium.com/python-probability-game-puzzle-for-data-scientists-4540571afc01)
- [probability puzzle with dice](https://math.stackexchange.com/questions/1187942/probability-puzzle-with-dice)
- [A probabilistic analysis of the Game of the Goose](https://www.win.tue.nl/~jfg/articles/CSR-14-04.pdf)
-