Some formatting.

Whatever: this class needs a kick to the head.
Maybe I should make a new one that isn't singleton and thread-unsafe
like this one.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@914 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Ray Greenwell
2010-04-13 20:42:26 +00:00
parent c1ba3f7d18
commit 24e3afe18f
@@ -122,8 +122,7 @@ public class AStarPathUtil
public static final int ADJACENT_COST = 10; public static final int ADJACENT_COST = 10;
/** The cost to move diagonally. */ /** The cost to move diagonally. */
public static final int DIAGONAL_COST = (int)Math.sqrt( public static final int DIAGONAL_COST = (int)Math.sqrt((ADJACENT_COST * ADJACENT_COST) * 2);
(ADJACENT_COST * ADJACENT_COST) * 2);
/** /**
* Return a list of <code>Point</code> objects representing a path from coordinates * Return a list of <code>Point</code> objects representing a path from coordinates
@@ -211,8 +210,7 @@ public class AStarPathUtil
TraversalPred tpred, Object trav, int longest, TraversalPred tpred, Object trav, int longest,
int ax, int ay, int bx, int by, boolean partial) int ax, int ay, int bx, int by, boolean partial)
{ {
return getPath( return getPath(tpred, new Stepper(), trav, longest, ax, ay, bx, by, partial);
tpred, new Stepper(), trav, longest, ax, ay, bx, by, partial);
} }
/** /**
@@ -244,7 +242,7 @@ public class AStarPathUtil
// make sure the cost is reasonable // make sure the cost is reasonable
if (newg > info.maxcost) { if (newg > info.maxcost) {
// Log.info("Rejected costly step."); // Log.info("Rejected costly step.");
return; return;
} }
@@ -253,8 +251,7 @@ public class AStarPathUtil
// skip if it's already in the open or closed list or if its // skip if it's already in the open or closed list or if its
// actual cost is less than the just-calculated cost // actual cost is less than the just-calculated cost
if ((info.open.contains(np) || info.closed.contains(np)) && if ((info.open.contains(np) || info.closed.contains(np)) && np.g <= newg) {
np.g <= newg) {
return; return;
} }
@@ -340,8 +337,7 @@ public class AStarPathUtil
/** The maximum cost of any path that we'll consider. */ /** The maximum cost of any path that we'll consider. */
public int maxcost; public int maxcost;
public Info (TraversalPred tpred, Object trav, public Info (TraversalPred tpred, Object trav, int longest, int destx, int desty)
int longest, int destx, int desty)
{ {
// save off references // save off references
this.tpred = tpred; this.tpred = tpred;
@@ -365,15 +361,12 @@ public class AStarPathUtil
{ {
// not traversable if the destination itself fails test // not traversable if the destination itself fails test
if (tpred instanceof ExtendedTraversalPred) { if (tpred instanceof ExtendedTraversalPred) {
if (!((ExtendedTraversalPred)tpred).canTraverse( if (!((ExtendedTraversalPred)tpred).canTraverse(trav, sx, sy, dx, dy)) {
trav, sx, sy, dx, dy)) {
return false; return false;
} }
} else { } else if (!isTraversable(dx, dy)) {
if (!isTraversable(dx, dy)) {
return false; return false;
} }
}
// if the step is diagonal, make sure the corners don't impede our progress // if the step is diagonal, make sure the corners don't impede our progress
if ((Math.abs(dx - sx) == 1) && (Math.abs(dy - sy) == 1)) { if ((Math.abs(dx - sx) == 1) && (Math.abs(dy - sy) == 1)) {