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; }
protected ZSquare squareTo(Integer key) { assert key != null; ZSquare s = squareTo(Constants.decodedX(key), Constants.decodedY(key)); assert s != null; return s; }