Assignment 5 Connect Four
Design Due: Sunday, 12/1/19, 11:59pm on Canvas Peer Review 5 Due: Friday, 12/6/19, 11:59pm on Canvas Code Due: Sunday, 12/8/19, 11:59pm on TEACH
Make sure you demo Assignment 4 within two weeks of the due date to receive full credit. If you go outside the two-week limit without permission, you will lose 50 points. If you fail to show up for your demo without informing anyone, then you will automatically lose 10 points.
Introduction
This particular program implements a game that is played in real life. For this assignment you should try to make your program look as nice as possible using the provided code fragment.
This assignment will not be demoed. TAs will grade on their own during finals week!!!
Problem statement:
Write a C++ program that plays the game of Connect Four. The game is simple and you can view the instructions online here.
You can also find online implementations if you want to see the game in action. One specific online implementation is at: https://www.mathsisfun.com/games/connect4.html.
Your game will allow 1-2 players, and at the end, you need to ask if the user(s) want to play again. In this program, we are going to use Xs and Os to represent pieces for different players. Those pieces are inserted into a board and the first player to get 4 adjacent pieces (horizontally, vertically, or diagonally) wins.
Game Set up
Command line arguments will be used to indicate the number of players as well as the size of the board. The three command line arguments will be provided in the following order: number of players, number of columns, number of rows. Neither the number of columns nor the number of rows can be over 20!!! A two-player game implies that two humans will be present and the program will allow each player to take turns. A one-player game implies that the human is playing against the computer (see One-Player Operation for more details).
Example command to start a two-player game with 7 columns and 6 rows:
./connect_four 2 7 6
If you want to start a one player game on a 9 x 7 grid, you would use the following command:
./connect_four 1 9 7
Two-Player Operation
In two-player mode, your code will first display the empty board (with each column numbered across the top). It will then prompt the first player to select a column. After a column is selected, the screen will display the updated board with the players piece at the bottom of the selected column. Player two can then choose a column in which to drop their piece. This behavior continues (alternating between players) until a winner is determined or until no more pieces can be dropped into the board (resulting in a tie).
One-Player Operation
In one-player mode, the human will play against the computer. Your code will first ask the human if they want to have the first move. If so, the human gets to drop the first piece. If not, the computer gets to drop the first piece. In order to make this programming assignment easier, the computer player does not have to be intelligent. For each computer move, the program will randomly select a column and drop the piece. Naturally, the computer player can only drop a piece into columns that have at least one empty space remaining. As with the two-player operation, game play will alternate between each player.
Implementation Requirements
In addition to the earlier specifications, your program must meet these requirements:
You must use a dynamic 2-dimensional array to represent the board
Establish the size of the board via command line arguments, must include error handling for too
many and too few arguments as well as incorrect input (negative number, floating point number, text string, etc). If an invalid value is provided, then the program should display a message to indicate the problem, and recover by asking for these values during runtime.
The board must be correctly colored black and white using the following code as a base. It also needs to display the column numbers across the top. The following code fragment colors a two- dimensional board. It is expected that you will adjust it as needed to provide the best user interface possible for your program.
for (int i=0; i