Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In JAVA language. Thanks! This project asks you to write a program that can: Generate a random two-dimensional square maze whose size is specified by
In JAVA language. Thanks!
This project asks you to write a program that can: Generate a random two-dimensional square maze whose size is specified by the user, and Read in a maze from a given text file (more about this later) Once the program has generated a random maze or read in a maze from a file, the program would solve the maze by finding a path from the startposition to the goal position in the maze. Because of the how the maze is generated (to be discussed next) or specified in the file, there will always be a path from the starting position to the goal position in the maze. The maze structure: The maze is an nxn grid of cells (which we also call rooms), where n is a positive integer specified by the user. Each room in the maze can have at most 4 doors, each of which (if open) can lead to the adjacent room to the north, south, east, or west. There is a passage way between two adjacent rooms if and only if both doors connecting the two adjacent rooms are open. There are two special rooms in the maze called the start room and the goal room. The start room is always the upper-left room in the maze and the goal room is always the bottom-right room in the maze. The start room has its door leading to the north always open while the goal room has its door leading to the south always open. Rooms on the boundary of the maze (except the start and goal rooms) have their doors leading out of the maze always close. As an example, the following figure shows a randomly generated 5 x 5 maze rendered in ASCII characters where each horizontal or vertical line character denotes closed door(s). I I I I I I I I I Maze generation: To randomly generate an nxn maze, we use the algorithm below. The algorithm assumes that the rooms are uniquely numbered from left to right, top to bottom. The numbering of rooms starts from 0 and ends with N-1, where N is the total number of rooms in the maze (i.e., N n For the example maze given above, the start room is numbered 0 while the goal room is numbered 24Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started