What is the probability of rolling two 5s or better with 5 dice? Preamble
My question is in the context of a dice game called 31. You have 6 dice and the goal is to have the highest score. If you roll 36, you score 6 points. If you roll 35 you score 5 points and so on up until 30, where you break even. At 29 you lose 1 points and so on.
You roll all the dice at once and after each roll you need to keep at least 1 die on the table. So you roll a maximum of 6 times.
Question
If your first roll gives you 6-5-5-x-x-x (where the Xs ≤ 4), what is the probability of getting at least two 5s if you roll five dice (excluding the 6 that you keep). By "at least two 5s" I mean that 5-5-x-x-x is the bottom of the range and 6-6-6-6-6 is the top of the range.
The question could also be worded "On the 2nd roll, do you keep the 5s and roll 3 dice or do you roll them?"
Thanks.
As to add more clarification to the rules of the games, here's a good exemple provided by @Brams28 int the comment
[...]a roll is rolling all the dice you still have left. You have to keep at least one die after each roll, but a single die could potentially be rolled 6 times. Example: I roll 6,5,4,3,2,1 on the first roll. I decide to keep the 6 and the 5 but reroll the 4 others. Now I get 5,2,2,1. I keep the 5 and reroll the other 3. Now I get 6,3,1. I keep the 6 and reroll the last two. I get 5,4. OK, I keep those two (of course!)
 A: I don't think the answer to first question is much help in answering the second, and I agree with Daniel Mathias's answer to the second—namely that you should roll all 5 dice.   If you do that, and play optimally thereafter, your expected score will be $6 + \frac{8,569,700}{350,699} - 30 \approx 0.44$.   
If you keep the 6 and one of the 5s, roll the remaining four dice and play optimally thereafter, your expected score will be $6 + 5 + \frac{989,065}{52,488} - 30 \approx -0.16$.
If you keep the 6 and both 5s, roll the remaining three dice and play optimally thereafter, your expected score will be $6 + 5 + 5 + \frac{13,049}{972} - 30 \approx -0.58$.
If you roll $d$ dice, they show the numbers $m_1 \ge m_2 \ge \dots \ge m_d$, and you decide to keep $k$ of them and roll the remaining $d-k$ (where $1 \le k \le d$), then then the ones you should keep are obviously those showing $m_1, m_2, \dots , m_k$.  If you play optimally thereafter, your expected final sum will be $ES_{d,k} = m_1 + m_2 + \dots + m_k + EV_{d-k}$, where $EV_i$ (to purloin Daniel's notation) represents the maximum expected sum you can obtain by proceeding optimally with $i$ dice.  Your optimal strategy is therefore to choose the value of $k$ for which $ES_{d,k}$ is a maximum.  We therefore get the following recursive equation for the value of $EV_d$:
$$EV_d = \sum_{\mbox{all $d$-tuples of die faces}}
\frac{\max_{1\le k \le d}\left(ES_{d,k}\right)}{6^d} \ \ \ .$$
Using a Math Studio script to compute the values of $EV_d$ for $d=3 \mbox{ to } 6$ (the values $d = 1$ and $2$ are trivial to do by hand), I obtained the following:
\begin{eqnarray}
EV_1 &=& \frac{7}{2} \\
EV_2 &=& \frac{593}{72 }\approx 8.236\\
EV_3 &=& \frac{13,049}{972} \approx 13.425\\
EV_4 &=& \frac{989,065}{52,488} \approx 18.844\\
EV_5 &=& \frac{8,569,700}{350,699} \approx 24.436\\
EV_6 &\approx& 30.152\ \ ,
\end{eqnarray}
thus confirming Daniel's analysis.
Edit:
It's probably worth giving the following fairly simple explicit description of an optimal strategy.
If you throw the numbers $j_1, j_2, \dots , j_d$ when you throw $d$ dice, 


*

*list those numbers in decreasing order as $m_1, m_2, \dots , m_d$;

*calculate the quantites
\begin{eqnarray}
S_0 &=& \sum_{i=2}^d m_i ,\\
 S_k &=& EV_k + \sum_{i=2}^{d-k} m_i  \mbox{ for $k= 1, 2, \dots , d-2$ , and}\\
 S_{d-1} &=& EV_{d-1} ;
\end{eqnarray}

*determine the value $k^*$ of $k$ for which $S_k$ achieves its maximum value;

*If $k^* = 0$, keep all the dice and don't throw any more. Otherwise, keep the $d-k^*$ dice $m_1, \dots , m_{d-k^*}$ and throw the $k^*$ dice $m_{d+1-k^*}, \dots , m_d$ .

