Exemplo n.º 1
0
 public void tryToBuild() throws GameActionException {
   // try to build a robot
   Direction dl = randomDirection();
   if (rc.getRoundNum() % 400 < 20 && rc.canBuild(dl, RobotType.SCOUT) && rc.isCoreReady()) {
     rc.build(dl, RobotType.SCOUT);
   }
   double prob = random.nextDouble();
   int index = 0;
   RobotType robot;
   if (Utility.getClosestRound(zss) < 30) {
     while (prob > probabilitiesZ[index]) {
       index++;
     }
     robot = buildRobotTypes[index];
   } else {
     while (prob > probabilities[index]) {
       index++;
     }
     robot = buildRobotTypes[index];
   }
   for (Direction d : Direction.values()) {
     if (rc.canBuild(d, robot)) {
       if (rc.isCoreReady()) {
         rc.build(d, robot);
         int newid = rc.senseRobotAtLocation(rc.getLocation().add(d)).ID;
         MessageSignal teamFirstDirective = new MessageSignal(rc);
         if (leaderLocation != null) {
           teamFirstDirective.setCommand(leaderLocation, MessageSignal.CommandType.MOVE);
         }
         teamFirstDirective.send(2);
       }
     }
   }
   return;
 }
Exemplo n.º 2
0
 public void getSignals() {
   Signal[] queue = rc.emptySignalQueue();
   for (Signal signal : queue) {
     if (signal.getTeam() == myTeam) {
       if (signal.getMessage() != null) {
         if (signal.getMessage()[0] == 0xdead && signal.getMessage()[1] == 0xbeef) {
           heiarchy--;
           continue;
         }
         MessageSignal msgSig = new MessageSignal(signal);
         switch (msgSig.getMessageType()) {
           case ROBOT:
             if (msgSig.getPingedTeam() == Team.NEUTRAL) {
               rc.setIndicatorString(0, "Found neutral");
               if (msgSig.getPingedLocation().distanceSquaredTo(rc.getLocation()) < 40) {
                 goalLocation = msgSig.getPingedLocation();
               }
             }
             if (msgSig.getPingedType() == RobotType.ARCHON
                 && msgSig.getPingedTeam() == myTeam.opponent()) {
               rc.setIndicatorString(0, "Found enemy Archon");
               foundEnemyArchon = true;
               sentGoal = false;
               enemyArchon = msgSig.getPingedLocation();
             }
             if (msgSig.getPingedType() == RobotType.ZOMBIEDEN) {
               rc.setIndicatorString(2, "Found Zombie Den");
               knownZombieDenLocations.add(msgSig.getPingedLocation());
               foundZombieDen = true;
             }
             break;
           case PARTS:
             break;
           default:
             break;
         }
       }
     }
   }
 }
Exemplo n.º 3
0
  @Override
  public void prerun() throws GameActionException {

    if (rc.getRoundNum() % 5 == 0) {
      RobotInfo[] robotsNearMe = rc.senseNearbyRobots();
      for (RobotInfo ri : robotsNearMe) {
        if (ri.team == Team.NEUTRAL && !neutralBotLocations.contains(ri.location)) {
          neutralBotLocations.add(ri.location);
        }
      }
    }
    getSignals();

    if (!suppressSignals && heiarchy == -1 && (!sentGoal || rc.getRoundNum() - lastSentGoal > 10)) {
      MapLocation goal;
      MessageSignal goalDirection = new MessageSignal(rc);
      if (foundZombieDen) {
        goal = knownZombieDenLocations.get(knownZombieDenLocations.size() - 1);
        goalDirection.setCommand(goal, MessageSignal.CommandType.ATTACK);
      } else if (foundEnemyArchon) {
        goal = enemyArchon;
        goalDirection.setCommand(goal, MessageSignal.CommandType.ATTACK);
      } else {
        goal = rc.getLocation();
        goalDirection.setCommand(goal, MessageSignal.CommandType.MOVE);
      }

      goalDirection.send(GameConstants.MAP_MAX_HEIGHT * GameConstants.MAP_MAX_HEIGHT);
      sentGoal = true;
      lastSentGoal = rc.getRoundNum();
      rc.setIndicatorString(2, goal + "");
    } else {
      rc.setIndicatorString(2, "");
      super.prerun();
    }
  }