Beispiel #1
0
  public static void makeSomeNoise() throws GameActionException { // assumes RC is active

    incrementAB();

    if (b < pathat[a] - 1
        && b > 1
        && paths[a][b] != null
        && paths[a][b + 1] != null
        && paths[a][b - 1] != null) {
      if (paths[a][b].directionTo(paths[a][b + 1]) == paths[a][b - 1].directionTo(paths[a][b])) {
        b--;
      }
    }

    if (paths[a][b] != null) {
      if (RC.canAttackSquare(paths[a][b].add(directions[a]))) {
        RC.attackSquare(paths[a][b].add(directions[a]));
      } else {
        makeSomeNoise();
      }
    }
  }
Beispiel #2
0
  public BFSNoiseTower() throws GameActionException {
    System.out.println("start " + Clock.getBytecodeNum());

    queue[0] = currentLocation;
    dir[17][17] = Direction.OMNI;

    for (int i = 7; i >= 0; i--) {
      Direction d = directions[i];
      MapLocation loc = currentLocation.add(d);
      TerrainTile there = RC.senseTerrainTile(loc);
      if (!there.isTraversableAtHeight(RobotLevel.ON_GROUND)) continue;
      int x = loc.x - currentLocation.x;
      int y = loc.y - currentLocation.y;
      dir[x + 17][y + 17] = d.opposite();
      queue[at] = loc;
      at++;
    }

    for (int s = 1; s < at; s++) {
      if (s % 30 == 0 && RC.isActive()) {
        if (target == null
            || target.distanceSquaredTo(ALLY_PASTR_COUNT > 0 ? ALLY_PASTR_LOCS[0] : currentLocation)
                <= 5) {
          earlyNearbyCows();
        }
        MapLocation realTarget = target.add(currentLocation.directionTo(target), 3);

        if (RC.canAttackSquare(realTarget)) RC.attackSquare(realTarget);

        target = target.add(target.directionTo(currentLocation));
      }

      Direction initD =
          dir[queue[s].x - currentLocation.x + 17][queue[s].y - currentLocation.y + 17];
      Direction aD;
      Direction bD;
      if (initD.isDiagonal()) {
        aD = initD.rotateLeft().rotateLeft();
        bD = initD.rotateRight();
      } else {
        aD = initD.rotateLeft().rotateLeft().rotateLeft();
        bD = initD.rotateRight().rotateRight();
      }
      for (Direction d = aD; d != bD; d = d.rotateLeft()) {
        MapLocation loc = queue[s].add(d);
        TerrainTile there = RC.senseTerrainTile(loc);
        if (!there.isTraversableAtHeight(RobotLevel.ON_GROUND)) continue;
        int x = loc.x - currentLocation.x;
        int y = loc.y - currentLocation.y;
        if (x * x + y * y > 200) continue;

        if (dir[x + 17][y + 17] == null) {
          dir[x + 17][y + 17] = d.opposite();
          queue[at] = loc;
          at++;
        }
      }
    }

    System.out.println("end " + Clock.getBytecodeNum());
    System.out.println("at " + at);
  }