Question: 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
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 rows, number of columns. Neither the number of rows nor the number of columns 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. Example command to start a two-player game with 7 rows and 6 columns, 2 suggests two player: ./connect_four 2 7 6 Two-Player Operation This is a 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 player's 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). 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. You may also download the .cpp file contains the following code: assignment4_template 2 for (int i=0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
