Question

Write a program that will randomly generate a square maze that has a side-dimension between 10 to...

Write a program that will randomly generate a square maze that has a

side-dimension between 10 to 100 cells based on a set of attributes from the

user, and then it will solve the maze problem. The maze cells are either free

(0) or have obstacles (1). Daedalus can move over the free cells but not the

cells with obstacles. The user of the program is asked to enter two attributes

for generating the maze:

1. Side-dimension of the square maze

2. The percent free cells in the maze.

*** NO STL LIBRARY*****
**** PLEASE INCLUDE / DISTINGUISH BETWEEN .h file and .cpp file *****

0 0
Add a comment Improve this question Transcribed image text
Answer #1

choose a point at random out in the unsolved territory and begin a random walk: when you reach the solved territory (the maze as it is already known), add those points back to the maze; when you self-intersect you should delete the random walk back to where you self-intersected. (For the very first walk, furthermore, there is only one "solved" point in the maze so you may wish to speed up maze generation by doing a different random walk that just "busts down walls" into the as-yet-unknown area; this is called Aldous-Broder and it has the opposite problem where it tries to randomly walk into unsolved space so it takes forever when the unsolved space becomes rare.) So one would start from Now, the algorithm might get a bit weird because it looks like you are using block mazes rather than conventional thin-walled mazes; every n-by-m thin-walled maze has an embedding as a block maze of size (2n+1)-by-(2m+1) simply by making (0, y) and (x, 0) all walls, every (odd, odd) point is empty space representing one of the squares of the original maze, every (even, even) point is a block, and (odd, even) and (even, odd) points are blocks if and only if there is a vertical/horizontal wall between the corresponding squares in the original maze.

following is the given the program .

 function* randomWalkPoints({ x, y }, height, width) {
      const incr = [{dx: -1, dy: 0}, {dx: 1, dy: 0}, {dx: 0, dy: -1}, {dx: 0, dy: 1}];
      while (true) {
        const { dx, dy } = incr[Math.floor(4 * Math.random())];
        const new_x = x + dx, new_y = y + dy;
        if (new_x >= 0 && new_x < width && new_y >= 0 && new_y < width) {
          x = new_x;
          y = new_y;
          yield { x, y };
        }
      }
    }

DISTINGUISH BETWEEN .h FILE AND .cpp FILE

The convention is that .h files are declarations, and .cpp files are definitions. That's why .h files are #included -- we include the declarations. The .cpp file is the compilation unit : it's the real source code file that will be compiled (in C++)..

Add a comment
Know the answer?
Add Answer to:
Write a program that will randomly generate a square maze that has a side-dimension between 10 to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • using c++ (NO STL libraries) create a program that will ask the user to enter two...

    using c++ (NO STL libraries) create a program that will ask the user to enter two values (percent of free squares in the maze and the side dimensions of the maze) that will build a maze according to what the user enters. Along with asking the user these questions also ask the user the location they want to place the character inside the maze as well as the exit of the maze. In the maze free cells are blank. cells...

  • Write a program to compute the area of a triangle using side-angle-side method and reports the...

    Write a program to compute the area of a triangle using side-angle-side method and reports the area of that triangle (rounded to 2 decimal places). Side-angle-side formula: ???? = 1/ 2 ?? sin(?), where a and b are two sides of the triangle, and C is the included angle. Your program must meet the following criteria to receive full marks: • Randomly generate two values between 5 and 10 (inclusive) for two sides a and b of the triangle, respectively....

  • Maze Solving with Stacks Problem Statement Consider a maze made up of rectangular array of squares,...

    Maze Solving with Stacks Problem Statement Consider a maze made up of rectangular array of squares, such as the following one: X X X X X X X X X X X X X           X            X X X X    X X X           X               X     X X X     X X    X    X     X     X X X         X          X             X X X     X X X X X                X X X X X X X X X X X X X Figure...

  • using C++ Requirements: . Classes you must create o Monster must be an abstract class Each monster has . an attack) o randomly generate a number between 0 and strength for each attack (Strength 10 wo...

    using C++ Requirements: . Classes you must create o Monster must be an abstract class Each monster has . an attack) o randomly generate a number between 0 and strength for each attack (Strength 10 would generate 0-10) add up all the damage done return total damage o o e a number of attacks . a number for strength used during attacking . a string representing the type » accessor for type o Goblin inherits from Monster type is "Goblin"...

  • Objective: Write a program that implements the Game of Life cellular automata system invented by John...

    Objective: Write a program that implements the Game of Life cellular automata system invented by John Conway. 1. Create two game grids of size at least 50x50. These grid cells can be either Boolean or integer. In the following, I’ll refer to these as gridOne and gridTwo. 2. Set all cells in both grids to false. 3. Start by initializing gridOne. Allow the user to specify two different ways of initializing the grid: 1) by specifying a pattern file to...

  • For this c++ assignment, Overview write a program that will process two sets of numeric information....

    For this c++ assignment, Overview write a program that will process two sets of numeric information. The information will be needed for later processing, so it will be stored in two arrays that will be displayed, sorted, and displayed (again). One set of numeric information will be read from a file while the other will be randomly generated. The arrays that will be used in the assignment should be declared to hold a maximum of 50 double or float elements....

  • Specification Write a program that allows the user to play number guessing games. Playing a Guessing...

    Specification Write a program that allows the user to play number guessing games. Playing a Guessing Game Use rand() function from the Standard C Library to generate a random number between 1 and 100 (inclusive). Prompt the user to enter a guess. Loop until the user guesses the random number or enters a sentinel value (-1) to give up. Print an error message if the user enters a number that is not between 1 and 100. Print an error message...

  • Write a simulation of zombies/walkers that move randomly in one dimension. Each walker begins at the...

    Write a simulation of zombies/walkers that move randomly in one dimension. Each walker begins at the origin and at each time-step it takes a step to the right or left with equal probability, so that Pright= 0.5, Pleft= 0.5. Use a lattice of spacing x =1 and discrete time-steps, t= 1. Number of steps in each walk: 20 Number of walkers: 10.000 Please make your own algorithm for this simulation. Note: You will need to use a random number generator....

  • Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that...

    Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that will process monthly sales data for a small company. The data will be used to calculate total sales for each month in a year. The monthly sales totals will be needed for later processing, so it will be stored in an array. Basic Logic for main() Note: all of the functions mentioned in this logic are described below. Declare an array of 12 float/doubles...

  • Needs Help with Java programming language For this assignment, you need to write a simulation program...

    Needs Help with Java programming language For this assignment, you need to write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: • delete the addfirst, addlast, and add(index) methods and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT