Minimum Spanning Trees

Projects

 15.33 Implement the game of Nine Men's Morris (Figure 15-41). 15.34 Implement the game of Aggression (Figure 15-42). Generate the board randomly, so that a city has a 50% chance of being connected to each of the cities next to it horizontally, vertically, or diagonally.

Figure 15-41. Nine Men's Morris is one of the oldest games in existence.

Nine Men's Morris

Players: 2

Object: To either reduce the opponent to two pieces or to leave the opponent with no legal move.

Board: See below. The pieces (merels) are placed on the dots (points) and moved along the lines to adjacent points. Each player gets nine merels in her color. The board is initially empty.

Play: Players take turns. On a turn, a player places a merel on an unoccupied point. If a player has no merels left to place, she instead moves one of her merels to an adjacent point.

Capture: If a player's move causes three of her merels to be in a horizontal or vertical line through adjacent points, she has formed a mill. She gets to remove any one of the opponent's merels from the board. If possible, she must choose a merel which is not currently part of a mill. The removed merel is discarded; the opponent does not get it back.

Game End: The game ends when one player either has only two merels or has no legal move. This player loses.

Figure 15-42. Aggression is a simple, abstract wargame.

Aggression

Players: 2, black and white.

Object: To control the most cities at the end of the game.

Board: There are 20 cities and some roads on the board. Two cities are adjacent if they are connected by a single road segment. The board may be different in each game. A typical board is shown below.

Setup: The board is initially empty. Each player starts with 100 troops. In turns, each player places one or more troops in any unoccupied city to claim it. This continues until all cities have been claimed or both players have deployed all of their troops. An example is shown below.

Play: Taking turns, each player chooses a city to attack. The attack is successful if the number of troops in the city is less than the number of opposing troops in adjacent cities. After a successful attack, the defending troops are removed and the city becomes neutral. The attacking troops are unaffected. An unsuccessful attack has no effect.

As an example, in the game above, black could successfully attack the upper white 20 (with 45 adjacent troops), but not the lower white 20 (with only 15 adjacent troops).

Game End: The game ends when either one player has no troops left or there are no successful attacks left to make. The player controlling the most cities wins.

Data Structures and Algorithms in Java
ISBN: 0131469142
EAN: 2147483647
Year: 2004
Pages: 216
Authors: Peter Drake

Similar book on Amazon