Bart Massey
bart@cs.pdx.edu
Acro-Nim (from the Latin acro, heights, hence ``High Nim'') is a Nim variant with some interesting rules.
The basic game is 1-3-5-7 Nim, with the winner taking the last stone. To review the Nim rules: Nim is a game played with (unordered) piles of stones. Players alternate in taking one or more stones from a single pile and discarding them. The player that takes the last stone from the board wins. 1-3-5-7 Nim is the variant where there are four initial piles, of size 1, 3, 5 and 7.
Acro-Nim has four specific rules that alter the basic Nim game.
The Z formal specification notation is described elsewhere. In this section, it will be used to formalize the rules of Acro-Nim.
The state of a game of Acro-Nim consists of the state of the board and of two players. We will call these players North and South, and let South move first.
The Acro-Nim board consists of piles of stones. We will
model these piles using schema. There are no empty piles: a
pile ceases to exist when its last stone is removed. Our
board design urges to keep track of whether a pile contains
poison stones or not as part of the pile state. While the
rules given above mention only one poison stone, it is
convenient to generalize the specification to handle other
initial positions.
The board is a set of piles.
The initial board is the 1-3-5-7 board with the 7 pile
containing one poisoned stone, described above. A helper function is useful
to generate the piles.
The player state consists of the set of resources
available to the player. While the game as described above
only allows a single equalizer or split, it is convenient
to generalize the specification to allow other initial
states and/or rules.
The initial player state is as described.
It will be necessary to have a record of move types, and
of the state of play. It is also necessary to name the
players.
The game state consists of the board state, the state of
each player, a record of the last move type (for the draw
rule), and an indication of the state of play.
The initial state is as described above.
The moves in Acro-Nim are all transformations on the
game state. The player on move alternates.
There are four distinct types of move.
To conveniently annotate the various types of moves,
it is useful to formalize the notion of a player state adjustment.
A take move takes a selected number
of (poisoned and/or non-poisoned) stones from a selected pile
according to the rules of Nim. A pile disappears
when its last stone is taken. The poison stone has
to be handled carefully.
If the player has a pass token, they may pass. If the
previous move was a pass, then the game is drawn.
Otherwise, play continues in the same board state.
A sensible way to handle split and equalizer moves is to
construct a function that levels a set of piles. This
function proceeds in two phases. First, the set of piles
is combined into a single big pile containing all the
stones.
Next, the big pile is split into the requested number
of smaller piles. The piles are split as evenly as
possible, as are the poison stones: the poison stones are
placed in the larger piles if possible.
If the player has not consumed all of their splits, they
may select a pile of two or more stones containing
no poison stones and
split it as evenly as possible.
Finally, if the player has not consumed all of their equalizes, they
may pile up all the stones and split them as evenly as
possible into the
same number of piles they started with.
A legal game of Acro-Nim consists simply of those moves
described above that are legal in the given state.
The terminal states are those which have no successor
because the game is over.