/** * Renvoie le nombre de base dans l'équipe. * * @return */ public int getAlliedBaseCount() { SortedMap<Integer, EntityKnowledge> a = allies.get(Names.BASE); if (a == null) { return 0; } int count = 0; for (EntityKnowledge ek : a.values()) { if (ek.getLastUpdateDuration(tick) < 2) { count++; } } return count; }
public EntityKnowledge getBestTarget() { int radius = (int) (WarRocket.AUTONOMY * WarRocket.SPEED); EntityKnowledge target = null; for (Map<Integer, EntityKnowledge> map : ennemies.values()) { for (EntityKnowledge ek : map.values()) { if ((ek.getLastUpdateDuration(tick) < 5) && (ek.getDistance(x, y) < radius)) { if ((target == null) || (ek.getEnergy() < target.getEnergy())) { target = ek; } } } } return target; }
public EntityKnowledge getNearestEnnemy() { EntityKnowledge nearest = null; int minDistance = Integer.MAX_VALUE; for (Map<Integer, EntityKnowledge> map : ennemies.values()) { for (EntityKnowledge ek : map.values()) { if (ek.getLastUpdateDuration(tick) < 2) { int distance = ek.getDistance(getX(), getY()); if (distance < minDistance) { minDistance = distance; nearest = ek; } } } } return nearest; }