Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

..ooo Verizon 2:19 PM 45% csnS.calstatela.edu CS242 1 Project (Connect 5) Descri

ID: 3677299 • Letter: #

Question

..ooo Verizon 2:19 PM 45% csnS.calstatela.edu CS242 1 Project (Connect 5) Description Implement a Connect 5 game (like tic-tac-toe, but on a larger board with the objective of making 5 in a row horizontally, vertically or diagonally) 1 2 34 5 689 1D Player 1: You have to complete the connect5.cpp to work as described: (You have to implement and use the functions given in the skeleton. If you want you can add more functions, but you cannot ignore/bypass the ones in the prototype) As the program starts the board is drawn and the first player makes a move by entering the letter of the row and the number of the column (they are prompted for each by cin) If the move is valid (valid row and column, and the given cell is empty) the move is made, the board is redrawn and player 2 is prompted for their move, and seo on If an invalid move is given the player is prompted to give a new, valid move The moves (the contents of the cells on the board) are stored in a 2d array. By default the value of all (empty) cells is "(space character) Drawing the board The board doesn't have to look exactly like on the image above, but the rovw letters, column numbers have to show clearly, and it should be clear for someone to tell which cell falls in which row and column by looking at it. If the submitted code has compile errors it will automatically get-80% Individual assignment, if anyone is caught sharing code everyone involved will get a 0 for the assignment. EXTRA CREDIT (+75 pts) After each player move evaluate the board to see if any player won. (Check if either player has 5 in a row horizontally, vertically or diagonally somewhere) If one of the players has 5 in a row change the 5 winning characters on the board to " (asterisk), redraw the board, display which player won and end the program Copyright2012-2015, Chengyu Sun. All rights reserved.

Explanation / Answer

#include #include using namespace std; const int ROWS=7; //These can be changed as you want const int COLUMNS=10; const char BORDER='@'; //Marks the border const char COMPUTER='O'; //Computers piece const char HUMAN='X'; //Humans piece const char SPACE=' '; //Un-occuppied place on the board const char C='C'; //This is returned from the game function if the computer has won const char H='H'; //This is returned from the game function if the human has won const char T='T'; //This is returned from the game function if it's a tie //Declaring all the functions void populate(vector &board); //Populates the board for the first time void displayBoard(const vector &board); //Displays the board. Should use a const ref... int isLegal(int &move, const vector &board); //Checks if a move is legal int humanMove(int &move, const vector &board); //Gets the humans move void updateBoard(int &move, char &piece, vector &board); //Updates the board with a move int aiMove(); //Finds the computers move. Find algorithim... char changeTurn(char &piece); //Changes the turn from human to computer or vice-versa char game(const vector &board); //Returns whether the game has been won, drawn or neither void populate(vector &board) { //Populate the borders for (int i=0; i