private void computeOutPath() throws GameActionException { Pair<Direction, Integer> pathingInfo = messagingSystem.readPathingInfo(dest); if (pathingInfo.first == null) { outPath = null; return; } RC.setIndicatorString(1, "Computing outPath"); outPath = new LocSet(); distances = new int[MAP_SIZE]; MapLocation loc = dest; int d = pathingInfo.second; while (!loc.equals(DIJKSTRA_CENTER)) { pathingInfo = messagingSystem.readPathingInfo(loc); distances[outPath.size] = d - pathingInfo.second; outPath.insert(loc); loc = loc.subtract(pathingInfo.first); } int[] diffs = new int[outPath.size - 1]; for (int i = diffs.length; --i > 0; ) { diffs[i] = distances[i + 1] - distances[i]; } // heuristic to prefer further away points on the path (which may be closer to us) for (int i = 1; i < outPath.size; i++) { distances[i] = distances[i - 1] + Math.max(1, diffs[i - 1] * 100 / (100 + 10 * i)); } }
public void setTarget(MapLocation dest) throws GameActionException { if (!dest.equals(this.dest)) { this.dest = dest; computeOutPath(); dstar = null; } }
private void simpleMove(MapLocation loc) throws GameActionException { if (!loc.equals(simpleTarget)) { simpleTarget = loc; simple.recompute(loc); } Direction dir = simple.getNextDir(); if (RC.canMove(dir)) { move(dir); } }