Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 15th, 2006, 03:22 PM
nineball_ssj9 nineball_ssj9 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 1 nineball_ssj9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 32 sec
Reputation Power: 0
Send a message via MSN to nineball_ssj9 Send a message via Yahoo to nineball_ssj9
I need help with the Maze Driver that walks through a maze recursively

I need to navigate through a maze recursively giving a start and end point using row and column.

public class mazeDriver
{
public static void main(String[] args)
{
Maze maze = new Maze(4,6);
maze.traverse(0,1);
}
}
The values "4,6" (passed to the Maze constructor) represents the end point, which must correspond with the value one in the matrix. Similarly, the starting point, row/col (0,1) in this example, must also contain a one in the matrix. Note that the values "0,1" are parameters to the traverse routine, which is recursively called until a solution, in other words the exit, is found.

The Maze class should configured in the following manner:
public class Maze
{
. . .
. . .
public void traverse(. . .)
{
. . .
. . .
}
private int[][] theMaze = { {0, 1, 0, 0, 0, 0, 0},
{0, 1, 0, 1, 1, 0, 0},
{0, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 1},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0} };
. . .
. . .
}

ok the maze driver should look like this

The following is a sample run, starting with the maze depicted above:
% java mazeDriver
0 1 0 0 0 0 0
0 1 0 1 1 0 0
0 1 1 1 0 0 0
0 0 0 1 0 0 0
0 1 1 1 1 1 1
0 0 0 0 0 0 0
0 0 0 0 0 0 0

and when the solution is found it shoud look like this

0 7 0 0 0 0 0
0 7 0 1 1 0 0
0 7 7 7 0 0 0
0 0 0 7 0 0 0
0 3 3 7 7 7 7
0 0 0 0 0 0 0
0 0 0 0 0 0 0

The first matrix, containing just ones and zeros, is simply a print out of the original maze that is stored in the Maze class. The resulting matrix contains zeros, ones, threes, and sevens, representing how the program traversed the maze.
The sevens, which replace ones, depict the path that the program traversed. The threes, which also replace ones, represent dead ends that the program "walked" and then turned around. The remaining ones are paths that the program did not travel on, and the zeros represent walls, that never change.
Special Notes:
- Although the maze depicted has the same number of rows and columns, your code should be able to handle any number of rows and columns above two, in each dimension, and work for any valid configuration, that is traversable through the maze.
- The solution must be recursive in nature, i.e., use recursion.
- The exit location is passed to the Maze constructor, and the start location
is passed to the traverse method.
- When debugging the program use simple mazes first, such as a straight path from the start to the finish. Next enhance the
maze, and run your program again, until any valid maze is supported.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > I need help with the Maze Driver that walks through a maze recursively


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway