AceWindgar1285's Profile
Reputation: 0
Apprentice
- Group:
- Members
- Active Posts:
- 20 (0.09 per day)
- Joined:
- 12-October 12
- Profile Views:
- 65
- Last Active:
May 03 2013 06:36 AM- Currently:
- Offline
Previous Fields
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: My problem is that the solution to the map is not marked right
Posted 9 Dec 2012
Sorry forgot to place it back in the program.
/** * @author Chris * */ public class Maze { // Class Variables final static char BLANK = ' '; final static char WALL = 'X'; final static char BACK = 'B'; final static char PATH = '-'; static char[][] map=null; Maze(String [] n) { map= new char[n.length][]; for(int i =0;i<n.length;i++){ map[i] = n[i].toCharArray(); } } public boolean findSolution(int row, int col) { boolean done = false; if (valid (row, col)) { map[row][col] = BACK; // this cell has been tried if (row == map.length-1 && col == map[0].length-1) done = true; // the maze is solved else { done = findSolution (row, col+1); // down if (!done) done = findSolution (row-1, col); // right if (!done) done = findSolution (row, col-1); // up if (!done) done = findSolution (row+1, col); // left } if (done) // this location is part of the final path map[row][col] = PATH; } return done; } private boolean valid (int row, int column) { boolean result = false; // check if cell is in the bounds of the matrix if (row >= 0 && row < map.length && column >= 0 && column < map[row].length) // check if cell is not blocked and not previously tried if (map[row][column] == BLANK) result = true; return result; } public boolean solution() { return findSolution(4,0); } public void displayMaze() { final char[ ][ ] maze = map; for(int i = 0; i < maze.length; i++){ for(int j = 0; j < maze.length; j++) System.out.print("|"+maze[i][j]); System.out.println("|"); } } } -
In Topic: having a java.lang.ArrayIndexOutOfBoundsException-1
Posted 7 Dec 2012
iactually figured out what i was doing wrong i was having it start at the wrong point. But now i can't get it to backtrack. -
In Topic: having a java.lang.ArrayIndexOutOfBoundsException-1
Posted 7 Dec 2012
is it possible to see a sample of what you would perfer me to do just a small sample to put me in the right direction? -
In Topic: having a java.lang.ArrayIndexOutOfBoundsException-1
Posted 7 Dec 2012
so what should do to fix my issue? -
In Topic: Random Number Generation
Posted 25 Nov 2012
thank you every one for the help i truly am in your debt
My Information
- Member Title:
- New D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
Contact Information
- E-mail:
- Private
Friends
AceWindgar1285 hasn't added any friends yet.
|
|


Find Topics
Find Posts
View Reputation Given
|
Comments
AceWindgar1285 has no profile comments yet. Why not say hello?