private Ant FindNearestAnt() { if (Simulation.simulation.queen == null) { return(null); } if (AntHillConfig.antSightRadius >= DistanceMeasurer.Taxi(Simulation.simulation.queen.Position, this.Position)) { return(Simulation.simulation.queen); } LIList <Ant> ants = Simulation.simulation.GetVisibleAnts(this); if (ants == null) { return(null); } if (ants.Count == 0) { return(null); } int minDistance = DistanceMeasurer.Taxi(ants.First.Value.Position, Position); int distance; Ant bestAnt = null; LIList <Ant> .Enumerator ant = ants.GetEnumerator(); while (ant.MoveNext()) { if ((distance = DistanceMeasurer.Taxi(this.Position, ant.Current.Position)) < minDistance) { bestAnt = ant.Current; minDistance = distance; } } return(bestAnt); }
public bool DeleteAnt(Ant ant) { this.food.AddLast(new Food(ant.Position, AntHillConfig.antFoodQuantityAfterDeath)); ants.Remove(ant); return(true); }