Comp 401 Assignment 1:
Connect Four

Plan due 2:00PM, Friday February 7, implementation due 11:59PM, Friday February 14

Handy References

This is an individual assignment. You may discuss high-level concepts with other students but all submitted materials should be your own. Please keep the Academic Integrity Policy in mind---do not show your code to anyone outside of the professors and do not look at anyone else's code for this lab.

The main goal of this lab is to gain practice top-down design while implementing a game of Connect Four. First, you should make a plan of what the main function should do, assume that each big step is going to be a function call, then recursively make your plans for each functions until you get to functions that can be implemented without any big steps.

Remember that each function should be kept short, and all the 'thinking' in each function should be on the same level. Do not hesitate to push some of the work down into calls to other functions. Read the list of specifications carefully, points will be taken off if you do not respect all directives.

Problem

You need to implement a game of Connect Four. When run, program should play one game of Connect Four, and at the end of each game, ask the user(s) if they want to play another game. The user should be able to play the entire game using mouse clicks only.

Interface

Once per turn, the game invite the player to select one of the column in which to insert their token. The graphic of the game should make it clear where the user should click to place their token in the correct column. After placing the token on the board, the game should scan the board to determine if the game is over, and if not, move to the next turn.

At the end of the game, the program should print a message congratulating the victor if someone won, or announce a draw if no one won, then ask the players if they want to play another game.

Specifics

Your code should respect the following rules:

  1. Almost no function should be more than 40 lines long -- really, you should have a good reason for having a function that is longer than 20 lines. If a function is too long, what the function does should be broken into smaller pieces, each of which will be executed by a function. The one exception I will allow is the function that creates and/or displays the board, that one could be a little longer.
  2. Functions should contain at most one loop, unless the function needs to examine every cell on the board; that function can use two nested loops.
  3. No function should contain more than two if statements (remember, if---elif---elif----else is a single if statement).
  4. Before each function, you should write a short comment that describes what the function does, what input parameter it takes and, if necessary, what it returns.

Submission

You should hand in a written plan that describes the steps you will execute in each of your functions at a high level, together with a sketch (tree structure) that shows the dependencies between the functions.

The implementation of the game should be submitted on onCourse before 11:59pm, Monday February 10.