Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help in implementing the void EdgeDetect and the void Menu functions within my C++ code below. So that, the output could turn out to

Need help in implementing the void EdgeDetect and the void Menu functions within my C++ code below. So that, the output could turn out to be the following sample output below. I have included my code (given code of main.cpp), and three supporting text files.

Sample Output:

image text in transcribed

image text in transcribed

My code (main.cpp);

#include  #include  // For time() #include  // For srand() and rand() #include  // std::flush #include  #include  #include  using namespace std; //generates random numbers 0 or 1 int coinToss() { return rand() % 2; } //generates random coordinates for the grid int randCoord(int ceiling, int floor) { return floor + rand() % (( ceiling + 1 ) - floor); } //initializes the grid 2D array void GridInit(char grid[25][25]) { for(int i=0; i fabs(h_distance)) { if(v_distance>0) //if distance is positive, move up return 'w'; else return 's'; //otherwise move down } else { if(h_distance>0) return 'a'; else return 'd'; } } //checks if coordinates are invalid or not bool InvalidPos(int x, int y){ if(x ==-1 || y ==-1) return true; else return false; } //checks if capture occurs //If rabbit is on an square next to the fox, or they are in the same square, capture happens bool Capture(int x, int y, char grid[25][25]){ if(grid[x][y] == 'X' || grid[x+1][y] == 'X' || grid[x-1][y] == 'X' || grid[x][y+1] == 'X' || grid[x][y-1] == 'X') return true; else return false; } void UpdateGrid(int rabbitsX[],int rabbitsY[], int foxesX[], int foxesY[], char grid[25][25], int &score, int numRabbits, int numFoxes) { //reset graphics for foxes for(int j=0; j>rabbitsX[i]; myfile>>rabbitsY[i]; } myfile.close(); } else cout>foxesX[i]; myfile>>foxesY[i]; } myfile.close(); } else cout  

foxes.txt:

9 9 10 10 11 11 12 12 13 13

rabbits.txt:

3 4 14 3 23 24 15 7 7 15 19 20 5 6 15 3 9 10 10 19 14 15 5 6 18 19 5 19 6 3 

leaderboard.txt:

Stationary Rabbits Chase Fox Movement 15 
Main Menu Launch Import Positions from file Random Positions Stationary Rabbits Random Fox Movement Chase Fox Movement ---------------- -------------- Stationary Pieces : 1 Random Fox Movement:1 Random Positions Enter Action: Random Positions File Positions 0 0 Score:5 Turns:9 bcore:1 Turns:0 Main Menu Launch Import Positions from file Random Positions Stationary Rabbits Random Fox Movement Chase Fox Movement ---------------- -------------- Stationary Pieces : 1 Random Fox Movement:1 Random Positions Enter Action: Random Positions File Positions 0 0 Score:5 Turns:9 bcore:1 Turns:0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions