Two Pile Move-Size Dynamic Nim

The purpose of this paper is to solve a special class of combinational games consisting of two-pile counter pickup games for which the maximum number of counters that can be removed on each successive move changes during the play of the games. Two players alternate moving. Each player in his turn first chooses one of the piles, and his choice of piles can change from move to move. He then removes counters from this chosen pile. A function f : Z + ! Z + is given which determines the maximum size of the next move in terms of the current move size. The game ends as soon as one of the two piles is empty, and the winner is the last player to move in the game. The games for which f(k) = k, f(k) = 2k, and f(k) = 3k use the same formula for computing the smallest winning move size. Here we find all the functions f for which this formula works, and we also give the winning strategy for each function. See [7] for a discussion of the single pile game.


Introduction
Two players alternate removing counters from two piles.Each player in his turn first chooses one of the piles, which can change from move to move.He then removes counters from this pile.An ordered triple (a, b, x) = (b, a, x) of positive integers is called a position, where a and b represent the sizes of the two piles of counters, and x represents the greatest number of counters that can be removed from the chosen pile on the next move.A function f : Z + → Z + is given which determines the maximum size of the next move in terms of the current move size.Thus a move in a game is an ordered pair of positions (a, b, x) → (a − k, b, f (k)), where 1 ≤ k ≤ min(a, x), or (a, b, x) → (a, b − k, f (k)), where 1 ≤ k ≤ min(b, x).The game ends as soon as one of the two piles is empty, and the winner is the last player to move in the game.At the start of the game, the position (a, b, x) is specified.We started this project by studying the strategy for the simple move functions f (k) = k, f (k) = 2k, and f (k) = 3k.We then noticed that the smallest winning move size for each of these three functions is computed by the same formula, which we will soon state in the main theorem.We then took upon ourselves the problem of finding (with proof) all functions f : Z + → Z + for which this formula works.This paper gives the complete solution to this problem.This also explains why many of the functions that we must include may seem quite artificial.
As an example, consider the function f (k) = k and the initial position (a, b, x) = (3,4,2).This means the first moving player can take 1 or 2 counters from either pile.Suppose he removes 2 counters from the pile with 4 counters.The move can be depicted as Then the second moving player can remove 1 or 2 from either pile.Suppose he takes 2 from the pile with 2 counters.He wins the game because he has created an empty pile.

For all
The admissible functions are precisely the ones that satisfy our main theorem.It is easy to see that f (N) = N, f (N) = 2N, f (N) = 3N satisfy these 4 conditions, but f (N) = 4N does not.Also, if r > 0 is a real number, f (N) = rn satisfies these 4 conditions if and only if 1 ≤ r < 4. Also, f (N) = rn satisfies these 4 conditions if and only if 1 ≤ r ≤ 3. Of course, the functions included in Definition 2 can be far more complex than any of these 'primitive' functions.
We now make the problem more precise.

The Problem
Two players play the game using an admissible function f .If a, b are the two pile sizes, the pile position can be denoted either as (a, b) or as (b, a).For every pile position (a, b), we wish to compute L(a, b), which we define as the least winning move size.This means that a winning move is a remove L(a, b) counters from one of the piles.Of course, L(a, b) by itself does not necessarily tell the player from which pile L(a, b) is to be removed.However, this fact will be revealed in the proof that we soon give.We also state this strategy immediately after the main theorem.Also, if x < L(a, b), the removal of x counters must be a losing move no matter from which of the two piles x counters is removed.

