Example #1
0
 // Number of ants in all 8 neighboring squares (excluding 'here')
 protected int neighboringAnts(ZSquare excluded) {
   int n = 0;
   for (ZSquare s : neighbors) {
     if (s != excluded) n += s.getNumberOfAnts();
   }
   return n;
 }
Example #2
0
 protected ZSquare bestSquareToAvoidConflict(ZSquare target) {
   if (isAroundNest()) return null; // Don't avoid conflict when nearby own nest
   double dist = 0;
   ZSquare best = null;
   for (ZSquare s : neighbors) {
     if (s.isPassable() && s.getNumberOfAnts() == 0) {
       double d = Constants.normalDistance(target.x - s.x, target.y - s.y);
       if (d > dist) best = s;
     }
   }
   if (best != null) assert best.isPassable();
   return best;
 }