this will really help performance a lot
This commit is contained in:
parent
2aa4770b45
commit
f28cdc531f
@ -48,7 +48,7 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel
|
||||
|
||||
@Override
|
||||
protected Optional<IPath> calculate0(long timeout) {
|
||||
startNode = getNodeAtPosition(start.x, start.y, start.z);
|
||||
startNode = getNodeAtPosition(start.x, start.y, start.z, posHash(start.x, start.y, start.z));
|
||||
startNode.cost = 0;
|
||||
startNode.combinedCost = startNode.estimatedCostToGoal;
|
||||
BinaryHeapOpenSet openSet = new BinaryHeapOpenSet();
|
||||
@ -118,11 +118,12 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel
|
||||
if (actionCost <= 0) {
|
||||
throw new IllegalStateException(moves + " calculated implausible cost " + actionCost);
|
||||
}
|
||||
if (favoring && favored.contains(posHash(res.destX, res.destY, res.destZ))) {
|
||||
long hashCode = posHash(res.destX, res.destY, res.destZ);
|
||||
if (favoring && favored.contains(hashCode)) {
|
||||
// see issue #18
|
||||
actionCost *= favorCoeff;
|
||||
}
|
||||
PathNode neighbor = getNodeAtPosition(res.destX, res.destY, res.destZ);
|
||||
PathNode neighbor = getNodeAtPosition(res.destX, res.destY, res.destZ, hashCode);
|
||||
double tentativeCost = currentNode.cost + actionCost;
|
||||
if (tentativeCost < neighbor.cost) {
|
||||
if (tentativeCost < 0) {
|
||||
|
@ -129,8 +129,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder {
|
||||
* @return The associated node
|
||||
* @see <a href="https://github.com/cabaletta/baritone/issues/107">Issue #107</a>
|
||||
*/
|
||||
protected PathNode getNodeAtPosition(int x, int y, int z) {
|
||||
long hashCode = posHash(x, y, z);
|
||||
protected PathNode getNodeAtPosition(int x, int y, int z, long hashCode) {
|
||||
PathNode node = map.get(hashCode);
|
||||
if (node == null) {
|
||||
node = new PathNode(x, y, z, goal);
|
||||
|
Loading…
Reference in New Issue
Block a user