The Solution
We In this paper, it is more convenient to denote a pile position as (a, N), where a ≤ b and N = b − a.Thus (a, N) means that 'a' is the smaller pile size and N is the difference between the larger pile size and the smaller pile size.Hence we wish to compute L(a, N), 0 ≤ a, 0 ≤ N. Of course, L(0, N) = ∞.The following theorem finds L(a, N) for all admissible functions.Main Theorem.Let f : Z + → Z + be an admissible function.For all positions (a, N), where a ≥ 1, the least winning move L(a, N) is computed by the following rule: Strategy.The strategy also provides a partial outline of the proof of the main theorem.Case 1.If a ≤ f (g(N)), then L(a, N) = a.The moving player removes a counters from the smaller pile and wins immediately.
Case 2. If a > f (g(N)), then L(a, N) = g(N) and, from Note 1, which we state and prove in section 5, g(N) < a.The strategy has two subcases.
A. Suppose g(N − g(N)) ≥ 4g(N).This includes the subcase where N − g(N) = 0.The moving player removes g(N) counters from the larger pile.
(1) Suppose f (g(N) < 2g(N)).Then the moving player removes g(N) from the larger pile. ( , then the moving player removes g(N) from the smaller pile.But if f (g(N)) ≥ a − g(N), then the moving player removes g(N) from the larger pile.
Remark.At the end of the paper, we show that the main theorem is true for an arbitrary f : ).Of course, L(a, N) ≤ a is also clear since the removal of a counters from the smaller pile is an immediate win.We will prove the main theorem by first proving three lemmas.
Proof.Use the binary representation.
Then it is easy to see that there exists x ∈ B such that f (x) > f (2x), since f cannot be non-decreasing on {x, 2x, 4x, 8x, . . ., y}.Now since 2x ∈ B, we know by Condition 3 on Given the position (a, N), suppose we remove x counters from the larger pile.The new position becomes (a, N − x) as long as 0 ≤ N − x.However, if N − x < 0, the new position becomes (a + N − x, x − N).This is because when N − x < 0, the smaller pile size becomes a + N − x, the larger pile size becomes 'a' , and the difference between the larger and smaller pile size becomes x − N. We now state Lemma 3. Lemma 3. Suppose f is admissible and the conclusion of the main theorem is true for all positions (a, N), a ≥ 1.
For the position (a, N), suppose a ≤ f (g(N)).That is, (a, N) comes under Case 1 of the main theorem.Suppose x counters are removed from the larger pile, where N < x < a + N. The new position becomes (a + N − x, x − N), where 1 ≤ a + N − x < a and 1 ≤ x − N. Then it cannot be the case that f (x) < L(a Proof.Since the main theorem is true for the position (a + N − x, x − N) and also 1 . We now consider two cases: Case A: g(x) = g(N), and Case B: It is important to note that although Lemma 3 assumes the main theorem is true for all positions (a, N), a ≥ 1, it can also be used later in the induction argument since 1 ≤ a + N − x < a, the induction will be on a, and we will only be interested in the position (a + N − x, x − N).

Starting the Induction
We now prove that the main theorem is true for all positions (a, N), a ≥ 1, by mathematical induction on a.Of course, L(0, N) = ∞.Now L(1, N) = 1 is obvious for all N since the removal of 1 counter from the smaller pile is an immediate win.Also, a = 1 ≤ f (g(N)) is true for all N, which means that the theorem requires L(1, N) = 1.
Since the induction is started, we can assume the theorem is true for all positions (a, N), a = 1, 2, . . ., a − 1, a ≥ 2. We will now prove that the theorem is true for all positions (a, N).We do this by induction on N in the order (a, 0), (a, 1), (1, 2), (a, 3), . . . .First, note that for all positions (a, N), a ≥ 1, it is true that L(a, N) ≤ a.This is because the removal of a counters from the smaller pile is an immediate win since a is the smaller pile size.We now show that L(a, 0) = a, as is required by the theorem.By symmetry, since a = b, we see that L(a, 0) is the least x ∈ {1, 2, . . ., a} such that f (x) < L(a − x, x).First, we show that x / ∈ {1, 2, 3, . . ., a−1}.Now f (g(x)) ≤ f (x) by Condition 1 on f .From Note 1 (since a−x ≥ 1) and from the induction, we know that L(a − x, x) ≤ f (g(x)) ≤ f (x).Therefore, if x ∈ {1, 2, . . ., a − 1} and f (x) < L(a − x, x), we would have f (x) < L(a − x, x) ≤ f (x), a contradiction.Of course, when x = a, we have the obvious fact that f (x) = f (a) < L(a − a, a) = L(0, a) = ∞.Therefore, L(a, 0) = a is true, as it should be.

Main Induction
Next, we deal successively with L(a, N), N ≥ 1 and N starting at N = 1 and increasing.We assume that main theorem is true for N ∈ {1, 2, . . ., N − 1}, and we show it is true for (a, N).
To evaluate L(a, N), we must find the least x ∈ {1, 2, 3, . . ., a} such that (a) f (x) < L(a, N − x), and N − x ≥ 0, or where we note in (a) that we only need to consider x where N − x ≥ 0. This is because of two reasons.First, when a > f (g(N)), we need to prove L(a, N) = g(N).Now g(N) ≤ N when N ∈ Z + .Therefore, we only need to consider x in the range 1, 2, 3, . . .g(N), and obviously 0 ≤ N − x in this range.Second, when a ≤ f (g(N)), Lemma 3 along with the mathematical induction of those (a, N)'s that we have already dealt with shows us that f (x) < L(a Note that 1 ≤ a + N − x < a when x ∈ {1, 2, 3, . . ., a}, 1 ≤ N, and N − x < 0 which means that the induction on a can be used.This means that Lemma 3 can be used with the induction on a since a + N − x < a, a technicality that we mentioned above.We will now consider two cases for (a, N), which correspond to the two cases given in the main theorem.

The Two Cases
Case 1: a ≤ f (g(N)).We must show L(a, N) = a.
Case 2: a > f (g(N)).We must show L(a, N) = g(N).We take care of (a) first, and we consider two subcases for (a).Of course, we can assume N − x ≥ 0 in (a) as we have already shown.
Subcase A: f (x) ≥ a.If (a) is true, we have f (x) < L(a, N − x) ≤ a ≤ f (x), a contradiction.Note that L(a, N − x) ≤ a is true since for any position (a, N), a ≥ 1, it is always true that L(a, N) ≤ a since a is the smaller pile size.
We now deal with Case 2.
Dealing with x = g(N).Let us now show that x = g(N) will satisfy at least one of (a) or (b).We consider two possibilities.Remember, g(N) < a and g(N) ≤ N.
First, suppose g(N−g(N)) g(N) ≥ 4.This also includes the case where N − g(N) = 0, so that g(N − g(N)) = ∞.We show that x = g(N) satisfies (a).That is ) < a, by the definition of Case 2. Therefore, f (x) = f (g(N)) < L(a, N − x), since f (x) < a and f (x) < g(N − x) and L(a, N − x) ∈ {a, g(N − x)} where we note that L(a, N − x) ∈ {a, g(N − x)} is true by induction since 0 ≤ N − x < N.This means that (a) is satisfied by x = g(N).
We next assume x = g(N) satisfies x + f (x) ≤ f (2x) along with the above assumption that x = g(N) satisfies g(N − x) = 2x.Now g(N − g(N)) = 2g(N) implies 4g(N) ≤ g(N + g(N)) since N must be of the binary form That is 4x ≤ g(N + x).
We now consider two subcases, where x = g(N).Recall that f (g(N)) < a in Case 2.
Subcase B: f (x) ≥ a−x.We now show that (a) is satisfied by x = g(N).This means that we show f , by the definition of Subcase B and the above assumption about x.Therefore, a ≤ f (2x).Also, g(N − x) = 2x from the above assumption.Therefore, f (g We now state the converse of the main theorem. Converse Theorem.Suppose f : Z + → Z + , f (∞) = ∞, is given, and we play our game with this function f .Suppose also that the conclusion of the main theorem is true for f .Then it is also true that f satisfies all of the 4 conditions listed in Definition 2.
In binary we can write x = 1 0000 , N = 3x = 11 0000 , where 0000 represents a string of 0's.Since x ∈ B, it is obvious that N = 3x satisfies g(N) = g(3x) = x, g(N − g(N)) = 2g(N) = 10 0000 , and g(N + g(N)) = 4g(N) = 100 0000 .Of course, by assumption, f (x) = f (g(N)) ≥ 4g(N) = 4x.Since the main theorem is true for (a, N) = (a, 3x), we know the following.First, since a > f (g(N)), we know that L(a, N) = g(N).Of course, we are also assuming a > g(N).This means that the removal of g(N) from at least one of the two piles must be a winning move.Therefore, one of the following must be true.Either f (g(N)) < L(a, N − g(N)) or f (g(N)) < L(a − g(N), N + g(N).Now by the assumption on a, we know that a > f g(N − g(N)) and a − g(N) > f g(N + g(N)) .Therefore, by the main theorem, L(a, N − g(N)) = g(N − g(N)) = 2g(N).
define L(a, b) = ∞ if a = 0 or b = 0 because the game is over once one pile is empty.We can easily see that L(a, b) is the least x ∈ {1, 2, 3, . . ., min{a, b}} such that f (x) < L(a − x, b) or f (x) < L(a, b − x).Of course, L(a, b) = L(b, a).