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
|
@Override
|
||||||
protected Optional<IPath> calculate0(long timeout) {
|
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.cost = 0;
|
||||||
startNode.combinedCost = startNode.estimatedCostToGoal;
|
startNode.combinedCost = startNode.estimatedCostToGoal;
|
||||||
BinaryHeapOpenSet openSet = new BinaryHeapOpenSet();
|
BinaryHeapOpenSet openSet = new BinaryHeapOpenSet();
|
||||||
@ -118,11 +118,12 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel
|
|||||||
if (actionCost <= 0) {
|
if (actionCost <= 0) {
|
||||||
throw new IllegalStateException(moves + " calculated implausible cost " + actionCost);
|
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
|
// see issue #18
|
||||||
actionCost *= favorCoeff;
|
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;
|
double tentativeCost = currentNode.cost + actionCost;
|
||||||
if (tentativeCost < neighbor.cost) {
|
if (tentativeCost < neighbor.cost) {
|
||||||
if (tentativeCost < 0) {
|
if (tentativeCost < 0) {
|
||||||
|
@ -129,8 +129,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder {
|
|||||||
* @return The associated node
|
* @return The associated node
|
||||||
* @see <a href="https://github.com/cabaletta/baritone/issues/107">Issue #107</a>
|
* @see <a href="https://github.com/cabaletta/baritone/issues/107">Issue #107</a>
|
||||||
*/
|
*/
|
||||||
protected PathNode getNodeAtPosition(int x, int y, int z) {
|
protected PathNode getNodeAtPosition(int x, int y, int z, long hashCode) {
|
||||||
long hashCode = posHash(x, y, z);
|
|
||||||
PathNode node = map.get(hashCode);
|
PathNode node = map.get(hashCode);
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
node = new PathNode(x, y, z, goal);
|
node = new PathNode(x, y, z, goal);
|
||||||
|
Loading…
Reference in New Issue
Block a user