Question: Below here is the code: #include #include using namespace std; //check data structures to see if position is occupied by peg or not string checkRow(int

 Below here is the code: #include #include using namespace std; //check

Below here is the code:

#include #include

using namespace std;

//check data structures to see if position is occupied by peg or not string checkRow(int row, int pos, bool row0[], bool row1[], bool row2[], bool row3[], bool row4[], bool row5[], bool row6[]) { if(row == 0) if(row0[pos]) return "o"; else return " "; if(row == 1) if(row1[pos]) return "o"; else return " "; if(row == 2) if(row2[pos]) return "o"; else return " "; if(row == 3) if(row3[pos]) return "o"; else return " "; if(row == 4) if(row4[pos]) return "o"; else return " "; if(row == 5) if(row5[pos]) return "o"; else return " "; if(row == 6) if(row6[pos]) return "o"; else return " "; } //print board void printBoard(bool row0[], bool row1[], bool row2[], bool row3[], bool row4[], bool row5[], bool row6[]) { cout = 0 && row = 0 && column = 0 && column = 0 && column = 0 && column = 0 && column = 0 && column

//move peg if(tempRow2 == 0 && !row0[tempColumn2]) row0[tempColumn2] = true; if(tempRow2 == 1 && !row1[tempColumn2]) row1[tempColumn2] = true; if(tempRow2 == 2 && !row2[tempColumn2]) row2[tempColumn2] = true; if(tempRow2 == 3 && !row3[tempColumn2]) row3[tempColumn2] = true; if(tempRow2 == 4 && !row4[tempColumn2]) row4[tempColumn2] = true; if(tempRow2 == 5 && !row5[tempColumn2]) row5[tempColumn2] = true; if(tempRow2 == 6 && !row6[tempColumn2]) row6[tempColumn2] = true; }

void playGame(bool row0[], bool row1[], bool row2[], bool row3[], bool row4[], bool row5[], bool row6[]) {//Determine Players moves and if valid move is made reflect on board //* initialize player data //** read player moves //* check if player move is valid //* update board

}

int main() { //initialize data structures bool row0[7] = {true,true,true,true,true,true,true}; bool row1[6] = {true,true,true,true,true,true}; bool row2[5] = {true,true,true,true,true}; bool row3[4] = {true,true,true,true}; bool row4[3] = {true,true,true}; bool row5[2] = {true,true}; bool row6[1] = {true};

printBoard(row0, row1, row2, row3, row4, row5, row6); playGame(row0, row1, row2, row3, row4, row5, row6); return 0; }

There are several steps that you will need to implement: First request the user to remove 4 pieces from the board, make sure that the selections are valid. Next, the user should be given a prompt to choose a peg that they would like to move; again, make sure that the selection is valid. Now that you know which piece will be moved, ask the user to select a position that is the result of a valid jump. Be sure to remove the jumped piece! Now repeat the action of jumping with that original piece. Remember that in this version of tricky triangles, to complete your turn, a given peg must jump two pieces. Here is a demonstration of your final game: You need to write the stepwise refinement prior to implementing your game so you can show the project manager what you plan to do. You can use the lecture notes to read more about stepwise refinement General Instructions: You are given a code that compiles with no errors. Functions to update the board are already provided, you will need to update the data structures that correspond to places on the board. You only need to implement the playGame () function using the step-wise refinement approach. Your job is to ask the player for their input, then check that they have made a valid decision and update the board using the given data structures. Task: Your task is to apply the technique of stepwise refinement to design an algorithm for the playGame()function and play the game of modified tricky triangles. Your playGame() function should not break the provided working code, and it should interact with and call other given functions

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!