private boolean moveToPath() throws GameActionException { if (dstar == null) { dstar = new DStar(outPath, distances, currentLocation); } if (!dstar.arrived(currentLocation)) { dstar.compute(7000); } if (!RC.isActive()) return true; Direction dir = Direction.NORTH, best = null; int min = Integer.MAX_VALUE; for (int i = 0; i < 8; i++) { int d = RC.canMove(dir) ? dstar.getDistance(currentLocation.add(dir)) : Integer.MAX_VALUE; if (d < min) { min = d; best = dir; } dir = dir.rotateRight(); } if (best != null && move(best)) { RC.setIndicatorString(1, "Moving to outPath"); return true; } else { return false; } }
private boolean move(Direction dir) throws GameActionException { if (!RC.isActive() || !RC.canMove(dir)) return false; switch (movementType) { case SNEAK: RC.sneak(dir); break; case RUN: RC.move(dir); break; } return true; }