The deadline for this lab is Wednesday 09 November 2005, 17:45 hours. Strictly no submissions will be accepted after the deadline.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
We use '.' (full-stop) to represent an empty slot.
The columns are numbered from 0 to 7, with 0 being the leftmost column.
White moves first, and suppose he places his disc at column 2. The white disc will drop all the way to the bottom, as shown below:
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . W . . . . .
We use 'W' to represent a white disc, and 'B' to represent a black disc.
Now it is Black's turn, and suppose he places his disc at column 3. The black disc will drop all the way to the bottom, as shown below:
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . W B . . . .
Suppose the board position is now as shown below:
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . W . . . . . . W B . . . .
If Black places his disc at column 3, it will land on the white disc, as shown below:
. . . . . . . . . . . . . . . . . . . . . . . . . . . B . . . . . . . W . . . . . . W B . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B B B . . . . . W W W W . . . .
In the above example, white wins, and the coordinates of the winning line are from (5,0) to (5,3), or (5,3) to (5,0). Note that (0,0) is the top left-hand corner, and (5,0) is the bottom left-hand corner.
. . . . . . . . . . . . . . . . . . B . . . . . . . B . W . . . . . B . W . . . . . B . W . W .
In the above example, black wins, and the coordinates of the winning line are from (2,2) to (5,2). Note that the winning line is also from (5,2) to (2,2); the order does not matter.
. . . . . . . . . . . . . . . . . . . W . . . . W B W B . . . . B W B W . . . . W B W B . . . .
In the above example, white wins, and the coordinates of the winning line are from (5,0) to (2,3). Note that the winning line is also from (2,3) to (5,0); the order does not matter.
2 3 0 1 1 2 3 0 2 3 0 1 3 0 1 2
This says that White first places his disc at column 2, then Black places his disc at column 3, then White places his disc at column 0, then Black places his disc at column 1, and so on.
You may assume that the column number is always from 0 to 7 inclusive, and that players will never place a disk on a column that is already full. No error checking is required.
Your program must keep reading player's moves, and terminate immediately whenever a player wins, even though there may be further moves stored in the text file. If no one wins after reading all the moves from the text file, it is a draw. Before termination, display the final state of the board, and print out the result: White wins, Black wins, or Draw result.
When a player wins, display also the coordinates of the starting and ending point of the winning line. The starting and ending point can be in any order. If the winning line contains more than four discs, the starting and ending points must contain exactly four discs. If there are multiple winning lines for a single colour, display any one of the winning lines.
. . . . . . . . . . . . . . . . . . . W . . . . W B W B . . . . B W B W . . . . W B W B . . . . White wins: (5,0) to (2,3)You are reminded to follow the sample output exactly; else marks will be deducted.
Remember to submit your program using the submit connect.c command, and check your submission using the check command.
All the best!