Fixed pathfinding bug.
This commit is contained in:
@@ -132,7 +132,7 @@ public class Game {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return reconstructShortestPath(allVerticies, dst);
|
return reconstructShortestPath(allVerticies, src,dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean doUndo(){
|
public boolean doUndo(){
|
||||||
@@ -214,7 +214,7 @@ public class Game {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Point> reconstructShortestPath(final List<Vertex> vertices, final Point dst) {
|
private List<Point> reconstructShortestPath(final List<Vertex> vertices, final Point src, final Point dst) {
|
||||||
ArrayList<Point> path = new ArrayList<Point>();
|
ArrayList<Point> path = new ArrayList<Point>();
|
||||||
path.add(dst);
|
path.add(dst);
|
||||||
Vertex u = findVertex(dst, vertices);
|
Vertex u = findVertex(dst, vertices);
|
||||||
@@ -225,6 +225,9 @@ public class Game {
|
|||||||
u= u.getPrev();
|
u= u.getPrev();
|
||||||
path.add(0, u.getPos());
|
path.add(0, u.getPos());
|
||||||
}
|
}
|
||||||
|
if(u!=findVertex(src, vertices)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user