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, 21.06.2019 20:50
What does operator overloading allow you to do?
Answers: 2
question
Computers and Technology, 21.06.2019 21:30
What elements related to the release and success of the nes console do you see in modern console releases? what elements are no longer relevant to modern console gaming?
Answers: 3
question
Computers and Technology, 22.06.2019 15:00
I'm taking a class on how to make a movie, and it offers some apps that would be in the process. the thing is, i don't have any of those ha. if you have any tips on some apps i could use, that would be awesome. i don't have an iphone, so don't suggest any apps like imovie. i know that this is a weird question, but it would be super for me. : )
Answers: 2
question
Computers and Technology, 23.06.2019 06:30
How do you write an argumentative essay about the importance of free enterprise ?
Answers: 1
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, 18.08.2021 14:00
question
Mathematics, 18.08.2021 14:00
question
Mathematics, 18.08.2021 14:00
question
Mathematics, 18.08.2021 14:00
question
Mathematics, 18.08.2021 14:00
question
Mathematics, 18.08.2021 14:00
Questions on the website: 13722363