DPA 401/601

Spring 2013

C++ Connect 4

Homework Assignment 5

Due: Midnight, Thursday, March 7


Maybe you have had enough of Quadtrees for a while, so lets go back to the Connect 4 game. This week you are to redo the Connect 4 game program, but now using C++. To do this you should create at least three object classes Game, Grid and Piece. The class Game should contain all of the game logic, keeping track of the current player, responding to mouse clicks, determining when the game is done, and reporting the winner. The class Piece should represent a playing piece, and have the ability to keep track of what color it is, and to draw itself. The class Grid should have the ability to determine where a new piece goes in a column, to place the piece in the column, to report what piece is in a slot, and to draw itself. Your callback and other routines should make use of these classes and their methods to implement the Connect 4 basic  game.

You still are required to check for legal moves, and indicate attempted illegal moves. 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 "smart" move. To implement this you should create a Player class, that handles the logic of making a play.

Please submit your program using the standard submit procedure. You should include your all of your source code .cpp and .h files, and a Makefile.