numNodes debug output
This commit is contained in:
parent
95086bdcb4
commit
16e31fee88
@ -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();
|
||||
}
|
||||
|
@ -9,10 +9,6 @@ import baritone.pathfinding.goals.Goal;
|
||||
import baritone.ui.LookManager;
|
||||
import baritone.util.Out;
|
||||
import baritone.util.ToolSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@ -20,8 +16,12 @@ import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
public class Path {
|
||||
@ -38,9 +38,8 @@ public class Path {
|
||||
/**
|
||||
* note that this ISN'T the number of nodes in this path, it's actually the
|
||||
* number of nodes used to calculate this path. this is here for idk why
|
||||
*
|
||||
*/
|
||||
public final int numNodes;
|
||||
private final int numNodes;
|
||||
|
||||
Path(Node start, Node end, Goal goal, int numNodes) {
|
||||
this.numNodes = numNodes;
|
||||
@ -95,6 +94,7 @@ public class Path {
|
||||
Minecraft.getMinecraft().world.setBlockState(path.get(i), originalStates[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Where are we in the path? This is an index in the movement list
|
||||
*/
|
||||
@ -126,6 +126,7 @@ public class Path {
|
||||
double zdiff = z - (pos.getZ() + 0.5D);
|
||||
return Math.sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
|
||||
}
|
||||
|
||||
/**
|
||||
* How many ticks have I been more than MAX_DISTANCE_FROM_PATH away from the
|
||||
* path
|
||||
|
Loading…
Reference in New Issue
Block a user