While playing a bit of the game of 30s Tuesday, I learned that the second stage of the game is actually a bit different from what I previously described. In fact, it works as follows: say one has thrown 32. Then one starts throwing again, putting away 2s while new ones are thrown. But now, the previous score (in this case, 2*6 thrown in the second stage+2) gets doubled, and one starts throwing 3s. This can go on (doubling the score each time) until one gets at 6s; in this case, if 6*6s are thrown, one just continues throwing 6s — presumably, this is already bad enough for the opponent.
Unfortunately, this makes the calculation of the expected value for the second stage game more difficult for two reasons. First, the expected value is no longer linearly dependent on the value of the dice: the lower the score on the dice, the more impact going from one dice value to a higher one is. This is not a real problem since it only increases the number of equations by, say, 6. The real problem is the doubling, which makes the score dependent in a non-linear fashion on the score obtained earlier. I’ll spare you the analysis for now, but here’s the Maxima code I used to define P(x,n), which is the expected value when throwing xs when n points have already been scored. I do this by ignoring terms for very large n. This seems justifyable given that, letting n tend to infinity, the calculated values converge.d(x,n):=if(x=0) then 1 else if n=0 then (5/6)^x else sum((1/6)^i*(5/6)^(x-i)*binomial(x,i)*d(x-i,n-i),i,1,n); d(6,0)+d(6,1)+d(6,2)+d(6,3)+d(6,4)+d(6,5)+d(6,6); a:sum(d(6,i)*6*i,i,0,6); b:d(6,6); P6(x):=if x>10000 then 0 else x+a+b*(36+x+P6(72+2*x)); P(y,x):=if y=6 then P6(x) else x+sum(d(6,i)*y*i,i,0,6)+b*(6*y+x+P(y+1,12*y+2*x));This gives the following results:
| Start dice d | Expected value P(d,d) |
|---|---|
| 1 | 3.212283178756882 |
| 2 | 6.387677375348993 |
| 3 | 9.563071394130493 |
| 4 | 12.73845501067105 |
| 5 | 15.9132297503401 |
| 6 | 19.05236519793943 |
Small update: a reversed version of the source code is available. It now has command-line support, so that recompilation if one wants to use another strategy is no longer necessary. A Linux binary (static, gzipped) is available as well. Also, here is a slightly revised version of the paper, now with some formalization of expected values as well.
Last Thursday, I finished tidiying up the code for the strategy calculator: it can now also compare strategies, and it is pretty easy to add new ones. I will post the code in a while. Also, I started a bit on a mathematical formalization of the problem and the concepts involved. A first effort on a formalization (due to be released on Cleopatra’s “Schierkamp”), can be read here
Earlier, I described the optimal strategy in the game of 30s if one wants to maximize the number of points. I already mentioned then that there may actually be other things one wants to optimize. Also, since the optimal strategy may be a bit hard to remember, I developed a heuristic strategy.
So, I implemented some simple strategies, and calculated the optimal strategies to optimize various aspects. I calculated the following strategies: The various parameters of the different strategies are summarized in the following table:
| Strategy | Expected | Chance >30 | Expected Loss |
|---|---|---|---|
| Maximal | 30,15 | 0,62 | 1,07 |
| Maximize >30 | 29,84 | 0,67 | 1,06 |
| Minimize loss | 29,89 | 0,66 | 1,00 |
| Heuristic | 30,15 | 0,62 | 1,07 |
| Leave >5 | 29,64 | 0,54 | 1,30 |
| Leave >6 | 29,82 | 0,56 | 1,29 |
When interpreting these numbers, one has to keep in mind that the strategies only optimize for the given varible; thus for example, the “over 30s” strategy does not favor a score of 36 over a score of 31. So, if the first five stones are sixes, then the “over 30s” strategy will not discriminate between throwing the last dice or putting it aside. This somewhat troubles the results. Still, it can be noted that for any of the three parameters, there is a somewhat different strategy to reach its optimum.
Next time: a more detailed analysis of the differences between the various strategies. For now, see the source code of the analyser.
As noted before, the game of thirties normally consists of two phases. In phase 1, the player attempts, with six dice, to throw a score higher than 30. The optimal strategy for this part of the game was calculated here. If the score is above 30 case (say x is the number of points scored above 30), then the player enters the second phase. Here, the player throws all six dice, putting aside all dice with value x. As long as a new x is put away, the player can throw again. If all dice are put aside, the player can start all over again. Finally, the player next to the throwing player gets x times (number of dice put aside plus 1) points (which is a bad thing, because points correspond to drinking).
Obviously, there is no such thing as an optimal strategy here, but we can calculate the expected value of the game. We will calculate the expected number dice we put aside; the expected value of the game will clearly be this value times x. Thus, define f(a,b,c) to be the chance that, given a dice we throw with, we get b times the dice with value x, times b+c:
f(a,b,c):=(1/6)^b*(5/6)^(a-b)*binomial(a,b)*(b+c); solve([ t6=f(6,1,t5)+f(6,2,t4)+f(6,3,t3)+f(6,4,t2)+f(6,5,t1)+f(6,6,t6), t5=f(5,1,t4)+f(5,2,t3)+f(5,3,t2)+f(5,4,t1)+f(5,5,t6), t4=f(4,1,t3)+f(4,2,t4)+f(4,3,t3)+f(4,4,t6), t3=f(4,1,t2)+f(3,2,t4)+f(3,3,t6), t2=f(4,1,t1)+f(2,2,t6), t1=f(1,1,t6)], [t1,t2,t3,t4,t5,t6]);
This gave t6=4991553659467369/10415586649199975≈1.88. Hence given x, the expected number of points for the opponent is 2.88x.
After looking at the results of calculations I did earlier on the 30s game, I now had a look to see what is the optimal strategy for the game (assuming your goal is to maximize your number of points).
As a general rule of thumb, I formulated this heuristic strategy:If, after removing the highest dice, at least all but one of the remaining stones are 5s or 6s, at least put those away. If the lowest stone is a 4 or higher; keep it, if it is a 3 or lower, throw it again.If there are four dice or less on the table, this rule always gives you the optimal strategy; if there are five or six dice, there are some exceptions. I put those into a table, listing the number of dice that need to be rethrown for the optimal strategy, the expected return of the optimal strategy, and the expected return of the heuristic approach above:
| Throw | Rethrow | P(rethrow) | P(heuristic) |
|---|---|---|---|
| 15556 | 4 | 24,84 | 24,50 |
| 15555 | 4 | 23,84 | 23,50 |
| 25556 | 4 | 24,84 | 24,50 |
| 25555 | 4 | 23,84 | 23,50 |
| 35556 | 4 | 24,84 | 24,50 |
| 35555 | 4 | 23,84 | 23,50 |
Indeed, as we see, in the case of the the two lowest combinations of 5s and 6s that can occur (5555 and 5556), it is actually better to start all over. If the lowest dice is 3 or lower, that is. Indeed, note the difference between, for example 35555 and 45555: in the former case, it is better to put one 5 away and start all over with the other 4 dice; in the latter case, according to our heuristic strategy, we need to keep all 5.
| Throw | Rethrow | P(rethrow) | P(heuristic) |
|---|---|---|---|
| 155566 | 4 | 30,84 | 30,5 |
| 255566 | 4 | 30,84 | 30,5 |
| 355566 | 4 | 30,84 | 30,5 |
| 155556 | 5 | 30,44 | 29,5 |
| 255556 | 5 | 30,44 | 29,5 |
| 355556 | 5 | 30,44 | 29,5 |
| 455556 | 5 | 30,44 | 30 |
| 155555 | 5 | 29,44 | 28,5 |
| 255555 | 5 | 29,44 | 28,5 |
| 355555 | 5 | 29,44 | 28,5 |
| 455555 | 5 | 29,44 | 29 |
Here the image is slightly more diffuse; for the two lowest combinations of 5s and 6s, it makes sense to start all over again even with a 4 as lowest throw; in the other situation, only with a 1, 2 or 3 this is helpful.
Note that, in all situations, the expected value of the optimal strategy is less then a point more than the the expected value of the heuristic strategy. This poses the question: what is the expected value of the heuristic strategy in general? I may follow-up on that later.Since I coulnd’t sleep anyway, I figured I’d implement chance distibution into the 30s game analyzer, and make a nice graph. Well, the graph can be admired here:
Source code to generate this can be found here. Now off to sleep
As a small project, I decided to calculate the optimal strategy in the so-called “game of 30s”. The idea is pretty simple: one starts with 6 dices which you throw. Now, you have to put aside at least one dice, and throw with the rest. Continue with this until all dice are put aside. The objective is to get as many points as possible.
(A variation of this game can also be played as a drinking game. In this variation, if you throw above 30, then let x (between 1 and 6) be the number of points over 30 you scored. Now you throw the dice, putting aside every dice that has value x; continue as long as you throw new x’s. If you have collected 6 x’s, then you can throw the 6 dice another time. Then the number of x’s aside + x is the amount of points awarded to the person next to you; where points correspond to a fixed amount of alcoholic beverage. Conversely, if you score below 30, then you are awarded the difference between 30 and your score.) Anyway, I did a brute-force analysis of the expected value of the game for different numbers of dice. The (preliminary; I didn’t do much checking) results can be found here:| #dice | P(value) |
|---|---|
| 1 | 3.500000 |
| 2 | 8.236111 |
| 3 | 13.424897 |
| 4 | 18.843640 |
| 5 | 24.436055 |
| 6 | 30.151977 |