Due: Wednesday, February 10th, 2010 9:40am
This assignment starts a project in implementing a player of the Clue board game. We will use this copy of the rules, plus any clarifications (as needed) in clue-board.txt.
The file clue-board.txt contains a map of the Clue board, which is a 25x25 grid. Your program can use the first 25 lines (each of which has 25 characters) to initialize its view of the board.
The state of the board coresponds to the player positions among (distinct) cells and (possibly shared) rooms; in the case of a room, the board state also includes whether the player was moved into the room by a suggestion or whether the player moved/stayed in the room voluntarily. We will use a parenthesized list of parenthesized pairs of numbers or letters. The first pair is the position of Scarlet, the second is for Mustard, the third is for White, the fourth is for Green, the fifth is for Peacock, and the sixth is for Plum. (The order corresponds to the numbers in clue-board.txt, and it will also be the turn order.)
Each pair is either a pair of numbers or a pair of uppercase letters. A pair of numbers corresponds to a cell by counting cells down and right, where the top-left cell is (0 0). A pair of letters is a room letter followed by either S (moved by suggestion) or V (moved/stayed voluntarily).
The initial board state is represented by ((17 24) (24 17) (15 0) (10 0) (0 6) (0 19)).
A board state where Scarlet moved in the lounge by dice roll and Plum was moved there by suggestion would be ((U V) (24 17) (15 0) (10 0) (0 6) (U S)).
Pairs of numbers in a board state must correspond to cells marked with -, a lowercase letter, or a number on clue-board.txt. In the case of a number, only the corersponding player can be on the number, and only as an initial state (i.e, not as a move result). No two players can occupy the same cell.
Consume a board state, a player number (between 0 and 5), a dice roll (i.e., a number between 2 and 12) or 0 (elected not to roll), and another board state. Confirm that the second board state repesents a valid move for the indicated play with the given dice roll. If the dice roll is 0, then the player must move either through a secret passage or stay in a room to which the player was moved by suggestion (after which the player remains in the room voluntarily).
Submit a collection of tests cases corresponding to both valid and invalid moves. Brownie points will be awarded to the person who produces test cases that are failed by other implementations.
|Last update: Wednesday, March 5th, email@example.com|