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 16:00
If a client wants to make minor edits, what should he/she use?
Answers: 3
question
Computers and Technology, 23.06.2019 01:10
Are special combinations of keys that tell a computer to perform a command. keypads multi-keys combinations shortcuts
Answers: 1
question
Computers and Technology, 23.06.2019 11:30
The most accurate readings that you can take on an analog vom are when the meter's pointer is at the a. center scale. b. extreme right. c. near right. d. extreme left.
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Jake really works well with numbers and is skilled with computers but doesn't work well with others. which of the jobs discussed in this unit might be best for jake? why?
Answers: 3
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, 05.03.2021 18:10
question
Mathematics, 05.03.2021 18:10
question
English, 05.03.2021 18:10
question
Mathematics, 05.03.2021 18:10
Questions on the website: 13722363