The deadline for this lab is Wednesday 15 November 2006, 09:45:59 hours. Strictly no submissions will be accepted after the deadline.
. b . b . b . b b . b . b . b . . b . b . b . b . . . . . . . . . . . . . . . . r . r . r . r . . r . r . r . r r . r . r . r .
The meanings of the symbols are:
There are two other pieces. Their symbols are:
All pieces can only move one square diagonally. Red Peasants move and capture only upwards, Black Peasants move and capture only downwards. Pieces may not move into a square that is occupied by any other existing piece. Players take turns to move, with Red moving first.
The Red Peasant at (5, 6) can move to either (4, 5) or (4, 7).
Suppose two moves are made:
The board now looks like:
. b . b . b . b b . b . b . b . . b . b . . . b . . . . . . b . . . . . . . . r r . r . r . . . . r . r . r . r r . r . r . r .
. b . b . b . b b . b . b . b . . b . b . r . b . . . . . . . . . . . . . . . . r . r . r . . . . r . r . r . r r . r . r . r .
Now, either of the Black Peasants at (1, 4) or (1, 6) can capture the Red Peasant at (2, 5). Note that pieces are not forced to capture, and each piece can only make one capture per move.
Suppose the lines of the text file contains:
5 6 4 7 2 5 3 6 4 7 2 5
Each move in contained in one line. The first line says move a piece from (5, 6) to (4, 7). The second line says move a piece from (2, 5) to (3, 6). The third line says move a piece from (4, 7) to (2, 5). The third move is actually a capture so the board and statistics must both be updated correctly.
You do not need to do any error checking. You may assume that all the moves and captures are valid and that players take turns to move their pieces.
Assuming the text input file shown above, the following is the correct output of the program. Follow it precisely, else marks may be deducted!
Initial layout: . b . b . b . b b . b . b . b . . b . b . b . b . . . . . . . . . . . . . . . . r . r . r . r . . r . r . r . r r . r . r . r . Final state: . b . b . b . b b . b . b . b . . b . b . r . b . . . . . . . . . . . . . . . . r . r . r . . . . r . r . r . r r . r . r . r . Red peasants captured: 0 Black peasants captured: 1 Red kings captured: 0 Black kings captured: 0
We will test your programs with other (more complicated) text input files.
Do not use any structures in your program, else no credit will be given.
Remember to submit your program using the submit checkers.c command, and check your submission using the check command.
All the best!