• No se han encontrado resultados

Capítulo 5. Descripción detallada de la solución

5.2 Estructura de software y hardware para hospedaje y ejecución de rutinas

5.2.5 Soporte mecánico temporal

Can we yet spot the structure of the balanced positions in 3–pile Nim? A flash of insight would help and perhaps you have had one. If not, then the line of reasoning we now follow will lead us closer to the moment of recognition.

The bright idea we need to progress further is apparent in the experiments we have so far performed, provided we look at things from a new point of view. We noticed that all these positions were balanced:

(1,1,0)as well as(2,2,0),(1+2,1+2,0),(2,1+2,1+0), and(1+2,2,1+0). This includes(3,2,1), so(1,2,3)would be balanced too.

The same kind of doubling produces yet more balanced positions:

(1,2,3)as well as(2,4,6),(1+2,1+4,6),(2,1+4,1+6)and(1+2,4,1+6). Starting at(2,2,0)and using the same pattern produces

A little checking shows that these too are balanced.

If we were to include in this list all the different permutations we would recognize that we have obtained all of the balanced positions close to the end of a 3–pile game just by doubling and redoubling (1,1,0)and maybe adding a couple of 1’s each time. If we continue this process further perhaps we can generate all balanced postions.

Examples such as these suggest that doubling a balanced game does not change its status. Nor does doubling and adding 1 to two of the piles. If that turns out to be true, it will give us a large collection of positions whose status we will know. Here is our conjecture.

Near doubling Start with any Nim position(x,y,z). Any of the four positions (2x,2y,2z), (2x+1,2y+1,2z), (2x+1,2y,2z+1), or(2x,2y+1,2z+1) are said to be near-doubles of (x,y,z). Note that a position cannot be a near double of more than one choice of(x,y,z).

3.4.2 (Near doubling argument) A position(x,y,z)in 3–pile Nim is balanced if and only if it is a near-double of another balanced position.

To prove this statement we use an argument that should be familiar to us. We used it before in our even/odd analysis of the game of binary bits. Let us call a position a red position if it is near-double of a balanced position. Every other position is said to be a black position.

The end position is red The end position in a three pile game of Nim is (0,0,0). Since this is balanced and is its own near-double the end position is red.

Any red position must move only to a black Start with any of these red positions:

(2x,2y,2z), (2x+1,2y+1,2z), (2x+1,2y,2z+1), or(2x,2y+1,2z+1) where we are assuming that(x,y,z)is balanced.

It is enough for our argument to consider only moves that take away sticks from the first pile—the argument is the same for the other cases. Taking away an even number 2k of sticks from the first pile results in

(2x,2y,2z) (2[xk],2y,2z),

(2x+1,2y+1,2z) (2[xk] +1,2y+1,2z),

(2x+1,2y,2z+1) (2[xk] +1,2y,2z+1) and

3.4. NIM 119 We recognize a doubling or near-doubling of the pile(xk,y,z). But(xk,y,z) must be unbalanced since it came from a move out of the balanced position (x,y,z). Consequently all of the resulting positions are black, i.e., all of our red positions have moved to black if we remove an even number of sticks.

Start again with any of these red positions:

(2x,2y,2z), (2x+1,2y+1,2z), (2x+1,2y,2z+1), or(2x,2y+1,2z+1) but this time remove an odd number 2k1 of sticks, again from the first pile:

(2x,2y,2z) (2[xk] +1,2y,2z),

(2x+1,2y+1,2z) (2[xk+1],2y+1,2z),

(2x+1,2y,2z+1) (2[xk] +2,2y,2z+1) and

(2x,2y+1,2z+1) (2[xk] +1,2y+1,2z+1).

Again we recognize all of these positions to be black, i.e., all of our red positions have moved to black if we remove an odd number of sticks.

Any black position can be moved to at least one red We need to consider several cases of black positions and, for each one, determine how to make the correct move to a red position.

1. Suppose that(2x,2y,2z)is a black position. Then (x,y,z)is unbalanced and so there is a balancing move which leaves, say, the position (xk,y,z). Since that position is balanced, the doubled position

(2x2k,2y,2z)

is a red position. This gives us a way to move from the black to the red if we start at(2x,2y,2z)assumed to be a black position. Take away 2k sticks.

2. Suppose that(2x,2y+1,2z+1)is a black position. Then (x,y,z)is un- balanced and so there is a balancing move which leaves, say, [Case 2a] the po- sition(xk,y,z)or [Case 2b] the position(x,yk,z)or [Case 2c] the position (x,y,zk). We need consider only the first two cases.

In Case 2a the position(xk,y,z)is balanced, hence the near-doubled po- sition

(2[xk],2y+1,2z+1)

is a red position. This gives us a way to move from the black to the red if we start at(2x,2y+1,2z+1)assumed to be a black position. We remove 2k sticks from the first pile.

In Case 2b the position(x,yk,z)is balanced, hence the near-doubled po- sition

(2x,2[yk] +1,2z+1

is a red position. This gives us a way to move from the black to the red if we start at (2x,2y+1,2z+1)assumed to be a black position. We remove 2k1

sticks from the second pile.

3. Suppose the starting position is (2x+1,2y,2z); this is always a black position since two of the entries are even. If (x,y,z)is balanced then there is an obvious move: take away 1 from the first pile to produce the red position (2x,2y,2z). If, however,(x,y,z)is unbalanced we can balance it to the position (xk,y,z) or perhaps (x,yk,z) (the remaining case is similar). In the first situation(2[xk],2y,2z)is a red position which we obtain by removing 2k1 sticks. In the second situation(2x+1,2[yk],2z)is a red position which we obtain by removing 2k1 sticks.

4. The only case that we must finally consider is a position of the form (2x+1,2y+1,2z+1); this is always a black position since each of the entries is odd. How can we move to a red position?

If(x,y,z)is balanced then there is an obvious move: take away 1 from the first pile to produce the red position(2x,2y+1,2z+1). If, however,(x,y,z)is unbalanced we can balance it to the position (xk,y,z) (the remaining cases are similar). Then(2[xk],2y+1,2z+1)is a red position which we obtain by removing 2k1 sticks.

Conclusion Our analysis shows that we can win the game, starting from a black position, since we can always find a way to produce a red position and our opponenet must always produce a black position. Eventually we end up with the position(0,0,0)which is a red position and we win. This is exactly the same as the balanced and unbalanced argument and shows that the red positions are simply the balanced positions and the black positions are the unbalanced one. So now we can drop the red and black language and go back to balanced and unbalanced.

We have not really solved the game, we have just found a convenient way of describing balanced positions in the language of near-doubling. A little more thinking about this, however, leads to an elegant solution.

Documento similar