Maximizing Expected Scores in the Game of Zilch

A Throw of the Dice
Image by Thunderchild7

Zilch is a fun little dice game codified into an online game by Gaby Vanhegan that can be played at Zilch is actually a variation of the game Farkle which goes by several other names including Zonk, 5000, 10000, Wimp Out, Greed, Squelch and Hot Dice1. I've worked out the strategy that maximizes your expected game score and wanted to share the analysis, my strategy finder software, and the strategy itself. Depending on whether you have zero, one or two consecutive zilches from previous turns, three successively more conservative turn-play strategies are required to maximize your long term average score. Using these three strategies you rack up an average of 620.855 points per turn, which is the best you can possibly do.

Beyond the scope of Gaby's implementation of Zilch, the scoring rules of Farkle vary from venue to venue and the strategies provided here do not generally apply, but the analysis and the software do.

If you understand conditional probabilities, expectations, and can do a little algebra, you should be able to follow along. If you're just here to take the money and go pound someone in the game, you'll need to at least read and understand Strategy Formulation before you try to interpret the tables.



I've found several blog postings where folks have offered probabilistic analyses of various aspects of the game2,3,4, but none (that I've seen) find the game strategy that maximizes your expected points. It is possible that I'm the first to publish these solutions. If not, it was still a fun problem. I've always enjoyed software, algorithms, optimization, and probabilities and this problem delves into all of these areas.

The Rules of Zilch

