Computers and Technology

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

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 15:00, gmc2771
Hyperactive media sales has 10 windows 7 laptop computers used by sales-people in the organization. each laptop computer has several customized applications that are used during the sales process as well as customer relationship management software. all of the applications on the laptops are difficult to configure and have large data files. if all of the laptops have current hardware, what is the easiest way to install windows 10 on them?
Answers: 1
image
Computers and Technology, 23.06.2019 06:40, euniceyi56
How many nibbles can be stored in a 16-bit word?
Answers: 1
image
Computers and Technology, 23.06.2019 07:00, lin550
Why were most movies from the late 1890s until the early 1930s only filmed in black and white? there were only a few people who could afford the technology to produce color motion pictures back then. audiences did not want color motion pictures until later. the film used to make color motion pictures often overheated, which was a safety hazard, so it was generally not allowed. color films had to be hand-colored, frame by frame.
Answers: 3
image
Computers and Technology, 23.06.2019 07:10, anika420
If you want to import a picture into a dtp application, what must you do first? draw an image frame. import text. open the folder containing the file. select get image… from the windows menu.
Answers: 2
Do you know the correct answer?
You are required to design a class for the grid and submit exactly three files: . . maze. h: class d...

Questions in other subjects:

Konu
Mathematics, 31.08.2021 08:50
Konu
History, 31.08.2021 08:50
Konu
Social Studies, 31.08.2021 08:50
Konu
Physics, 31.08.2021 08:50