Joined: Sun Aug 21, 2011 9:10 am Posts: 6
|
I added the debugging output, cleaned the class abit, and made a new algorithm... Testing it more but, here is what I have for everyone now. Map class: Code: /* The Map Class, One is given to each Entity. The Map is used to "remember" where that Entity has been
PathFinding will use this. */
import java.util.ArrayList; import java.awt.Point; import java.util.HashSet; import java.util.Set; import java.util.List;
public class Map { private PathPoint[][] blocks; private int xSize; private int ySize; private boolean isDead = false; private ArrayList<ArrayList<Point>> uniquePoints; private int stockD; Map(int xSizes, int ySizes) { //set size then construct! xSize = xSizes; ySize = ySizes; stockD = (xSize*ySize*2); construct(); } private void construct() { //make the blocks then fill it with new cells blocks = new PathPoint[xSize][ySize]; for(int x = 0; x < blocks.length; x++) for(int y = 0; y < blocks[x].length; y++) blocks[x][y] = new PathPoint(new Point(x,y), new Cell(), stockD); //make the uniquePoints uniquePoints = new ArrayList<ArrayList<Point>>(); for(int k = 0; k < 5; k++) { if(k < 2) uniquePoints.add(null);//why would we want walls and floors in this? else uniquePoints.add(new ArrayList<Point>()); } } public void died() { //is the entity in the act of dieing? (because we toke so long makeing the path, it's the only way they die right now!) isDead = true; } public void close() { //closing method, used to keep memory low, System.gc() is called in the caller of this method. //world.hasBecomeDead() > world.eh.isDeadNow() > Entity.close() > item/map.close() //world.hasBecomeDead() calls the garbage collector. //clear blocks for(int x = 0; x < blocks.length; x++) { for(int y = 0; y < blocks[x].length; y++) { blocks[x][y].close(); blocks[x][y] = null; } blocks[x] = null; } //clear uniques for(int k = 0; k < uniquePoints.size(); k++) if(uniquePoints.get(k)!=null) { uniquePoints.get(k).clear(); } uniquePoints.clear(); uniquePoints = null; } private void updateUnique(Cell newC, Cell oldC, Point p) { //if the old one is a unique cell then dump it from the list if(oldC.getCode() > 1) { //find the cell first >.> ArrayList<Point> ps = uniquePoints.get(oldC.getCode()); boolean found = false; for(int k = 0; !found && k < ps.size(); k++) if(ps.get(k).equals(p)) { //now dump it. ps.remove(k); found = true; } } //if the new one is unique, add it if(newC.getCode() > 1) uniquePoints.get(newC.getCode()).add(p); } public void set(java.awt.Point p, Cell c) { //updating Cells ^^ //if the code is different, then update the uniques! if(blocks[p.x][p.y].cell.getCode() != c.getCode()) updateUnique(c, blocks[p.x][p.y].cell, p); //set the cell into it's new home blocks[p.x][p.y].cell.set(c);//copies the new cell into it's self blocks[p.x][p.y].cell.unTake();//makes sure there is no people on it, it's for a map (maps don't show people on them!) } public void makePathToFood(ArrayList<Integer> path, Point start) throws World.DirectionException, World.NoGoalException { //code for food is 3, go to it. if(!isDead) makePathToCode(3, path, start); } public void makePathToWater(ArrayList<Integer> path, Point start) throws World.DirectionException, World.NoGoalException { //code for water is 2, go to it. if(!isDead) makePathToCode(2, path, start); } private PathPoint findGoal(int code, Point start, ArrayList<PathPoint> avoiders) throws World.NoGoalException { //I recently came up with this, after a good 80% of the pathfinding-making time passed... //get the points that are the goals we want ArrayList<Point> goals = uniquePoints.get(code); if(Main.DEBUG) for(int k = 0; k < goals.size(); k++) System.out.println("Goal point ("+(k+1)+"): "+goals.get(k)); { int k = 0; while(k < goals.size()) { boolean good = true; for(int j = 0; j < avoiders.size(); j++) if(goals.get(k).equals(avoiders.get(j))) { good = false; goals.remove(k); } if(good) k++; } } if(goals.size() <= 0) throw new World.NoGoalException(); if(Main.DEBUG) for(int k = 0; k < goals.size(); k++) System.out.println("Good Goal point ("+(k+1)+"): "+goals.get(k)); int shortestGoal = 0; double shortestGoalLength = 99999.9;//should be increased? //go through all of them and find the shortest. for(int k = 0; k < goals.size(); k++) if(start.distance(goals.get(k))<shortestGoalLength) { if(Main.DEBUG) System.out.println(goals.get(k)+" is shorter then "+shortestGoalLength); shortestGoalLength = start.distance(goals.get(k)); shortestGoal = k; } //return shortest. return blocks[goals.get(shortestGoal).x][goals.get(shortestGoal).y]; } private int makeH(Point a, Point b) { return (int)a.distance(b); } private void pathAdd(PathPoint p, PathPoint parent, Point goal, ArrayList<PathPoint> list) { if(parent == null) { p.parent = null; p.g = 0; p.h = makeH(p,goal); } else { p.parent = parent; p.g = parent.g + 1; p.h = makeH(p,goal); } list.add(p); } private int findLowestFIn(ArrayList<PathPoint> list) { int lowest = -1; int lowestF = 99999; for(int k = 0; k < list.size(); k++) { if(list.get(k).getF() < lowestF) { lowest = k; lowestF = list.get(k).getF(); } } return lowest; } private boolean onList(ArrayList<PathPoint> list, PathPoint p) { boolean is = false; for(int k = 0; (!is)&&(k < list.size()); k++) if(p.equals(list.get(k))) is = true; return is; } private ArrayList<PathPoint> getPath(PathPoint start, PathPoint end) throws World.CanNotFindGoalException { ArrayList<PathPoint> open = new ArrayList<PathPoint>(); ArrayList<PathPoint> closed = new ArrayList<PathPoint>(); boolean found = false; // 1) Add the starting square (or node) to the open list. pathAdd(start, null, end, open); // 2) Repeat the following: while((!found)&&(open.size()>0)) { // a) Look for the lowest F cost square on the open list. We refer to this as the current square. int lowestF = findLowestFIn(open); // b) Switch it to the closed list. PathPoint current = open.get(lowestF); open.remove(lowestF); closed.add(current); ArrayList<PathPoint> sides = getOpenSides(current); // c) For each of the 8 squares adjacent to this current square & for(int k = 0; k < sides.size(); k++) { // * If it is not walkable or if it is on the closed list, ignore it. Otherwise do the following. if(!onList(closed, sides.get(k))) { // * If it isnt on the open list, add it to the open list. Make the current square the parent of this square. Record the F, G, and H costs of the square. if(!onList(open, sides.get(k))) { pathAdd(sides.get(k), current, end, open); } else { //check to see if this path to that square is better, using G cost as the measure. //A lower G cost means that this is a better path. if(current.g+1 < sides.get(k).g) { //If so, change the parent of the square to the current square, and recalculate the G and F scores of the square. sides.get(k).parent = current; sides.get(k).g = current.g + 1; } } } } // d) Stop when you: // * Add the target square to the closed list, in which case the path has been found (see note below), or if(onList(closed, end)) found = true; } // * Fail to find the target square, and the open list is empty. In this case, there is no path. if(!found) throw new World.CanNotFindGoalException(); // 3) Save the path. Working backwards from the target square, go from each square to its parent square until you reach the starting square. That is your path. ArrayList<PathPoint> invertedPath = new ArrayList<PathPoint>(); PathPoint current = end; while(current.parent != null) { invertedPath.add(current); current = current.parent; } ArrayList<PathPoint> path = new ArrayList<PathPoint>(); for(int k = invertedPath.size()-1; k >= 0; k--) path.add(invertedPath.get(k)); return path; } private void path2(Point beginning, int code, ArrayList<Integer> path) throws World.DirectionException, World.NoGoalException { path2(beginning, code, path, new ArrayList<PathPoint>()); } private void path2(Point beginning, int code, ArrayList<Integer> path, ArrayList<PathPoint> avoidGoals) throws World.DirectionException, World.NoGoalException { //We are not on it, it was worth a try :( if(isDead) return; if(Main.DEBUG) System.out.println("Path2: "); //add the start cell PathPoint start = blocks[beginning.x][beginning.y]; //Find the closest goal cell PathPoint end = findGoal(code, beginning, avoidGoals); if(isDead) return; if(Main.DEBUG) System.out.println("Start"+start); if(Main.DEBUG) System.out.println("end"+end); //Path routez = getPath(start,end); //ArrayList<PathPoint> route = routez.Tiles(); ArrayList<PathPoint> route = null; try { route = getPath(start,end); } catch(World.CanNotFindGoalException cnfge) { avoidGoals.add(end); path2(beginning, code, path, avoidGoals); } if(route != null) for(int k = 0; k < (route.size()-1); k++) path.add(direction(route.get(k), route.get(k+1))); //path.Tiles() = "Current > Goal" if(Main.DEBUG) System.out.println("End Path2"); } public void makePathToCode(int code, ArrayList<Integer> path, Point beginning) throws World.DirectionException, World.NoGoalException { { if(Main.DEBUG) System.out.println("Map.makePathToCode-0"); if(isDead) return; //Clear All cells for next path-finding for(int x = 0; x < blocks.length; x++) for(int y =0; y<blocks[x].length; y++) blocks[x][y].clear(); printMap(); //Set a stocknumber, a default d int stockNum = blocks[2][2].stock; if(Main.DEBUG) System.out.println("Map.makePathToCode-1"); //Check if we are on it if(blocks[beginning.x][beginning.y].cell.getCode() == code) { //we are on it! if(Main.DEBUG) System.out.println("Map.makePathToCode-2-A-0"); if(isDead) return; //lets move once in an open direction and move back PathPoint b = getOpenSides(blocks[beginning.x][beginning.y]).get(0); PathPoint ac = blocks[beginning.x][beginning.y]; if(Main.DEBUG) System.out.println("Map.makePathToCode-2-A-1"); if(isDead) return; //add the moves into the path list path.add(direction(ac,b)); path.add(direction(b,ac)); if(Main.DEBUG) System.out.println("Map.makePathToCode-2-A-Done"); } else { //check to see if we are one block away, will crash. boolean oneAway = false; ArrayList<PathPoint> test = getOpenSides(blocks[beginning.x][beginning.y]); for(int k = 0; k < test.size(); k++) if(test.get(k).cell.getCode() == code) { oneAway = true; path.add(direction(blocks[beginning.x][beginning.y],test.get(k))); } if(oneAway == false) path2(beginning, code, path); } } if(Main.DEBUG) { System.out.println("Path: "); for(int k = 0; k < path.size(); k++) { int t = path.get(k); //get dir from t; String dir = ""; switch(t) { case World.North: dir = "North"; break; case World.East: dir = "East"; break; case World.South: dir = "South"; break; case World.West: dir = "West"; break; } System.out.print(dir+","); } System.out.println(""); } System.gc(); } private ArrayList<PathPoint> getPathPointsAround(PathPoint p, int r) { if(Main.DEBUG) System.out.println("getPathPointsAround: "); if(isDead) return null; //get the points around us ArrayList<Point> ps = World.getPointsAround(p, r); if(isDead) return null; //and convert them to pathpoint, excluding the "out of bounds" ones ArrayList<PathPoint> pp = new ArrayList<PathPoint>(); for(int k = 0; k < ps.size(); k++) try { pp.add(blocks[ps.get(k).x][ps.get(k).y]); if(Main.DEBUG) System.out.println(blocks[ps.get(k).x][ps.get(k).y]); } catch(ArrayIndexOutOfBoundsException aioobe) { } if(Main.DEBUG) System.out.println(""); return pp; } private int direction(Point a, Point b) throws World.DirectionException { //what direction would I have to go from a to b? {north,south,east, or west} if((a.x == b.x) && (a.y+1 == b.y)) return World.NORTH; else if((a.x+1 == b.x) && (a.y == b.y)) return World.EAST; else if((a.x == b.x) && (a.y-1 == b.y)) return World.SOUTH; else if((a.x-1 == b.x) && (a.y == b.y)) return World.WEST; else throw new World.DirectionException(); } private ArrayList<PathPoint> getOpenSides(PathPoint pp) { if(Main.DEBUG) System.out.println("Open Sides: "); ArrayList<PathPoint> newP = new ArrayList<PathPoint>(); if(isDead) return null; //add the side of the current cell to the list. newP.add(blocks[pp.x+1][pp.y]); newP.add(blocks[pp.x-1][pp.y]); newP.add(blocks[pp.x][pp.y+1]); newP.add(blocks[pp.x][pp.y-1]); if(isDead) return null; int k = 0; while(k < newP.size()) { //remove the walls (they are not open!) if(newP.get(k).cell.getCode()<=0) { newP.remove(k); } else { if(Main.DEBUG) System.out.print(newP.get(k)); k++; } } if(Main.DEBUG) System.out.println(""); return newP; } private void printMap() { if(Main.DEBUG) { System.out.println("Map:"); for(int x = 0; x < xSize; x++) { for(int y = 0; y < ySize; y++) System.out.print(blocks[x][y]); System.out.println(""); } System.out.println(""); } } static class PathPoint extends Point { public Cell cell; public final int stock; public PathPoint parent; public int g; public int h; PathPoint(int base) { this(new Point(0,0), new Cell(), base); } PathPoint(Point p, Cell c, int base) { super(p); cell = c; stock = base; clear(); } public int getF() { return g+h; } public void clear() { g = stock; h = stock; parent = null; } public void close() { parent = null; cell.close(); cell = null; } public boolean canWalk() { return cell.getCode() > 0; } public String toString() { String string = "{@:"+super.toString() + "; Code:" + cell.getCode()+": F:"+(g+h)+": G:"+g+"; Path2Home:["; PathPoint t = this; while(t.parent != null) { string = string + (((Point)t)+":"+t.cell.getCode()) + ">"; t = t.parent; } string = string + "]}"; return string; } } } Log, with Error: Code: $ java Main Main.main-0 Main.main-1 Main.main-2 Main.main-3 Main.main-Done Map.makePathToCode-0 Map: {@:Map$PathPoint[x=0,y=0]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=0,y=1]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=0,y=2]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=0,y=3]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=0,y=4]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=0,y=5]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=0,y=6]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=0,y=7]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=0,y=8]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=0,y=9]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=0,y=10]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=0,y=11]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=0,y=12]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=0,y=13]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=0,y=14]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=0,y=15]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=0,y=16]; Code:0: F:884: G:442; Path2Home:[]} {@:Map$PathPoint[x=1,y=0]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=1,y=1]; Code:2: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=1,y=2]; Code:4: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=1,y=3]; Code:3: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=1,y=4]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=1,y=5]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=1,y=6]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=1,y=7]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=1,y=8]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=1,y=9]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=1,y=10]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=1,y=11]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=1,y=12]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=1,y=13]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=1,y=14]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=1,y=15]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=1,y=16]; Code:0: F:884: G:442; Path2Home:[]} {@:Map$PathPoint[x=2,y=0]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=1]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=2]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=3]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=4]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=5]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=6]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=7]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=8]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=9]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=10]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=11]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=12]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=13]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=14]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=15]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=16]; Code:0: F:884: G:442; Path2Home:[]} {@:Map$PathPoint[x=3,y=0]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=1]; Code:2: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=2]; Code:4: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=3]; Code:3: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=4]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=5]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=6]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=7]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=8]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=9]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=10]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=11]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=12]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=13]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=14]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=15]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=16]; Code:0: F:884: G:442; Path2Home:[]} {@:Map$PathPoint[x=4,y=0]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=4,y=1]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=4,y=2]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=4,y=3]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=4,y=4]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=4,y=5]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=4,y=6]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=4,y=7]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=4,y=8]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=4,y=9]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=4,y=10]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=4,y=11]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=4,y=12]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=4,y=13]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=4,y=14]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=4,y=15]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=4,y=16]; Code:0: F:884: G:442; Path2Home:[]} {@:Map$PathPoint[x=5,y=0]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=5,y=1]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=5,y=2]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=5,y=3]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=5,y=4]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=5,y=5]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=5,y=6]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=5,y=7]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=5,y=8]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=5,y=9]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=5,y=10]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=5,y=11]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=5,y=12]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=5,y=13]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=5,y=14]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=5,y=15]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=5,y=16]; Code:0: F:884: G:442; Path2Home:[]} {@:Map$PathPoint[x=6,y=0]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=6,y=1]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=6,y=2]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=6,y=3]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=6,y=4]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=6,y=5]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=6,y=6]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=6,y=7]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=6,y=8]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=6,y=9]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=6,y=10]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=6,y=11]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=6,y=12]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=6,y=13]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=6,y=14]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=6,y=15]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=6,y=16]; Code:0: F:884: G:442; Path2Home:[]} {@:Map$PathPoint[x=7,y=0]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=7,y=1]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=7,y=2]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=7,y=3]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=7,y=4]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=7,y=5]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=7,y=6]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=7,y=7]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=7,y=8]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=7,y=9]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=7,y=10]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=7,y=11]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=7,y=12]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=7,y=13]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=7,y=14]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=7,y=15]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=7,y=16]; Code:0: F:884: G:442; Path2Home:[]} {@:Map$PathPoint[x=8,y=0]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=8,y=1]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=8,y=2]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=8,y=3]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=8,y=4]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=8,y=5]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=8,y=6]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=8,y=7]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=8,y=8]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=8,y=9]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=8,y=10]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=8,y=11]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=8,y=12]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=8,y=13]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=8,y=14]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=8,y=15]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=8,y=16]; Code:0: F:884: G:442; Path2Home:[]} {@:Map$PathPoint[x=9,y=0]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=9,y=1]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=9,y=2]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=9,y=3]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=9,y=4]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=9,y=5]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=9,y=6]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=9,y=7]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=9,y=8]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=9,y=9]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=9,y=10]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=9,y=11]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=9,y=12]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=9,y=13]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=9,y=14]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=9,y=15]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=9,y=16]; Code:0: F:884: G:442; Path2Home:[]} {@:Map$PathPoint[x=10,y=0]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=10,y=1]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=10,y=2]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=10,y=3]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=10,y=4]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=10,y=5]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=10,y=6]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=10,y=7]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=10,y=8]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=10,y=9]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=10,y=10]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=10,y=11]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=10,y=12]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=10,y=13]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=10,y=14]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=10,y=15]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=10,y=16]; Code:0: F:884: G:442; Path2Home:[]} {@:Map$PathPoint[x=11,y=0]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=11,y=1]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=11,y=2]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=11,y=3]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=11,y=4]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=11,y=5]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=11,y=6]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=11,y=7]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=11,y=8]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=11,y=9]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=11,y=10]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=11,y=11]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=11,y=12]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=11,y=13]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=11,y=14]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=11,y=15]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=11,y=16]; Code:0: F:884: G:442; Path2Home:[]} {@:Map$PathPoint[x=12,y=0]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=12,y=1]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=12,y=2]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=12,y=3]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=12,y=4]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=12,y=5]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=12,y=6]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=12,y=7]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=12,y=8]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=12,y=9]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=12,y=10]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=12,y=11]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=12,y=12]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=12,y=13]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=12,y=14]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=12,y=15]; Code:0: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=12,y=16]; Code:0: F:884: G:442; Path2Home:[]}
Map.makePathToCode-1 Open Sides: {@:Map$PathPoint[x=4,y=6]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=6]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=7]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=5]; Code:1: F:884: G:442; Path2Home:[]} Path2: Goal point (1): java.awt.Point[x=1,y=3] Goal point (2): java.awt.Point[x=1,y=3] Good Goal point (1): java.awt.Point[x=1,y=3] Good Goal point (2): java.awt.Point[x=1,y=3] java.awt.Point[x=1,y=3] is shorter then 99999.9 Start{@:Map$PathPoint[x=3,y=6]; Code:1: F:884: G:442; Path2Home:[]} end{@:Map$PathPoint[x=1,y=3]; Code:3: F:884: G:442; Path2Home:[]} Open Sides: {@:Map$PathPoint[x=4,y=6]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=6]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=7]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=5]; Code:1: F:884: G:442; Path2Home:[]} Open Sides: {@:Map$PathPoint[x=4,y=5]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=5]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=3,y=6]; Code:1: F:3: G:0; Path2Home:[]} Open Sides: {@:Map$PathPoint[x=3,y=6]; Code:1: F:3: G:0; Path2Home:[]}{@:Map$PathPoint[x=1,y=6]; Code:1: F:884: G:442; Path2Home:[]}{@:Map$PathPoint[x=2,y=7]; Code:1: F:884: G:442; Path2Home:[]}Exception in thread "Thread-4" java.lang.StackOverflowError at java.util.Arrays.copyOf(Arrays.java:2895) at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:117) at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:614) at java.lang.StringBuilder.append(StringBuilder.java:229) at java.awt.Point.toString(Point.java:230) at Map$PathPoint.toString(Map.java:542) at java.lang.String.valueOf(String.java:2838) ~for(int k = 0; k < 339; k++) ~{ ~System.out.println(" at java.lang.StringBuilder.append(StringBuilder.java:132)"); ~System.out.println(" at Map$PathPoint.toString(Map.java:546)"); ~System.out.println(" at java.lang.String.valueOf(String.java:2838)"); ~} un-edited log(you have been worned): you sure?: [spoiler] Code: Your message contains 102193 characters. The maximum number of allowed characters is 60000.
Sorry :( [/spoiler] I'll try running it in jGRASP now and see what I can do about the error... also, the Map in the log, if you want to look at it in excel here is a link https://rapidshare.com/files/1025642337/map.xlsnew error: Code: Exception in thread "Thread-6" java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:2772) at java.util.Arrays.copyOf(Arrays.java:2746) at java.util.ArrayList.ensureCapacity(ArrayList.java:187) at java.util.ArrayList.add(ArrayList.java:378) at Map.path2(Map.java:324)
|
|