Zilch is played with two players and six six-sided dice. (Though really there's nothing to stop you playing with more people, but this is not supported in the online game.)

Each player takes turns rolling the dice. The dice in a roll can be worth points either individually or in combination. If any points are available from the roll, the player must set aside some or all of those scoring dice, adding the score from those dice to their point total for the turn. After each roll, a player may either reroll the remaining dice to try for more points or may bank the points accumulated this turn (though you can never bank less than 300 points).

If no dice in a roll score, then the player loses all points accumulated this turn and their turn is ended. This is called a zilch, a sorrowful event indeed.

If all dice in a roll score, the player gets to continue his turn with all six dice. This is called a free roll and is guaranteed to brighten your day.

A player may continue rolling again and again accumulating ever more points until he either decides to bank those points or loses them all to a zilch.

If a player ends three consecutive turns with a zilch, they not only lose their points from the turn but also lose 500 points from their banked game score. (This is the only way to lose banked points.) After a triple zilch, your consecutive zilch count is reset to zero so you're safe from another triple zilch penalty for at least three more turns.

The game ends when one player has banked a total of 10,000 points and all other players have had a final turn.

Scoring is as follows:

  • Each 1 is worth 100 points.
  • Each 5 is worth 50 points.
  • A set of three 1s is worth 1000 points.
    A set of three 2s is worth 200 points.
    A set of three 3s is worth 300 points.
    A set of three 4s is worth 400 points.
    A set of three 5s is worth 500 points.
    A set of three 6s is worth 600 points.
    Each extra die in a set doubles the value of the set. So four 4s are worth 800 points and six 1s are worth 8000.
  • Three pair is worth 1500 points.
  • A six die straight is worth 1500 points.
  • Six dice with no other scoring options at all are worth 500 points. (And this is why a 6 die roll is called a free roll: you can't zilch when rolling 6 dice.)
  • Each die can only be used once when scoring. (If you roll two 1s, two 2s, and two 3s you can either count the two 1s for 200 or use all six dice for three-pair and 1500 points — you can't use the ones both ways for 1700 points.)


The strategy presented will maximize your expected Zilch scores, but this is not necessarily the same strategy that will let you reach 10,000 points in the fewest number of turns; and certainly falls short of giving a complete gaming strategy that will maximize your chances of winning the game5, the holy grail of Zilch analysis. In particular, the strategy considers neither your current overall score, nor your opponent's score, nor the fact that the game ends when a player reaches 10,000 points (after the other player gets a final turn). All that I offer is a way to maximize your expected Zilch scores.

My intuition is that when you're in the lead you should play more conservatively; and when you're behind you should play more aggressively. (Though I think it a common mistake to be too aggressive too early when behind.) Consider this extreme example. Let's say you're currently beating your opponent 7500 to 1500 and it's your turn. On your turn you rack up 2500 points and are faced with the choice of either banking the 2500 or rolling five dice to go for more points. The strategy identified here advises you to roll the five dice; but surely in this case it is better to bank the 2500, putting you at the game goal of 10,000 points and forcing your opponent to try to put out 8550 points in a single turn to steal the win away from you.


Strategy Formulation

I will start by showing how to maximize the expected points for a particular turn. Because of the three consecutive zilch rule, the strategy that actually maximizes the average points gained across all turns is different: it is possible to trade off some expected gain in those turns where you have either zero or one consecutive zilches to reduce your zilch probability and more strongly avoid even getting into a turn where you are facing your third consecutive zilch. I will solve for this more complete strategy later, but for now let's stick with maximizing the expected points for a single turn and just ignore how such a greedy strategy might negatively affect the outcome of subsequent turns.

For my purposes, a Zilch turn has a state that may be completely defined by two variables (s, n) where s is the number of points accumulated in the current turn, and n is the number of dice you are about to roll. At the beginning of a new turn, the turn state is (s=0, n=6). Let's say for your opening roll you throw:

1, 3, 3, 4, 4, 6

The turn state will then advance to (s=100, n=5). You actually have no choice here: you must always select at least one scoring die and since the 1 (worth 100 points) is the only scoring die, you must select it. Furthermore, you are not allowed to bank less than 300 points so you must roll the five remaining dice.

Suppose with the remaining 5 dice you roll:

1, 1, 2, 3, 5

Here you have three scoring dice: two 1s and a 5. You now have a choice of turn states that you may enter:

  1. (s=150, n=4) (take just the 5)
  2. (s=200, n=4) (take a single 1)
  3. (s=250, n=3) (take a single 1 plus the 5)
  4. (s=300, n=3) (take the two 1s)
  5. (s=350, n=2) (take the two 1s plus the 5)

Note that s includes not just the points taken from this roll, but also all points accumulated in previous rolls during this turn as well. It should be clear that state B is better than A and state D is better than C. Of the remaining three states (B, D and E) it's not so obvious which is better. You also have the option of banking from either of states D or E (but not from B since you don't have 300 points in that case). Obviously, banking from state D is just plain dumb: if you're going to bank you'll do so from state E to bank as many points as you can! That leaves you with four reasonable choices:

  1. enter state B = (s=200, n=4) and roll;
  2. enter state D = (s=300, n=3) and roll;
  3. enter state E = (s=350, n=2) and roll; or
  4. enter state E = (s=350, n=2) and bank.

My objective is to find the optimal turn play strategy that defines what to do in all such situations which when followed will maximize the expected number of points for the entire turn starting from any given turn state.

Let E(s, n) be the expected number of additional points you will gain for the turn if you (perhaps non-optimally) roll while in state (s, n) but then follow the optimal turn strategy (which we hope to find) for all subsequent decisions in the turn. Note that E(s, n) includes not just the expected points for the upcoming roll, but all the expected points from all subsequent rolls, if any, as dictated by chance and the optimal play strategy.

Suppose we somehow solve for E(s, n) and find that:

E(s=200, n=4) =149
E(s=300, n=3) =34
E(s=350, n=2) =-20

Applying this information to the example leads to the following final expected scores for the turn.

  1. Final expected score by rolling from state B = 200 + 149 = 349.
  2. Final expected score by rolling from state D = 300 + 34 = 334.
  3. Final expected score by rolling from state E = 350 - 20 = 330.
  4. Final expected score by banking from state E = 350.

So, the choice that leads to the highest expected score for the turn is to bank the 350 points. From this example, it should be clear that if we can find E(s, n) for all possible game states (s, n) we'll have the optimal Zilch turn play strategy.

Finding E(s,n) - the Zilch strategy function


T(s, n) = { s + max(0, E(s, n))
s + E(s, n)
 for s ≥ 300
 for s < 300

T(s, n) is simply the total expected points for the turn given that you are in turn state (s, n) and you follow the optimal strategy. The special case for s < 300 models the rule that you can't bank less than 300 points. The max function used when s ≥ 300 models the requirement that you bank when E(s, n) is negative, and roll otherwise.

Suppose we are in some particular state (S, N) then let r1, r2, … rR be all possible rolls of N dice that do not result in a zilch. For any given roll ri you can potentially enter multiple game states (s1, n1), (s2, n2), … (sK, nK) (depending on which combination of scoring dice you choose — just like in the previous example). Define C(ri, S, N) to be the particular scoring combination among all scoring combinations possible with roll ri that when applied to turn state (S, N) will advance the turn to the new state (Si, Ni) that maximizes T. What could be simpler? Let CS be the number of points taken in scoring combination C, and let CN be the number of dice used in scoring combination C.

I also need a simple little function F(n) to reset the state variable n back to 6 when a score is selected that uses all remaining dice:

F(n) = { 6
 for n = 0
 for n ≠ 0

We can now express E(S, N) as a weighted sum of the expected scores of all states reachable from (S, N):

E(S, N) = -pN(S+y) + i  T(Si, Ni) - S


Si=S + CS(ri, S, N)
Ni=F(N - CN(ri, S, N))
pN=probability of zilching when you roll N dice
y=zilch penalty.

To handle the three zilch rule, I've introduced the constant y which gives the additional penalty (beyond loss of all turn points) for rolling a zilch. Setting y to 0 models turns where you have only zero or one consecutive zilches. Setting y to 500 models turns where you are playing with two consecutive zilches. As we shall see, these two cases will lead to two different turn play strategies.

The term -pN(S+y) gives the expected decrease in your score due to the likelihood of a zilch. The terms (T(Si, Ni) - S) give the expected increase in your score given that you throw ri. Summing over all possible ri and multiplying by the probability of rolling any particular ri gives the appropriate weighted sum.

Equation 3 expresses E(S, N) in terms of the T values of all the game states reachable from (S, N). But here's the important thing: any game state (s, n) reachable by any roll r from (S, N) has s > S. (Your score can only go up if you don't zilch and by definition r is not a zilching roll.) So, if we already know T(s, n) for all s > S, then we can calculate E(S, N) using the above summation.

I claim there exists some large value of accumulated turn points SBIG where the optimal turn play strategy is to always bank when faced with rolling less than six dice and to always roll when you have six dice to roll. If I set SBIG equal a million points, then I'm claiming that if you've somehow accumulated a million or more points on the current turn (an absurdly large number of points to be sure) you'll want to bank them if you're ever faced with rolling five (or fewer) dice: the 7% chance of losing all of your points far outweighs any comparatively meager gains you might achieve by continuing to roll. This claim is equivalent to saying:

E(s, n) < 0 for s ≥ SBIG, 1 ≤ n ≤ 5 (4)

Now if you have six dice to roll, you risk nothing so you might as well further insult your opponent by adding to your million point score. The number of points you expect to gain in this situation through the end of your turn is a constant:

E(s, n) = EBIG6 for s ≥ SBIG, n = 6 (5)

Here's how to solve for EBIG6. Let

EB=the expected number of points gained from a single roll of 6 dice given that the roll does not grant another free roll (so you have to bank).
EF=the expected number of points gained from a single roll of 6 dice given that the roll does grant another free roll.
pF=probability of a 6 die roll granting another free roll.

These terms are easily calculable by simply enumerating all the six die rolls and determining the best possible scoring combination in each case. (There's a subtlety here I'm not going to bore you with regarding how to score a roll of four 1s and a pair of either 2s, 3s, 4s or 6s; I explain this in detail in the software comments for the interested reader.) Once found they can be used in the following sum:

EBIG6 = (1-pF) EB + pF (EF + (1-pF) EB + pF (EF + ... )) (6)

This nicely simplifies to,

EBIG6 =  EB + pF
EF (7)

Combining Equations 1, 4 and 5 give

T(s, n) = { s + EBIG6
 for s ≥ SBIG, n = 6
 for s ≥ SBIG, 1 ≤ n ≤ 5

Knowing T(s, n) for s ≥ SBIG, we can now use Equation 3 to iteratively calculate E(SBIG - 50, n), E(SBIG - 100, n), … E(0, n). The rest is just the grunt work of writing the software to implement the curious function C; solving for EBIG6; and solving for all E(s, n) for s < SBIG. (Did I just slander my own profession?) But before we start grunting let's see what we can do about the three consecutive zilch problem.

Maximizing expected score across all turns

There are actually three different types of turns:

T0: a turn played with no previous consecutive zilches,
T1: a turn played with one previous consecutive zilch; and
T2: a turn played with two previous consecutive zilches.

Using the technique already described, we can find the strategies that will maximize the expected points in each of these turns independently, but what we really want is a strategy for each turn that when used together will maximize the average score for all of these turn types when weighted by the frequency of the appearance of the turn type in a game.

If zi is the probability of zilching while in turn type Ti (while following some strategy designed specifically for that turn type) then we have the state transition diagram shown in Figure 1.

transition diagram showing transitions between states T0, T1 and T2
Figure 1. State transition diagram governing the transitions between states T0, T1 and T2.

Performing a steady state analysis of this system we can find the probability ti of being in any particular state Ti. (I.e., we want to find what fraction of our turns will be of each type.) We have these flow equations which must balance:

t0 = (1-z0)t0 + (1-z1)t1 + t2
t1 = z0t0
t2 = z1t1


t0 + t1 + t2 = 1

Solving gives

t0 = 1 / (1 + z0 + z0z1)
t1 = z0 / (1 + z0 + z0z1)
t2 = z0z1 / (1 + z0 + z0z1)

Define Ei to be the expected points gained for a turn of type Ti. Then the average score for all turns is:

EAVG = t0E0 + t1E1 + t2E2


EAVG = E0 + z0E1 + z0z1E2
1 + z0 + z0z1

EAVG is what we want to maximize. Both Ei and zi are just a function of the strategy used to play a turn of type Ti. The strategy employed for T2 only affects E2, so E2 can be independently maximized — something we already know how to do. That leaves the strategies for T0 and T1. E2 is the term that's pulling down our average score since it's the turn played with the 500 point penalty for zilching. Can we modify our strategies for T0 and/or T1 in such a way so as to trade off some of our expected gains in those turns to reduce the coefficient z0z1 on E2 and thereby actually increase EAVG?

In Equation 3, I introduced the variable y to model the penalty for a zilch in a game. I said it should be set to 0 normally, but set to 500 if we are playing a turn where the third consecutive zilch is imminent. If we extend this idea and allow y to become a free variable, we can examine different levels of trade-off between expected score and the probability of zilching. For each y value, we'll find the optimal strategy given that zilch penalty; and then find both the expected number of points per turn and the probability of zilching on the turn for that strategy. EAVG then becomes a function of just two variables y0 and y1. We then need only to find the particular values Y0 and Y1 that maximize EAVG. Piece of cake!

When doing this analysis, it's important to understand that the penalties y0 and y1 are artificial. The true zilch penalty for these turns is of course zero. Accordingly, the values calculated for E(s, n) will not represent the true expected change in points for the turn from state (s, n). But the values E(s, n) do still define a strategy, dictating that you roll if E(s, n) is positive, and that you bank when E(s, n) is negative. Likewise, the E(s, n) values are still used in the normal way to determine which state among the reachable states after a roll is most desirable. To get the actual expected increase in score from state (s, n), you must add back the false zilch penalty times the probability of zilching for the remainder of the turn. Although you could calculate this for all states (s, n); we only really need to know the true expectation for the turn as a whole, which we can get by correcting E(0, 6). This gives rise to the notion of a corrected expectation for the turn:

EC = E(0,6) + yz (10)

Enough analysis! On to the results! Now I am become death, destroyer of Zilch.


The optimal strategies

I wrote a little java program that solves for EBIG6; finds E(s,n) for a supplied zilch penalty, y; for that strategy, calculates the probability of zilching, z; and also outputs the corrected expected points for the turn, EC. Running the software for the case y=0 we get:

EBIG6 = 478.237
EC = E(0, 6) = 623.017
z =.193326

So the best you can do for a single turn is to rack up an average of about 623 points, and zilch about 1 time in 5. I'll get to the actual strategy tables shortly, but first let's solve for the optimal strategies required for the three zilch rule for turn types T0, T1 and T2.

Finding the best strategy for T2 is easy: just set y=500 and you get these results:

E2 = E(0, 6) = 547.157
z2 = .132148

You don't use EC here since the 500 point zilch penalty is not artificial but real. This penalty reduces the maximum expected points per turn by about 12%. The more conservative play required here also reduces the zilch probability by about a third.

To find the best strategies for T0 and T1 we need to let the zilch penalty for those two turn types (y0 and y1) vary and then maximize EAVG as given by Equation 9. Table 1 shows how varying the penalty for zilching (y) affects the probability of zilching (z) and the corrected expected points per turn (EC). Due to the integral nature of the problem, there are fairly large ranges of y that have no affect on the strategy. I'm only listing y values among those tried that produced a strategy change:

Table 1. Probability of zilching for the turn, z, and corrected expected score, EC, as a function of the zilch penalty, y.


Pumping this table through a little awk script (which I hacked out at a command prompt and didn't save for you), I found that EAVG is maximized when Y0 = 0 and Y1 = 72. Here are the summary statistics:

y0 =0
z0 =.193326
E0 =623.017
y1 =72
z1 =.170988
E1 =622.269
y2 =500
z2 =.132148
E2 =547.157
This gives
EAVG = 620.855

For turn type T0, you're best off just going for the maximum expected points possible: trying to play more conservatively doesn't reduce your zilch probability (or the probability of entering state T2) enough to offset the corresponding loss in expected points for turns of type T0.

For turn type T1 (when you've got one consecutive zilch) you're best off pretending you will be penalized an extra 72 points if you zilch. This reduces your expected score by only 0.2% but reduces your probability of zilching by about 10%. This little extra protection against your third consecutive zilch slightly increases your overall average turn scores.

Let's move on to the actual strategies.

Strategy T0: playing with no consecutive zilches

Table 2 below gives E(s, n) for all s ≤ 3200 for the case y = 0. This is the strategy achieving the maximum expected points for a turn and is the best strategy to use if you didn't zilch on your previous turn. The first table entry is EBIG6 = 478.237. The last table entry gives the total expected points for the turn: E0 = 623.017. The probability of zilching for the entire turn (not shown in the table) is z0 = .193326.

Table 2. E(s,n) for turn type T0.

2450485.29051.290-222.876-567.008 -985.170-1446.876
2400485.97555.157-214.989-553.089 -962.881-1413.339
2350486.94959.026-207.101-539.170 -940.591-1379.789
2300488.22262.896-199.211-525.251 -918.299-1346.179
2250489.49666.767-191.320-511.331 -895.995-1312.472
2200490.77170.640-183.429-497.410 -873.664-1278.714
2150492.04874.513-175.538-483.482 -851.309-1244.955
2100493.32678.386-167.645-469.545 -828.945-1211.197
2050494.60482.260-159.748-455.601 -806.581-1177.438
2000495.88486.136-151.848-441.655 -784.217-1143.678
1950497.16490.013-143.944-427.706 -761.853-1109.919
1900498.44893.894-136.037-413.755 -739.488-1076.159
1850499.74097.776-128.128-399.802 -717.124-1042.398
1800501.041101.661-120.218-385.848 -694.759-1008.635
1750502.344105.547-112.306-371.893 -672.394 -974.870
1700503.867109.434-104.392-357.936 -650.029 -941.102
1650505.684113.323-96.476-343.979 -627.662 -907.298
1600507.502117.213-88.558-330.022 -605.289 -873.408
1550509.327121.105-80.641-316.064 -582.895 -839.469
1500511.172124.998-72.723-302.102 -560.480 -805.529
1450513.033128.891-64.805-288.132 -538.055 -771.583
1400514.894132.784-56.883-274.156 -515.630 -737.633
1350516.756136.679-48.958-260.177 -493.203 -703.679
1300518.619140.575-41.030-246.196 -470.774 -669.725
1250520.484144.474-33.100-232.212 -448.345 -635.771
1200522.356148.374-25.167-218.227 -425.916 -601.816
1150524.236152.277-17.233-204.240 -403.487 -567.860
1100526.119156.180-9.297-190.252 -381.057 -533.901
1050528.180160.085-1.360-176.263 -358.627 -499.941
1000530.368163.9926.579-162.273 -336.196 -465.950
950532.560168.76314.520-148.283 -313.760 -431.909
900534.870174.57722.461-134.293 -291.310 -397.845
850537.684180.57030.403-120.299 -268.848 -363.762
800540.959186.56438.345-106.301 -246.379 -329.574
750544.307192.55946.289-92.299 -223.889 -295.226
700547.655198.55554.235-78.294 -201.356 -260.789
650551.006204.87962.183-64.276 -178.780 -226.340
600554.457212.14670.136-50.240 -156.188 -191.890
550558.365219.98978.096-36.194 -133.594 -157.423
500562.820227.83886.062-22.143 -110.997 -122.863

Using this table, you can easily figure out what to do in any turn play situation. Consider these examples.

  • With 300 points and 3 dice to roll, you should roll.
  • With 300 points and 2 dice to roll, you should bank.
  • With 300 points and 1 die to roll, you should roll.
  • With an opening roll of (3, 3, 3, 5, 2, 6) you should take the 5 and roll five dice.
  • With an opening roll of (1, 1, 1, 1, 4, 4), you should score it as three pair for 1500 and take a free roll.
  • If you already have 500 points and then roll (1, 1, 1, 1, 4, 4), you should score it as a set of four 1s for 2000 and bank.

Strategy T1: playing with one consecutive zilch

Table 3 below gives E(s, n) for all s ≤ 3200 for the case y = 72. This is the optimal strategy for turns of type T1 (when you're playing with one consecutive zilch). The corrected expected points for the turn is: E1 = 622.269. The probability of zilching for the entire turn is z1 = .170988.

Table 3. E(s,n) for turn type T1.


Strategy T2: playing with two consecutive zilches

Table 4 below gives E(s, n) for all s ≤ 3200 for the case y = 500. This is the optimal strategy for turns of type T2 (when you're playing with two consecutive zilches). The expected points for the turn is: E2 = 547.157. The probability of zilching for the entire turn is z2 = .132148.

Table 4. E(s,n) for turn type T2.


Comparing Table 4 with Table 2 you can see that playing with two consecutive zilches is almost identical to playing without any consecutive zilches while pretending you have 500 more points for the turn than you really do. To see this compare the 500 point line in Table 4 with the 1000 point line in the Table 2. They are identical. This remains true until you get down to point values below 300 at which time the 300 point minimum bank rule forces you to roll even though rolling gives a negative expected change in your score.


The software I wrote to find optimized Zilch strategies is 718 lines of java code (or 322 lines comments stripped). Please observe the GNU public license copyright protection or I may have to introduce you to my friend Guido. You can download with either zip or tgz compression as convenient:

Downloads: OR zilch.tgz

The compile command is simply:


Then to run it type:

java Zilch

You can optionally add a zilch penalty to the command line. For example, to run the program with y = 500 type:

java Zilch 500

To find the best strategy for variations of the game that use different scoring rules, just change the scoring constants at the top of the file. If you set a score to zero, then that score combination is effectively eliminated from the game and is instead treated as a zilch. So if in your Farkle variant, the six-die nothing roll is just a zilch, you need only set NOTHING_SCORE = 0. The software will then interpret this as a zilching roll.

EBIG6 is calculated for you. If you set the NOTHING_SCORE to 0, (giving you a non-zero chance of zilching on a 6 die roll) then EBIG6 will be correctly initialized to 0. There's a chicken-and-egg problem associated with the calculation of EBIG6 which required a bit of finger work to resolve reliably in the face of various possible scoring changes. Check out the comments for method initEBIG6 if you're interested.

The smallest valid value for SBIG is also determined through a binary search, so you need not worry about changing that for different scoring options.

On my 10 year old home computer, the strategy for Zilch is determined in about 7 seconds. Farkle strategies take about 30 seconds. (Farkle is much slower because SBIG has to be set big enough that the chance of a 6 die farkle out-weighs the potential gains of a 6 die roll.) No doubt you could solve these same problems in a tiny fraction of a second with appropriate optimizations, but I personally don't have a need for better performance.


This was a fun problem. The trick is to work the problem backwards: finding the expected scores for high point states first, and then working your way back down to lower and lower scores until finally you get the expected score from the starting state. Everything else is just details (which hopefully I've gotten correct).

One thing I found surprising about the results is just how incredibly insensitive the corrected expected turn score is to the zilch penalty. The optimal strategy for the case of an infinite zilch penalty drops the probability of zilching from .193326 down to .126959 (the minimum zilch probability you can achieve for a turn). Playing that same strategy on a turn where the zilch penalty is actually zero drops your expected score from 623.017 down to 605.851 — it only costs you 17 points per turn! That's less than 300 points over the course of a typical game, and that's nothing in a game of Zilch. I think this is true because almost all the big points in Zilch come from 6 die rolls where there's no chance to zilch. So, playing to reach 300 points as reliably as you can and then banking as soon as you face a roll of less than six dice reduces your expected scores very little compared to playing for maximum expected points. I found this very surprising and somehow unsatisfying.

I'd be pleased to know if you found this document comprehensible; or if you found any errors in the analysis or the software. Leave a comment or send me an email. If you're lucky, you might even meet me masquerading as pips in a game of Zilch. Just don't expect to win.


  1. FARKLE, Wikipedia.
  2. Multinomial Coefficients and Farkle, Cap Khoury, Jul. 2009.
  3. Farkle Odds, Gregory Graham, August 2009.
  4. Study of the game Zilch part 1, Leadhyena Inrandomtan, November 2008.
  5. FARKLE, Expectation, and Knowing What You Want, Cap Khoury, August 2009.

About matt

I live in Lakewood, Colorado with my wonderful wife Tammy and three fine children Aaron, Becky and Cate. I'm an electrical engineer by education, but worked as a software developer for about 20 years. I recently took a promotion to full time care giver, but will likely return to the grind once the kids are a little older. I coach basketball, sing in two different church choirs, tutor mathematics and physics at a local high school, and spend what other time I can find pursuing home improvement projects and several pet software projects.
This entry was posted in Uncategorized. Bookmark the permalink.

13 Responses to Maximizing Expected Scores in the Game of Zilch

  1. matt says:

    I’ve discovered a very tiny error: because I was only printing out zilch probabilities and corrected expected scores to six decimal places, the script I ran the data through picked the wrong strategy for turn type T0: it turns out that you should really play a turn when you have no consecutive zilches as if you’ll lose an extra 10 points. This corresponds to the second strategy in Table 1. The error is only on the order of a millionth of a point per turn played and so is perhaps not worth mentioning, but in the interest of correctness I mention it anyway! I’m not going to bother modifying this document to correct it. The search algorithm I use in the Farkle Strategy Generator does not suffer from this rounding error.

  2. mh says:

    Thats quite a nice article. The Math behind let u proof the sense for your strategy :-)

  3. Lebossle says:

    Are you sure that that’s right? On conclusions you say that if when you zilch you get an infinite penalty your average roll remains positive: isn’t that impossible since there is always a chance not infinitely small of zilching, so your average score should be negative infinite?

  4. matt says:

    Hello Lebossle,

    Thank you for your comment. The only thing I’m sure of is death and taxes.

    In that paragraph of my conclusions, I was talking about the corrected expected score, but I can definitely see how it was confusing especially if you didn’t read the entirety of the article. I’ve taken liberty to rewrite that paragraph to make it (hopefully) more clear. For that discussion, the zilch penalty is zero, but I’m telling the equations that the zilch penalty is infinite to trick them into working very very hard to avoid zilching. By doing this I produce the most conservative strategy you can possibly play. (I.e., the strategy that gets you to 300 points with the smallest probability of zilching.) If you play THAT strategy when there is no zilch penalty at all, you will find yourself getting on average 17 points per turn LESS than you would if you play the strategy that simply maximizes expected score.

    I purposefully glossed over some of my claims in the section “Maximizing expected scores across all turns”, because I thought the mathematics behind them too tedious (or perhaps it is my limited mathematical skill that makes them too tedious) for a blog entry. But I’ll say a little more here as it pertains to your comment.

    By setting the zilch penalty to some value y, equation (3) will produce a particular strategy G(y) that produces the highest possible expected score given that the zilch penalty is y. Now here’s the funny part: what happens if you play strategy G(y) when in actuality the zilch penalty is zero? It may not be obvious why you’d ever want to do that, but the interesting thing is that if you use G(y) for a turn where there is no zilch penalty, then you will be playing the strategy that gives the best possible expected score with the constraint that you are not allowed to zilch with higher probability than the probability of zilching with strategy G(y). If this were not the case, then it’s easy to show that G(y) isn’t actually the best strategy for the situation where the zilch penalty is y, but we know that it is the best. So, if you consider all other possible strategies having a zilch probability the same or less than the zilch probability of G(y), none of them will give a better expected score than G(y). That’s very useful because for purposes of finding the strategies that maximize expected scores across all turns, the only thing we care about is their expected score and their zilch probability.

    So in the section “Maximizing expected scores across all turns”, the zilch penalty y is fictitious for turn types T0 and T1. I only introduce it as a means of producing strategies G(y) that maximize expectation for various inferred zilch probabilities. It turns out that from the infinitude of possible strategies, there are only a few hundred strategies G(y) for 0 ≤ y < ∞; and it becomes quite possible then, to find the two particular strategies that are best to use for turn types T0 and T1.

    If you plot the expected scores E(G(y)) vs. the zilch probabilities z(G(y)); you’ll see that E(G(y)) is strictly increasing in z(G(y)). Furthermore, if you connect the data points in this plot with straight line segments; you’ll see the slope of these segments is strictly decreasing. It is perhaps noteworthy that between any two neighboring strategies G(yi) and G(yi+1), there could exist other strategies with intermediate zilch probabilities and intermediate expected scores, but such strategies will always appear below (or conceivably on) the straight line joining G(yi) and G(yi+1) and are never a superior strategy to play for any possible zilch penalty.

    As a notable aside, you can set the minimum bank threshold to, say, 1000 points and again let the zilch penalty go to infinity and produce the strategy that gets you to 1000 points with the minimum probability of zilching.

    I hope that helps.


  5. Stef says:

    Lovely article about Zilch, really. I didn’t know it came from Farkle. Thanks!

  6. Tom says:

    This was an excellent article – I very much appreciated all the effort put into this! In particular, I was trying to formulate an optimal Farkle strategy for myself, until I came across your analysis. Having read everything very thoroughly, and played with your equations myself, I do have a query regarding your estimate of E(BIG6) for use in Farkle – not Zilch. I think one of the biggest differences between the two games appears to be the non-zero probability of getting a non-scoring roll with 6 dice. As I understand the two games, this is not possible with Zilch, whereas it is with Farkle. I have spent a lot of time trying to come up with an estimate of E(BIG6) for Farkle, because Equation (7) does not apply. When I changed the settings in your model to Facebook Farkle and generated the corresponding strategy, I noticed that the possibilities ran to scores of over 16,000! Yet, I doubt if any Farkle player would risk a 16,000 point score with a 2.3% chance of losing it all. I believe the “stopping score” would be much lower, but I’m having difficulty formulating the equation for this. I have not looked at your java code (I am not a programmer in java), but I suspect that my issues arise from what you describe as your chicken-and-egg problem for initializing E(BIG6). I would love to get your feedback and to extend discussion on this issue.

  7. matt says:


    Let me first tackle the insanity of rolling when you have 16,000 points. As I stated in Limitations, the strategy that maximizes expected score is NOT always the same strategy that maximizes your chance of winning the game. This is one of those situations. If you’re out to win, then yeah, you’d definitely bank the 16,000 points since that assures the win. But if you’re trying to maximize expected score, then (surprisingly enough) it’s actually better to roll 6 dice into 16,000 points. I’ll calculate that by hand here.

    There are 66 = 46656 different ways to roll six dice. Of these 1080 are farkles. So, as you noted, the chance of farkling = 1080/46656 = 1 / 43.2 = 2.3%. Then the negative expectation component in our sum is just -16,000 / 43.2 = -370.3703. Now the other 45576 rolls are not farkles and yield points. If you add up all the highest scoring combos from each of these rolls you get 17,709,000 points. So the average score (given that you don’t farkle) is just 17,709,000 / 45576 = 388.5598 points. Just as we multiplied the -16,000 by the chance of farkling, we need to multiply this average score by the chance of NOT farkling; so our positive expectation component is 388.5598 * (1 – 1/43.2) = 379.5656. And our net expectation is 379.5656 – 370.3703 = 9.1953. So on average if you roll 6 dice into 16,000 points, you’ll gain 9.1953 points. Now run the Farkle Strategy Generator for Facebook Farkle scoring, flip to the Expected Score table for turn type T0, and examine the table entry corresponding to 16000 turn points with 6 dice to roll. You’ll see the final expected turn score of 16009.195 points. Voila!

    You are right that for Facebook Farkle scoring rules there is always a non-zero probability of farkling, whereas in Zilch a throw of 6 dice always yields positive points. In zilch, you always throw 6 dice when you get the chance, no matter how high your score. This leads to an infinite series of increasingly unlikely game states which must be added to the total expectation of turn score. EBIG6 is introduced to deal specifically with this infinite series. Things are actually simpler in Facebook Farkle since rolling 6 dice into anything more than 16350 points always yields negative expectation to your score. So you must simply bank 16400 or more points. There is no infinite series to sum and accordingly EBIG6 doesn’t enter into the equations for Facebook Farkle at all. You shouldn’t be trying to calculate it. The software just sets EBIG6 to zero for Facebook Farkle scoring.

    For Facebook Farkle, all you need worry about is finding SBIG. To find it, you just make a guess, start running your calculations down from your chosen value of SBIG, and verify that E(SBIG-50, 6) is negative. If it is, then you’ve picked an SBIG that is big enough. If not, increase it. In the software, I use a binary search to zero in on the minimum value for SBIG. (Well, actually it picks a value for SBIG that is 50 points bigger than it needs to be, but that results in the last row of produced strategy tables being all banking states — which I think rather nice anyway.)

    I hope that helps.


  8. Kayen Davenport says:

    To what are referring when you say ‘strategy finding software’?

    • matt says:


      In the Software section of this blog post is a link to my original java software used to find the strategies that maximize expected scores in the game of Zilch. This software is open-source and is protected by GPL 3.

      Subsequently, I rewrote the strategy generation tool in C++. The new version is perhaps 3 orders of magnitude faster, solves for 3 turn strategies, and is in general far more flexible. The C++ version of the strategy finder is not shared, but you can run it through use of the Farkle Strategy Generator.


  9. Pingback: Analysis of Farkle | Possibly Wrong

  10. matt says:

    The analysis of Farkle found at Possibly Wrong which was done for a particular set of scoring rules produces an expected turn score of 542.063 points. The results of the FSG for these same score settings are identical giving strong evidence of correctness. You can see for yourself by running the FSG with these settings:,200,300,1000,2000,3000&set2=0,0,200,1000,2000,3000&set3=0,0,300,1000,2000,3000&set4=0,0,400,1000,2000,3000&set5=50,100,500,1000,2000,3000&set6=0,0,600,1000,2000,3000&straight=1500&threepair=1500&flexpairs=true&twotriplet=2500&nothing=0&penalty=0&minbank=0

  11. Zach says:

    Hi Matt! I was going to try to do exactly what you did here just for fun when I stumbled upon your website and realized the problem had been solved for me already :) Great work!

    I have a quick question. I am surprised that the expected points of a turn where there are 50 points currently accumulated and there are 5 dice to roll is greater than a turn where there are 100 points accumulated and there are 5 dice to roll (basically, keeping a 5 and rolling 5 dice is better than keeping a 1 and rolling 5 dice). Unless you play by slightly different rules than I do, I can’t think of why this is true. Do you have any thoughts?

    (I read the rules by which you play – they are slightly different but not in a way that would effect this. I play without zilching, a no-score first roll is not worth any points [and is horrible when it happens haha] and a roll of 4 of a kind and 2 of a kind [example 2-2-2-2-3-3] does not count as 3-pair).

    • matt says:

      Hi Zach,

      I think you are misinterpreting the tables. I assume you are looking at Table 2. E(s,n) for turn type T0. E(s,n) is the expected number of points for the rest of you turn assuming you roll from state (s,n) and thereafter follow the max-expected-score strategy. To get the expected score for the whole turn (given your current state within the turn) you have to add your current turn score: s + E(s,n). For the states you talking about we have:

      E(100,5) = 306.667
      E(50,5) = 322.318

      And the expected score the whole turn for these two states would be:

      T(100,5) = 100 + 306.667 = 406.667
      T(50,5) = 50 + 322.318 = 372.318

      So your intuition is right: the better play is to take one 1, and it does indeed yield a higher expected turn score.


Leave a Reply

Your email address will not be published. Required fields are marked *


Your comments will not appear until I've had a chance to screen them. This usually takes a day or less, but could be longer if I'm canoeing or camping or am otherwise beyond the reach of the internet. I respond to all questions.