CMSC 22001: Software Construction Assignment 3: Carcassonne Rules

Due: Jan 25, 2006 @ 3pm

Your task is to implement a rules checker for Carcasonne.

Design a data structure for representing a map (including tiles and meeples) that supports the following operations:

  • adding a new tile to the map
  • placing a meeple onto a region on that tile
  • recovering meeples from completed regions
  • getting the score for the completed regions of a just-placed tile, and
  • getting the score for fields and incomplete regions as if the game were over

Don't implement the game playing infrastructure (yet), but to put this in context, imagine that during a turn, a player will invoke the operation for placing a tile and the one for placing a meeple (if necc). These operations will then check the legality and handle the score computations for that (one) turn, but the code so far will have no memory of what the meeple count for players is, or what the running score total is.

The operation for adding a tile should be a function of four arguments:

  • the map,
  • a tile identifier,
  • a number between 0 and 3 indicating how far the tile has been rotated (matching the numbers on the tiles page), and
  • an x and y coordinate.
The initial tile always goes at (0,0).

The operation for placing a meeple should specify which region to place the meeple by specifying

  1. an edge of a tile: left, top, right, bottom or center (where center indicates the meeple is to be placed on a cloister in the center of the tile),
  2. and in the case of a road edge, a number 0, 1, or 2.
The edge indication is after the tile is rotated, not before. The number indicates the region by counting clockwise along the edge.

As an example, consider the initial tile:

To place a meeple in the town, specify the top edge. To place a meeple in the upper field, specify the right edge with the number 0, or the left edge with the number 2. To place a meeple on the road, specify the left edge with the number 1, or the right edge with the number 1. To place a meeple in the bottom field, specify the bottom edge, or specify the right edge with the number 2 or the left edge with the number 0.



CMSC 22001: Software Construction