subject

You are required to design a class for the grid and submit exactly three files: . . maze. h: class declaration maze. cpp : implementation of all methods defined in maze. h main. cpp: driver program that takes CLAs and uses the class Maze to generate output Your program will be compiled with the following line: $ g++ -std=c++11 -Wall main. cpp maze. cpp -o generator A common approach for maze generation involves removing interior walls iteratively. At each iteration a wall is removed to connect two adjacent cells. This iterative process must follow these rules: ⢠walls to be removed should be selected randomly. Use std:: rand() to generate random numbers and std::srand() to provide a seed to the random number generator ⢠there should be exactly one path connecting the starting and ending cells ⢠every cell must be reachable from the starting cell The algorithm below should be followed in your implementation. This is not the most efficient way to solve the problem of maze generation, however it is easy to understand and can be implemented with the support of simple data structures such as dynamic arrays ( std::vector in C++ ). The algorithm below should be followed in your implementation. This is not the most efficient way to solve the problem of maze generation, however it is easy to understand and can be implemented with the support of simple data structures such as dynamic arrays ( std::vector in C++ ). We strongly suggest you to trace this algorithm on paper using a small example (e. g. a 4 x 4 grid) until you fully understand how it works, before starting to code. create empty dynamic array A mark cell [0,0] as visited insert cell [0,0] at the end of 'A while 'A' is not empty 'current <- remove last element from A neighbors < current 's neighbors not visited yet if `neighbors is not empty insert current at the end of 'A 'neigh <- pick a random neighbor from `neighbors remove the wall between current' and 'neigh mark "neigh as visited insert "neigh' at the end of 'A endif endwhile In order to match the autograder tests, picking a random neighbor must follow this procedure: "check the neighbors of a cell in N-S-E-W order and append the ones that were not visited yet into an empty vector neighbors , then use the index idx below to pick a random neighbor with neighbors[idx] " idx = std::rand() / ((RAND_MAX + lu) / neighbors. size()); Your Task Your goal in this assignment is to develop a command line tool that will generate a random maze, given some options provided by the user. Command Line Arguments Your program must accept the following command line arguments: the seed value for the random number generator number of rows in the grid N > 0 number of cols in the grid M > 0 file name for the output The seed argument is very important as it initializes the random number generator. If you change the seed, you will generate a different maze. In your code make sure you call this function exactly once before generating the maze: std::srand(seed); The last argument will be used to save the generated maze into a text file. Note that you can provide any value as fname . See the example below: $ ./generator 10 10 example. txt Maze file format The file format for saving the maze is just a two dimensional array of integers, where each integer is used to represent a cell and its walls. Each integer in the matrix ranges from 0 to 16. The idea behind this representation is that the walls are encoded using 4 bits, and the ingeters are just their corresponding values in decimal notation. The figure below illustrates the encoding: N E N SE W ) 1 1 1 BITSTRING = 15 s Decinal walls 0111 = á U OD 3 = 1001 E9

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:30
You have a large, late-model pick-up truck with a rear seat. the pick-up truck weighs 6,500 pounds. the florida seat belt law
Answers: 1
question
Computers and Technology, 22.06.2019 12:00
The following function returns a string of length n whose characters are all 'x'. give the order of growth (as a function of n) of the running time. recall that concatenating two strings in java takes time proportional to the sum of their lengths. public static string f(int n) { if (n == 0) return ""; if (n == 1) return "x"; return f(n/2) + f(n - n/2); } options: a) constant b) logarithmic c) linear d) linearithmic e)quadratic f)cubic g) exponential
Answers: 2
question
Computers and Technology, 23.06.2019 04:31
Acloud service provider uses the internet to deliver a computing environment for developing, running, and managing software applications. which cloud service model does the provider offer? a. iaas b. caas c. maas d. paas e. saas
Answers: 1
question
Computers and Technology, 23.06.2019 09:00
Which best compares appointments and events in outlook 2010appointments have a subject man, and events do notappointments have a specific date or range of dates, and events do notappointments have a start and end time of day, and events do notappointments have a location option, and events do not
Answers: 2
You know the right answer?
You are required to design a class for the grid and submit exactly three files: . . maze. h: class d...
Questions
question
Mathematics, 07.12.2021 18:10
question
English, 07.12.2021 18:10
question
Physics, 07.12.2021 18:20
question
Mathematics, 07.12.2021 18:20
question
Social Studies, 07.12.2021 18:20
question
Mathematics, 07.12.2021 18:20
question
Mathematics, 07.12.2021 18:20