Example #1
0
  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;
    }
  }
Example #2
0
  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);
    }
  }
Example #3
0
 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;
 }