Write a program that takes a command line parameter

Assignment Help JAVA Programming
Reference no: EM132081369

You need question number 6 answered, but You do know that question #6 referenced #5 so that is why You supplied you with question #5.

5. Perfect maze. Generate a perfect maze like this one

14-by-14 perfect maze 22-by-22 perfect maze

Write a program Maze.java that takes a command line parameter N, and generates a random N-by-N perfect maze.

A maze is perfect if it has exactly one path between every pair of points in the maze, i.e., no inaccessible locations, no cycles, and no open spaces. Here's a nice algorithm to generate such mazes.

Consider an N-by-N grid of cells, each of which initially has a wall between it and its four neighboring cells.

For each cell (x, y), maintain a variable north[x][y] that is true if there is wall separating (x, y) and (x, y + 1). We have analogous variables east[x][y], south[x][y], and west[x][y] for the corresponding walls.

Note that if there is a wall to the north of (x, y) then north[x][y] = south[x][y+1] = true. Construct the maze by knocking down some of the walls as follows:

a. Start at the lower level cell (1, 1).

b. Find a neighbor at random that you haven't yet been to.

c. If you find one, move there, knocking down the wall. If you don't find one, go back to the previous cell.

d. Repeat steps ii. and iii. until you've been to every cell in the grid.

Hint: maintain an (N+2)-by-(N+2) grid of cells to avoid tedious special cases.

6. Getting out of the maze. Given an N-by-N maze (like the one created in the previous exercise), write a program to find a path from the start cell (1, 1) to the finish cell (N, N), if it exists. To find a solution to the maze, run the following algorithm, starting from (1, 1) and stopping if we reach cell (N, N).

explore(x, y)

-------------

- Mark the current cell (x, y) as "visited."

- If no wall to north and unvisited, then explore(x, y+1).

- If no wall to east and unvisited, then explore(x+1, y).

- If no wall to south and unvisited, then explore(x, y-1).

- If no wall to west and unvisited, then explore(x-1, y).

Reference no: EM132081369

Questions Cloud

Shares traded in the public securities market : Make-it Corporation has shares traded in the public securities market. Under the Securities Act of 1933, which one of the following is a security?
Discuss whether the verbal statement : Discuss whether the verbal statement and the writing on the napkin by two different CEO would be considered a valid and enforceable contract.
Create some jobs to control show the multi - tasking : Create some jobs - Type "cat" command in the terminal , and press ctrl - c to terminate it. Type "jobs" command and you will see nothing.
Discuss whether either a verbal statement or the writing : Discuss whether either a verbal statement or the writing on the napkin would fall under the Uniform Commercial Code (U.C.C.). Why or why not?
Write a program that takes a command line parameter : Write a program Maze.java that takes a command line parameter N, and generates a random N-by-N perfect maze.
Create a new project folder that will contain the helper : Create a new Project folder that will contain the 3 Helper classes: the PalindromeHelper, the ReversePoemHelper, and the AdoptAPetHelper.
Create an application which adds assignments : Which Adds, Edits, and Deletes assignments onto a storage medium, with grades per student-per assignment.
Compose a program that writes the coordinates of a random : Compose a program that writes the coordinates of a random point (a, b, c) on the surface of a sphere. To generate such a point, use Marsaglia's method.
Find the name of each trip containing the word pond : How many current reservations does Colonial Adventure Tours have and what is the total number of persons for all reservations?

Reviews

Write a Review

JAVA Programming Questions & Answers

  The fancy new french restaurant la food is very popular for

the fancy new french restaurant la food is very popular for its authentic cuisine and high prices. this restaurant does

  Unique index integer fields

Unique index integer fields Use at least 5 other fields of various, including at least one of each of String, int and double types. assume that the String's have no spaces within them

  Write a java program that uses the elapsed time

Write a Java program that uses the elapsed time for an event in second and then outputs the elapsed time in hours, minutes and seconds. (For example, if the desired time is 9630 seconds, then the output is 2: 40: 30)

  Identify how you can encapsulate the data

Describe the architectural differences between the object-oriented and structured designs. Which of the designs makes more sense to you? Why?

  Write java program that display a welcoming message

Write a complete Java program with the following specifications: Display a welcoming message such as: "Welcome to Cubing Program!" Prompt the user twice to enter two positive whole numbers, indicating starting and finishing values, first one being s..

  Programming intern at the alumni relations office

Create a Student class representing student records. It will have three data members corresponding to the data contained in the student records file

  Explain role of java developer in implement java application

Explain Role of Java Developer in Implementing Java Web Application. Methodology is a research paper about Action Research and 7-9 pages.

  Create a program that can find prime factors of an integer

Create a standalone Java program that can find the prime factors of an integer. Use the Java BigInteger class rather than an int type or the Integer type to all

  Write a program that accepts a distance in kilometers

Write a program that accepts a distance in kilometers, sends it to a method which converts it to miles, and then displays the result.

  Create exception classes

First, create three exception classes named NumberHighException, NumberLowException, and NumberNegativeException. Both NumberHighException and NumberLowException should be directly subclassed from the Exception class, but NumberNegativeException s..

  Provide the class declaration for three of the classes

MN404 Fundamentals of Operating Systems and Java Programming Assessment. Provide the class declaration for three of the classes

  Build a simple text-based adventure game

Build a simple text-based adventure game. You can and probably should use our Missed Connections example as the foundation for your game.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd