Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

****JAVA**** Write a recursive 2D maze solver. The input to the program will be a text file. Your program must read this text file and

****JAVA****

Write a recursive 2D maze solver.

The input to the program will be a text file. Your program must read this text file and then write out the solution (if one exists). By reading the text file I mean using the Java input output methods/classes to read the text file. This means you provide the full path of the text file as a command line parameter to your program. See below for example code for reading in a text file.

For example here is a sample input, the file name of the maze text file will be a command line input to your Java program. Meaning if you were to run your program from the command prompt, you can give it the filename. Please see below on how to get input from the command line into a Java program. This input will be the full path of your text file, for example:

C:\Users\zgorjian\Desktop\MyMaze.txt

This is the parameter in the main() method. Research how this works and how can you specify command line parameters in Eclipse so you don't have to exit the Eclipse environment to test your program.

004,004 0000 0111 0000 1110 003,003 000,003

The first 2 numbers give you the dimensions of the maze. In this case it's a 4x4 maze.

They will always be 3 digit numbers. So a 4 will be represented as 004.

You can create a 2D array of integers.

1 Represents a wall

0 Represents an open spot you can more to.

From any given position the legal moves are up, down, left and right, as long as you're not running into a wall or going off the maze.

The last set of 4 numbers are defined like this:

003,003 is the starting location, again each number will always be 3 digits.

000,003 is the ending location, again each number will always be 3 digits.

So your program should start at location 3,3 marked by S below and find a path to 0,3 marked by E (for End) below.

000E 0111 0000 111S

Output of your program:

Your program can either print the location of each grid from the start to the end position.

OR, it can print the maze with an asterisk "*" where the path is. like this:

***E *111 **** 111S 

Do not hard code your program to work with a certain number of rows and/or columns for the maze. The maze can have rows from 000 to 999 and columns from 000 to 999.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

Proficiency with Microsoft Word, Excel, PowerPoint

Answered: 1 week ago