4

The rules of the game are as follows:

  • There are two players.
  • The game starts with N number of game pieces arranged side by side in a row.
  • Taking turns, each player removes one game piece.
  • A piece can only be removed if there is another piece immediately to its right.
  • A player loses if they cannot remove a piece.

For instance, if the current game-state is XOOXXX, where X denotes a game piece and O an empty space, only the pieces on the 4th and 5th spaces can be removed. The pieces on the 1st and 6th spaces do not have another piece immediately to their right. If the piece on the 5th space is removed, the game-state becomes XOOXOX. There are now no removable pieces, and the player whose turn it is to remove a piece loses.

I have not been able to deduce an optimal strategy for this game, but here are some of the thoughts I have had (which might not be of interest):

There are essentially two types of moves, one where one piece is removed OXX --> OOX, and one where one piece is removed and another is left unremovable XXX --> XOX (the leftmost piece can no longer be removed). Since the second type is essentially removing two pieces from the pool of removable pieces, I was thinking it should be possible to do something with parity, e. g. always make sure there are an odd number of removable pieces, but I haven't gotten anywhere with this.

As the game progresses, the pieces are split into smaller and smaller groups of adjacent pieces, so another idea I had was to treat every group as its own subgame, but I think this is a dead end as the same player can make several moves in a group if the other player leaves it alone.

I was also thinking it might be possible to apply some kind of induction or dynamic programming logic, but I'm not very good at that.

Any input on the matter is greatly appreciated :)

  • 2
    You need to find the nimber corresponding to each length of a run of Xs. A single X is 0 as no move is possible. Two is 1 as it can move only to $0$ Three can move to 0 or 1, so it is *2. Then add them up and choose a move that leaves a 0 position. – Ross Millikan Dec 30 '23 at 00:30
  • "another idea I had was to treat every group as its own subgame" This idea is not only is the key to this problem, it's essentially why the field is called "Combinatorial Game Theory". The game breaks into a combination of smaller games which have values you need to combine. – Mark S. Dec 30 '23 at 10:55

1 Answers1

4

Not a full answer, but a few notes:

  • Pretty straightforwardly, there is no interaction between segments of X's; as soon as there's an O between them then the presence of one no longer affects any moves in the other. This means that we only have to keep track of the lengths of the segments.
  • Slightly less obviously, the only segment in which the 'there is a piece immediately to its right' constraint matters is in the single-piece segment. For instance, for a segment of length four, we're not allowed to take the rightmost X and turn it into a segment of length three — but we can still take the leftmost X with exactly the same result, so the constraint has no effect.

Between these, we get that the nim-value $\nu_n$ of a run of length $n$ is $\mathop{mex}_{0\leq i\lt n}(\nu_i\oplus\nu_{n-i-1})$, where $\mathop{mex}$ denotes the 'minimal excluded' value, with initial conditions $\nu_0=\nu_1=0$. Now the simplest thing to do is to just go look in Winning Ways for your Mathematical Plays, but since my copy is currently 3000 miles away, the next simplest thing to do is to start calculating and look for a pattern. We get $\{\nu_i: i\geq 0\}$ $=\{0, 0, *1, *2, 0, *1, *2, *3, *1, *2, *3, *4, 0, \ldots\}$, and this is enough to look for a pattern — which is to say, 'cheat' and look on OEIS for the sequence. Doing this, we come to https://oeis.org/A046695 which has more information and references.

  • 1
    Incidentally, because the game is an "octal game", those nim-values are eventually-periodic if they appear to start a repeating pattern of sufficient length. 140 trillion values have been calculated (see Grossman's "Searching for periodicity in Officers"), but no pattern has been found. It's still open. – Mark S. Dec 30 '23 at 10:52
  • Thanks for the answer :) I'm not familiar with that notation, am i right in assuming that for instance v_3 = mex({v_0 ⊕ v_2} U {v_1 ⊕ v_1} U {v_2 ⊕ v_0})? Also, is the ⊕ operator nim-addition as defined here: https://en.wikipedia.org/wiki/Nimber ? – blueshellplsno Dec 30 '23 at 13:55
  • 1
    @blueshellplsno You're right, but it's weird to use unions of singletons. Just write $v_3=\operatorname{mex}\left({v_0\oplus v_2,v_1\oplus v_1,v_2\oplus v_0}\right)$. Yes $\oplus$ is nim addition as on the page for Nimbers. If you're new to this theory, then see the Community Wiki answer to Tutorials for Sprague-Grundy Theorem/Nimbers?. – Mark S. Dec 30 '23 at 18:37
  • Thanks. Another comment states that the way to win is to "add them [the Nim numbers of the different runs of pieces] up and choose a move that leaves a 0 position", is this addition done using ⊕ as well? – blueshellplsno Dec 30 '23 at 19:31
  • 2
    @blueshellplsno Yes. (Adding nonnegative numbers wouldn't be able to give you zero otherwise.) I strongly recommend reading through a tutorial on this stuff rather than trying to pick it up indirectly through comments/answers here or on wikipedia alone. – Mark S. Dec 30 '23 at 23:00
  • I agree that a tutorial would be best, I've looked into getting my hand on a copy of Winning Ways for your Mathematical Plays as it has been mentioned a lot online. I do have one final question if you will entertain me. I tried to calculate $\nu_2$, but my calculation is clearly flawed: $\nu_2 = mex(\nu_0 \oplus \nu_1) = mex(mex(\emptyset \oplus \nu_1, \nu_0 \oplus \emptyset) = mex(mex(0, 0)) = mex(1) = 0$. Intuitively I can see that it must be $1$, but I cannot derive it from the formula. – blueshellplsno Dec 31 '23 at 11:10
  • 1
    @blueshellplsno The step going from $\mathop{mex}(\emptyset\oplus\nu_1, \nu_0\oplus\emptyset)$ to $\mathop{mex}(0, 0)$ is incorrect; $\nu_0\oplus\emptyset$, for instance, represents the result of nim-adding $\nu_0$ to each member of the set $\emptyset$ — which is to say it's $\emptyset$, not 0. And $\mathop{mex}(\emptyset)=0$, so you have $\nu_2=\mathop{mex}(\nu_0\oplus\nu_1)$ $=\mathop{mex}(\mathop{mex}(\emptyset\oplus\nu_1, \nu_0\oplus\emptyset))$ $= \mathop{mex}(\mathop{mex}(\emptyset, \emptyset))$ $=\mathop{mex}(\mathop{mex}(\emptyset))$ $=\mathop{mex}(0)=*1$. – Steven Stadnicki Dec 31 '23 at 17:48
  • 1
    (Note that the comma in $\mathop{mex}(\emptyset\oplus\nu_1, \nu_0\oplus\emptyset)$ represents a union here, in a similar fashion to how $\mathop{max}(1,2,3)$ is $\mathop{max}({1}\cup{2}\cup{3})$ $=\mathop{max}({1, 2, 3})=3$.) – Steven Stadnicki Dec 31 '23 at 17:51
  • "Winning Ways for your Mathematical Plays as it has been mentioned a lot online" It's been mentioned a lot online because it was basically the first book about CGT and hence the most well-known. It's not written like a textbook, and for first-time self-study, I'd recommend essentially every other source in the post I linked before I'd recommend "Winning Ways". @blueshellplsno – Mark S. Jan 01 '24 at 16:55