I’ve wanted to write a post about the new Doctor Who series for a while, but this is not that post. Instead, this post is about a Macintosh game called Daleks, which I first played on a Mac 512 (running OS 3) in the mid-80’s. Research indicates that this game was based on a Unix game called robots, and that some wag came up with the idea of rebranding it under the name of the classic Doctor Who monster. The first version I played had a very peculiar high score table: all the high scores were attributed to a fellow named “fingers,” and the high scores were not in any sort of numerical order. Moreover, no matter what one scored, it was impossible to permanently make it onto the high score list. My second encounter with the game was during a summer research program with Alf van der Poorten in 94/95, where I was impressed to find that he had broken 10000. Later, I had a copy on an ancient laptop given to me by my brother, and still later, I played classic Daleks in classic mode under OS X. I am not ashamed to say that I am proud of my high score, 15670, a feat which is probably meaningless to almost everyone. Anyway, today’s post is about some mathematical problems related to this game. If you have a mac computer, I recommend playing around with some current incarnations of the game, for example super Daleks (presumably robot is available on Gnome games as well):
Consider the following game: the Doctor is positioned on the lattice at the origin , and Daleks are distributed on the rest of the lattice with uniform density . It turns out that it is more convenient to work with the parameter , although all the graphs below are drawn with respect to . On each move, the Dalek at point P moves to the unique neighbouring square (out of 8) which is closest to the origin in the taxicab metric. In particular, Daleks always move diagonally towards the origin unless they lie on one of the axes. If two or more Daleks occupy the same square, then they crash and are destroyed, leaving a pile of debris which remains at that square forever. Moreover, any other Dalek which later moves on to the same square now occupied by the debris is also destroyed. If a Dalek reaches the origin unscathed, the Doctor is exterminated. However, if the debris resulting from Dalek collisions prevents all other Daleks from reaching the origin, then the Doctor survives. What is the probability that the Doctor survives? (In the computer game the Doctor can also move about, but not in our simplified version.)
If a Dalek starts on either the diagonal or the anti-diagonal then it will never crash with another Dalek (in general, Daleks can only crash on the axes). Hence, we modify the game by forbidding Daleks from either of these diagonals. This effectively separates the playing area into four quadrants which do not interact, and so we may as well confine ourselves to a single quadrant, and assume that all Daleks lie in the quadrant where with . A sample game is as follows, with the positions at time 0, 1, and 2. The Doctor will win this game, because the debris at will prevent all other Daleks in the quadrant from reaching the origin (they will crash into the debris and be destroyed):
Let be the truncated quadrant consisting of with . Let denote the probability of surviving the game where Daleks only exist with density in this quadrant. It is clear that
where is the expectation of being exterminated by a Dalek which originates at point P. (If there is a Dalek which kills the Doctor, it is unique.) Note that is independent of , providing that .
Definition: The occludation of P consists of the squares R different from P where a Dalek at square R will reach the origin before or at the same time as P, and which reach the -axis at least as near to the origin as P reaches the -axis.
The Daleks are those for which R is in the shadow of R, namely, those R which eventually occlude P from the origin (thus the name). It is not a great name, but I couldn’t think of anything better. Explicitly, if , then
The Doctor can only be killed by Dalek at point P if the occludation is empty of Daleks. The reason is that any Dalek R in the occludation can only crash at points on the -axis where P must eventually travel, and R will reach this point either at or before P does. We have
On the other hand, conditional on the assumption that the occludation contains no daleks, then the probability that P exterminates the Doctor only depends on ; namely, it is equal to the probability of surviving the game with and . (This the the quadrant not in the occludation of .) It follows that
We may simplify this slightly by writing
This simplifies even further to
and hence, subject to and ,
The resulting recurrence relation for gives a decreasing convergent sequence (for each fixed and also in ) with limit
Here is a graph of this function (with respect to , remember that ):
Although it appears from the graph that the maximum occurs at , closer inspection reveals that the optimal density is The maximum value is approximately , which means that, on an entire plane with all four quadrants, the largest possible chance of winning (with daleks on the diagonal and anti-diagonal removed) is approximately 1 in 160.
Reverse the Polarity: Here is a different way to estimate , this time from below. In order for the Doctor to survive, two or three Daleks must eventually coincide at . Call such Daleks savior Daleks. All savior Daleks must be in the same row, and at least one such Dalek must lie on the edge of the quadrant. Let us now consider the probability that one will be “saved” by a Dalek in the th row. If is a savior Dalek, then the Dalek creates the first crash at the point , and no Dalek exterminates the Doctor before this point. It follows that no Daleks may occlude , and hence must be free of Daleks, with the possible exception of . Note that . Suppose that is not occupied. Then (assuming that is empty) will be a savior Dalek if and only if the remaining restricted quadrant of size would otherwise result on the Doctor being exterminated at the final term, equivalently, the probability that, from a quadrant of size , the Doctor would be exterminated by a Dalek in the last row. Yet the probability of this is
and hence the contribution to is
On the other hand, if both and are to be savior Daleks, then one simply requires that, in addition to the rest of occlusion being empty, that in the remaining quadrant of size (removing the final row and the occlusion) no Doctor is exterminated, and this has probability . Hence
Let be the probability that there exists a savior Dalek at a row at most . Then clearly
Moreover, we naturally have inequalities , and
where the limit is pointwise and . However, the behavior of and is quite different in the regime or , as the following graph of shows:
Behavior as :
In order to estimate the behavior of as , we consider the following problem:
What is the probability that the first row with any Dalek contains exactly two Daleks, and that at least one of these Daleks lies at the edge of the quadrant? In such a situation, the Daleks necessarily annihilate one another at , and the Doctor is saved. Call the resulting function , so . Since there are pairs of elements in which contain at least one of the end points, we have
Let . As , we have , and so . On the other hand, by Poisson summation, we have
from which it follows easily that , and thus
In fact, we can actually prove that
In other words, the simple model above is very accurate in the limit . However, the combinatorics required to prove this are actually somewhat involved and annoying, and this is a blog, so I will omit it here. (The arguments are somewhat timey–wimey.)
A conditional game:
Consider the game which is pre-conditioned on the first square being empty. Since that square containing a Dalek is not consistent with survival, the new game results in a win with probability:
Apropos of nothing, here’s Davros enjoying a cuppa:
Suppose that the Doctor has a TARDIS. This allows him, at any point, to dematerialize and the materialize somewhere else. In the context of the classic Daleks game, the player appears at a random point in the plane with uniform distribution. Although this doesn’t quite make sense on an infinite plane, we can take it to mean that we have moved sufficiently far away from the axes that it is as if the game has started again. Hence this will be the context in which we shall consider rematerialization, namely, as if the game has started again. The catch with using the TARDIS is that the Doctor may materialize next to a Dalek, in which case he is immediately exterminated. The optimal strategy is to continue to continue rematerializing until one has a winning game. The chance of surviving a rematerization is ; the resulting game is the same, but now conditional on not being annihilated by the initial Dalek, hence is equivalent to the conditional game descibed above. It follows that the chances of survival are:
The asymptotic behavior of this function as (or ) requires the correct asymptotic , and from this we can deduce that
In this case, we see that the optimal probability is that the density tends to zero. Here is a graph of :
The Sonic Screwdriver: Like John Nathan-Turner, I find the sonic screwdriver to be somewhat ridiculous. Although it does exist in some versions of the game, I will only mention a minor modification here. The “sonic” in the game allows the Doctor to survive for one round when he would otherwise be exterminated; it has only one use. We shall additionally assume that the sonic can only be used on the very first round. This essentially changes the game (at the beginning) into the conditional game described above. If one is allowed to use the TARDIS as above, the resulting probability of winning is
As , this function tends to 1, and as , it tends to . The behavior of this function in a neighbourhood of appears to be of the form
for some constant , possibly around . Note that this function is not monotone; the most dangerous density of Daleks is approximately , where the resulting probability of surviving dips below .
Here’s an example of the vanilla game at the optimal : the Doctor lives!