Ejemplo n.º 1
0
  public static void setNumberOfPreFusionEnc() throws GameActionException {

    // only rushDistance determines how many PreFusion encampments to grab
    /*
     * 	int rushDistance = mRC.senseHQLocation().distanceSquaredTo(mRC.senseEnemyHQLocation());
    MapLocation[] allEncampments = mRC.senseEncampmentSquares(mRC.getLocation(), MAX_DIST_SQUARED, null);
    int encampmentsLength = allEncampments.length;
    int encampmentsCloserLength = 0;
    MapLocation[] encampmentsCloser = new MapLocation[allEncampments.length];

    for(int e = 0; e < allEncampments.length; e++){
    	if(allEncampments[e].distanceSquaredTo(mRC.senseEnemyHQLocation()) > allEncampments[e].distanceSquaredTo(mRC.senseHQLocation())){
    		encampmentsCloser[encampmentsCloserLength] = allEncampments[e];
    		encampmentsCloserLength++;
    	}
    }
    */
    // NUM_ENC_TO_CLAIM=allEncampments.length/4;
    // some function of encampmentsLength,encampmentsCloserLength, rushDistance
    MapLocation HQ = mRC.senseHQLocation();
    MapLocation EnemyHQ = mRC.senseEnemyHQLocation();
    int w = Math.abs(HQ.x - EnemyHQ.x);
    int h = Math.abs(HQ.y - EnemyHQ.y);
    int A = Math.max(w, h);
    NUM_PREFUSION_ENC = A / 10;
    /*
     * data for rush distance:
     * 8978 - so huge
     * 3242 - huge
     * 1570 - moderate
     * 800 - small
     * 1170 - moderate
     */

  }
Ejemplo n.º 2
0
 public static void startComputation(MapLocation start) {
   mapWidth = Map_Width;
   mapHeight = Map_Height;
   squareSize = (int) Math.sqrt(mapWidth * mapHeight) / 10;
   System.out.println(squareSize);
   gridWidth = (mapWidth + squareSize - 1) / squareSize;
   gridHeight = (mapHeight + squareSize - 1) / squareSize;
   startSquare = new MapLocation(start.x / squareSize, start.y / squareSize);
   distances = new int[gridWidth][gridHeight];
   costs = new int[gridWidth][gridHeight];
   parents = new MapLocation[gridWidth][gridHeight];
   visited = new boolean[gridWidth][gridHeight];
   done = false;
   mines = mRC.senseNonAlliedMineLocations(start, MAX_DIST_SQUARED);
   for (int i = 0; i < gridWidth; i++)
     for (int j = 0; j < gridHeight; j++) {
       costs[i][j] = squareSize;
       distances[i][j] = MAX_DIST_SQUARED * GameConstants.MINE_DEFUSE_DELAY;
       visited[i][j] = false;
       parents[i][j] = null;
       if (i == gridWidth - 1)
         costs[i][j] += GameConstants.MINE_DEFUSE_DELAY * (mapWidth % squareSize);
       if (j == gridHeight - 1)
         costs[i][j] += GameConstants.MINE_DEFUSE_DELAY * (mapHeight % squareSize);
     }
   for (MapLocation mine : mines) {
     costs[mine.x / squareSize][mine.y / squareSize] +=
         GameConstants.MINE_DEFUSE_DELAY / squareSize;
   }
   distances[startSquare.x][startSquare.y] = 0;
   que = new PriorityQueue<Pair<Integer, MapLocation>>();
   que.add(Pair.of(0, startSquare));
   started = true;
 }
Ejemplo n.º 3
0
  public static boolean goToLocation(MapLocation whereToGo, boolean defuseMines)
      throws GameActionException {
    int dist = mRC.getLocation().distanceSquaredTo(whereToGo);
    // TODO if its an hq and stuff is in the way you gotta kill it
    if (mRC.isActive() && dist > 0) {
      Direction dir = mRC.getLocation().directionTo(whereToGo);
      for (int d : Constants.testDirOrderFrontSide) {
        Direction lookingAtCurrently = Direction.values()[(dir.ordinal() + d + NUM_DIR) % NUM_DIR];
        MapLocation newLoc = mRC.getLocation().add(lookingAtCurrently);
        Team mineOwner = mRC.senseMine(newLoc);
        boolean shouldDefuseEnemyMine = Math.random() < CHANCE_OF_DEFUSING_ENEMY_MINE;
        if (mRC.canMove(lookingAtCurrently)
            && (defuseMines || !isMineDir(mRC.getLocation(), lookingAtCurrently, true))) {

          if (mineOwner != null && mineOwner != mRC.getTeam()) {
            mRC.defuseMine(newLoc);
          } else {
            mRC.move(lookingAtCurrently);
          }
          return true;
        } else if (mRC.canMove(lookingAtCurrently)
            && isMineDir(mRC.getLocation(), lookingAtCurrently, true)
            && mineOwner == mRC.getTeam().opponent()
            && shouldDefuseEnemyMine) {
          mRC.defuseMine(newLoc);
          return true;
        }
      }
    }
    return false;
  }