numNodes debug output
This commit is contained in:
@@ -102,8 +102,11 @@ public class PathingBehavior extends Behavior {
|
||||
}
|
||||
planAhead();
|
||||
} else if (talkAboutIt) {
|
||||
Out.gui("Finished finding a path from " + start + " to " + goal + ". " + currentPath.numNodes + " nodes considered", Out.Mode.Debug);
|
||||
Out.gui(, Out.Mode.Debug);
|
||||
}*/
|
||||
if (talkAboutIt && current != null && current.getPath() != null) {
|
||||
displayChatMessageRaw("Finished finding a path from " + start + " to " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered");
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch {
|
||||
}
|
||||
if (goal.isInGoal(currentNodePos)) {
|
||||
currentlyRunning = null;
|
||||
return Optional.of(new Path(startNode, currentNode, goal));
|
||||
return Optional.of(new Path(startNode, currentNode, goal, numNodes));
|
||||
}
|
||||
//long constructStart = System.nanoTime();
|
||||
Movement[] possibleMovements = getConnectedPositions(currentNodePos);//movement that we could take that start at myPos, in random order
|
||||
@@ -128,7 +128,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch {
|
||||
}
|
||||
System.out.println("Path goes for " + dist + " blocks");
|
||||
currentlyRunning = null;
|
||||
return Optional.of(new Path(startNode, bestSoFar[i], goal));
|
||||
return Optional.of(new Path(startNode, bestSoFar[i], goal, numNodes));
|
||||
}
|
||||
}
|
||||
System.out.println("Even with a cost coefficient of " + COEFFICIENTS[COEFFICIENTS.length - 1] + ", I couldn't get more than " + bestDist + " blocks =(");
|
||||
|
||||
@@ -103,7 +103,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder {
|
||||
|
||||
@Override
|
||||
public Optional<IPath> pathToMostRecentNodeConsidered() {
|
||||
return Optional.ofNullable(mostRecentConsidered).map(node -> new Path(startNode, node, goal));
|
||||
return Optional.ofNullable(mostRecentConsidered).map(node -> new Path(startNode, node, goal, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,7 +111,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder {
|
||||
if (startNode == null || bestSoFar[0] == null)
|
||||
return Optional.empty();
|
||||
|
||||
return Optional.of(new Path(startNode, bestSoFar[0], goal));
|
||||
return Optional.of(new Path(startNode, bestSoFar[0], goal, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,10 +38,13 @@ class Path implements IPath {
|
||||
|
||||
final List<Movement> movements;
|
||||
|
||||
Path(PathNode start, PathNode end, Goal goal) {
|
||||
private final int numNodes;
|
||||
|
||||
Path(PathNode start, PathNode end, Goal goal, int numNodes) {
|
||||
this.start = start.pos;
|
||||
this.end = end.pos;
|
||||
this.goal = goal;
|
||||
this.numNodes = numNodes;
|
||||
this.path = new ArrayList<>();
|
||||
this.movements = new ArrayList<>();
|
||||
assemblePath(start, end);
|
||||
@@ -119,4 +122,9 @@ class Path implements IPath {
|
||||
public Collection<BlockPos> getBlocksToPlace() {
|
||||
return movements.stream().map(move -> move.positionsToPlace).flatMap(Arrays::stream).collect(Collectors.toCollection(HashSet::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumNodesConsidered() {
|
||||
return numNodes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,4 +104,6 @@ public interface IPath {
|
||||
* @return an unordered collection of positions
|
||||
*/
|
||||
Collection<BlockPos> getBlocksToPlace();
|
||||
|
||||
int getNumNodesConsidered();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user