Your program should let two humans play against each other. A sample executable is in ~schar/cs313/hw4/cfour. The following instructions were taken from the SCS Connect Four website (minus 4 typos :)
Players take turns dropping their colored chips into a 7x6 grid, which pile up at the bottom. To win, a player must connect four of their chips in a row (horizontally, vertically, or diagonally). At the same time, the opponent is trying to connect four of their own chips. You must balance defense (blocking off the opponent's attempts at connecting four) and offense (connecting four of your own) in order to play successfully.My sample program is about as simple as it can get. At the very least, you should try to match what it does (e.g., checking for invalid input, and printing who won (or whether it was a tie), and how many moves it took. There are many ways to make it more interesting:
| O | | O O X | | X X X O X | | # # # # X O | | X X X O O X | | X O O X X O | +---------------------+ 1 2 3 4 5 6 7 Player 1 (O) wins after 27 moves!
{ Pascal }
procedure clear; { clear screen and move cursor to top left corner }
begin
write(chr(27), '[2J', chr(27), '[f');
end;
/* C */
void clear() { /* clear screen and move cursor to top left corner */
printf("%c[2J%c[f", 27, 27);
}
# Python
import sys # at the beginning of your python file
def clear():
"""clear screen and move cursor to top left corner"""
sys.stdout.write("%c[2J%c[f" % (27, 27))