DPA 4010 / 6010

Spring 2016

Connect 4 Game

Homework Assignment 2

Due: Midnight, Wednesday, February 10


Now that you have designed a program to draw the Connect 4 game, it is time to play the game. Please modify your program to allow the user to select the next move with a mouse click on a column. Your program should verify that the move is a legal move, and refuse any illegal moves. If the selected move is legal, place the new piece in the column in the correct slot. For information about how Connect 4 is played, click here.

Nice user interface features would be some visual feedback that a column has been selected, and some indication that an incorrect move was rejected. Turns should alternate, so that after a move of one color, the next move must be of the opposite color. You can pick one of the colors to always make the first move.

The program should recognize when a player has won, and also when no more moves are possible.

Your program should draw the game, and should respond to callbacks to service the mouse button and to automatically redraw the window if the display is covered and then uncovered. The program should not quit until either the 'q' or 'esc' key is pressed on the keyboard.


Advanced Extension: Include the option to have the computer play against a human. The computer should always go second, and should always make a "good" move.

Please submit your program using the standard handin procedure. You should include your program source code and a Makefile.