Loading....
Recent Article links:

Archive for February, 2008

30s: game of chance or game of luck?

Note that the original version of this article contains an erroneous calculation. This is the version as of 28 februari, 19:16.

As we have seen, different strategies in the game of thirties give us different expected results, even if the game is largely determined by luck. This raises the question: to what extent is the game a game of chance?

Obviously, to answer this question one needs to have a rigurous definition of what exactly is a game of chance. Some research in this area, particularly to be able to advise courts in The Netherlands, has been done by Dr. Ben van der Genugten. The method is explained in this article in the Dutch state newspaper:

The idea is that one defines the learning effect LE in a game to be the expected value of the optimal strategy minus the expected value of a strategy that may be employed by a “beginning player”, and the random effect RE to be the expected value of a player with advance knowledge (i.e., he knows what he is going to throw, should he throw again) minis the expected value of a player employing the optimal strategy. Then, the relative skill of a game is defined S=LE/(LE+RE).

On the grounds of Dutch jurisprudence, the boundary value has been set at 0.20; for example, roulette has value 0, black jack has value 0.049, and some simple forms of poker (the full game is too difficult to analyze) have values around 0.40.

To be able to calculate the random effect, I wrote a small simulator that, for random dice throws, calculates the optimal strategy. This suggests that with prior knowledge, the game has an expected value of about 32.73. As we know, the expected value given an optimal strategy is 30.1520.

So what, in this case, is the relative skill? For this, we need to define what a beginning player would do. Experience suggests that the strategy “put all fives and sixes away, and the last dice if it is 4 or higher” may be reasonable. In this case, one gets expected value 29.7232. This would suggest that the relative skill is 0.14, so the game just about a game of chance. This would seem to be reasonable.

There are some pitfalls, though. First of all: is this choice of strategy reasonable? As we know, the heuristic strategy is pretty easy to remember, and has an expected value which is just about equal to the expected value of the optimal strategy. In this case, the relative skill is only 0.0024.

Also, it is a bit difficult to precisely specify a random execution of the game, since the number of different throws may vary. In an earlier version of the simulation, I actually did this wrong. Calculating exactly (i.e., not simulating) the complete expected value with prior knowledge would probably be a large computation..

30s: an advanced endgame

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

Note that these values are considerably higher than the 2.88d obtained using the simpler variation of the endgame.

30s: binary, paper update

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.

Starting paper

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 :)

30s: comparing various strategies

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:

  • Maximal – Maximize number of points
  • Maximize >30 – Maximize chance of getting 30 points or more
  • Minimize loss – Minimize loss (defined as number of points below 30)
  • Heuristic – Heuristic strategy resembling the maximal strategy, as described here
  • Leave >5 – Put aside 5 or 6, or otherwise the highest dice
  • Leave >6 – Put aside 6, or otherwise the highest dice

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.

30s: calculaing the expected second-stage value

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:

Define t6, …, t1 to be the expected value of the game with 6, .., 1 dice respectively. Consider for example t2. If we throw the dice we want 0 times, the game is done. If we throw it 1 time, then the expected return is 1+t1, since we then do a 1-dice game. If we get the dice we want 2 times, then the expected return is 2+t6, since we repeat the 6-dice game. Hence we get the expected payoff f(2,1,t1)+f(2,2,t6). In general, we get the following set of equations:

To solve this system of equations, I used the great open-source computer algebra system Maxima with the following commands:

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.

The optimal strategy for 30s

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:

5 dice

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.

6 dice

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.

Other strategies

Another point is that we assumed here, that the goal of the player is to get as many points as possible. As discussed earlier, in the original game, any score below 30 is added as penalty points to yourself, whereas any score above 30 is added as penalty to an opponent. Thus a player may also want to play a risk-averting strategy: he just wants to make sure he gets 30 or above. We see that in the case of 45556, the strategy in order to maximize the number of points is to re-throw, but a risk-averting person will just want to leave the 30 on the table and get no penalty points for certain.

(The numbers indicate that if the player were to follow the maximizing strategy, he would have a 34% chance of ending up below 30. For the other x5556 possibilities, the risk-averting person will follow the maximizing strategy, since rethrowing the lowest dice gives him fully 50% chance of ending below 30.)

There are variations on this as well. The player will actually find a score of 28 worse than a score of 29, so the risk-averting strategy is actually a bit of a simplification. Another risk-averting strategy would be to minimize the expected payoff defined as 30 minus the score. Here, the situation with x55556 is that rethrowing all dice gives an expected payoff of 0.92; rethrowing the first dice gives an expected payoff of 1 and the expected payoff of not throwing at all can be seen easily. In this case, the advice of the both risk-averting strategies are is the same: rethrow everything. I’m not sure whether this is the case in general.

Finally, another strategy may be to inflict as much damage to your opponents, which is quite the oppositive of the risk-averting strategy: now everything above 30 gives a positive payoff we want to maximize, whereas 30 or lower has zero payoff.

Unfortunately, calculating the payoff in this case is more difficult, since the maximizing strategy has one big advantage over the other strategies: it is independent of the dice that have already been put away. Thus, once one has determined the optimal strategy for 5 dice, the optimal strategy for 6 dice can be easily computated. For the other strategies, if we have 4 dice on the table, the best action may depend on the dice we have already put aside, greatly increasing the number (and complexity) of the computations involved. Stay tuned for attempts at this..

Analysis of 30s game: distribution

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 :)

Optimal strategy in the game of 30s

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

Note that the optimal strategy gives you a score of just over 30. Unfortunately, my program doesn’t give a chance distribution of just how often one would get which score, this may be something to look at in the future.

This table obviously automatically gives an idea for an optimal strategy for the game. Suppose, for example, we have three dice left on the table. If we take away one with value lower than 3.5, then (since the expectancy of throwing one stone is 3.5), we can expect a higher result. If, we take two stones with sum 8 or lower, then we can also expect to improve upon our situation.

Trouble is, however, we know both choices improve our situation, only we don’t know which is better. In this case, we have the following rule of thumb: always leave 5s and 6s on the table, and only leave a 4 if other dice are 5s of 6s.

This rule seems to make sense since two 5s together make 10, so with an arbitrary stone we would expect a value of 13.5; if we were to save one 5 then we would get 8.2+5=13.2 as an expected result, which is just lower. With just one point lower, a 4 and a 5, we have an expected value of 12.5, so throwing the 4 again improves the situation.

In other situations, the situation may be a bit more difficult. I will try to formulate more general rules of thumb later. For now, the C++ source code I did the number crunching with can be found here (very ugly), and the raw results can be found here. A line cinsists of the dice one started with, sorted from low to high, followed by the expected value and the optimal number of dice to throw again with.

As for the second game, I guess it should be computable with common arithmetics, i.e., without a computer. Hopefully, I’ll come back to that later as well.