These are the instructions for your second programming project. Recall that all code must be written individually and independently. The assignment is designed to make use of the material recently taught in the course.
This program will allow two players to play a game called Connect-Four. The game of Connect-Four is an elaboration of tic-tac-toe. Two players take turns placing single x's and o's on a seven by seven grid. A player wins by aligning four of that player's character in a vertical, horizontal, or diagonal line. Play is constrained by the rule that each player chooses the column in which to place the character, but not the row. The character automatically descends to the lowest unoccupied position in the column.
Your program should begin by printing a brief explanation, and a seven by seven grid of l's, to indicate an empty grid. Then invite player x to choose a column by entering a number between 1 and 7. Display the grid with the x in the appropriate location. Prompt player o for a column. Display the new grid. Continue until there is a winner or the grid is full. In the event that there is a winner, your program should display the grid with all rows of four in upper case. If the grid is full and there is no winner, declare a tie game. After every game, your program should invite the user(s) to play again, and give them the option of stopping.
Give some thought to user-friendly design. For example, should the explanation be displayed at the start of every game? What should the program do if the user selects an invalid column? Should the user be allowed to stop a game part way through?
Instructions for submitting:
Your program should start with a few lines of
comments giving your name, the date, the course this is for, and the assignment
number. The program should be written with a well organized structure, and the
variables should be named in a useful way. The program should be formatted
consistently and clearly, and should include comments that explain the code.
When you're done writing and testing the program, print out a copy of your
source code. Bring it to
class on the due date and turn it in at the beginning of class.
Also, before the beginning of class on the due date, mail your source
code (your ".cpp" file) to comp1672@cs.du.edu. Do not include it as part
of the message, instead make it an attachment to the email.
If you're in need of further challenge:
Write a program for a single player to play against the computer.
This is not an easy problem.
You'll need to think hard about how to design an algorithm that will choose
the best next move. There are many solutions to this, and you could
compare their
effectiveness by having the different programs play each other.