Ejemplo n.º 1
0
 private static void updateMaxRange(Signal[] signals) {
   for (int i = 0; i < signals.length; i++) {
     if (signals[i].getTeam() == them) {
       continue;
     }
     int[] message = signals[i].getMessage();
     MessageEncode msgType = MessageEncode.whichStruct(message[0]);
     if (signals[i].getTeam() == us && msgType == MessageEncode.PROXIMITY_NOTIFICATION) {
       int[] decodedMessage =
           MessageEncode.PROXIMITY_NOTIFICATION.decode(signals[i].getLocation(), message);
       range = decodedMessage[0];
       break;
     }
   }
 }
Ejemplo n.º 2
0
 private static void shootWithoutThinking(Signal[] signals) throws GameActionException {
   for (int i = signals.length - 1; i >= 0; i--) {
     if (signals[i].getTeam() == us) {
       int[] message = signals[i].getMessage();
       MessageEncode msgType = MessageEncode.whichStruct(message[0]);
       int[] decodedMessage =
           MessageEncode.TURRET_TARGET.decode(signals[i].getLocation(), message);
       if (msgType == MessageEncode.TURRET_TARGET) {
         MapLocation enemyLocation = new MapLocation(decodedMessage[0], decodedMessage[1]);
         if (rc.canAttackLocation(enemyLocation)) {
           rc.attackLocation(enemyLocation);
           // lastSignal = enemyLocation;
           // patience = rc.getRoundNum();
           return;
         }
       }
     } else {
       MapLocation enemyLocation = signals[i].getLocation();
       if (rc.canAttackLocation(enemyLocation)) {
         rc.attackLocation(enemyLocation);
         return;
       }
     }
   }
   // if (lastSignal != alpha && rc.getRoundNum() - patience <= 27) {
   // if (rc.canAttackLocation(lastSignal)) {
   // rc.attackLocation(lastSignal);
   // }
   // }
   // if (false && rc.getRoundNum() > 500) {
   // Direction trueAway = alpha.directionTo(here);
   // Direction away = trueAway;
   // MapLocation enemyLocation = here;
   // int count = 0;
   // while (count < 4 || rc.canAttackLocation(enemyLocation.add(away))) {
   // enemyLocation = enemyLocation.add(away);
   // away = (new Direction[] { trueAway, trueAway.rotateLeft(),
   // trueAway.rotateRight() })[rand.nextInt(3)];
   // count++;
   //
   // }
   // if (rc.canAttackLocation(enemyLocation)) {
   // rc.attackLocation(enemyLocation);
   // return;
   // }
   // }
 }