using MorgSimulator; var dish = new Dish(); dish.AddMorg(new TypeAMorg(1, (0, 0), (1, 0))); dish.AddMorg(new TypeAMorg(2, (10, 10), (-1, -1))); dish.AddMorg(new TypeBMorg(3, (5, 5), (0, 1))); dish.AddMorg(new TypeBMorg(4, (15, 0), (-1, 0))); dish.AddMorg(new TypeCMorg(5, (8, 8), (0, -1))); dish.AddMorg(new TypeCMorg(6, (20, 5), (-1, 1))); const int RUN_TIME = 15; for (int timeStep = 0; timeStep < RUN_TIME; timeStep++) foreach (var morg in dish.GetAllMorgs()) if (morg.IsAlive) { if (morg.Prey == null || !morg.Prey.IsAlive) { var nearestPrey = dish.FindNearestPrey(morg); if (nearestPrey != null) { nearestPrey.Attach(morg); morg.Prey = nearestPrey; morg.Direction = morg.CalculateDirectionToTarget(nearestPrey.Location); } } morg.Move(); morg.Notify(); if (morg.Prey != null && morg.Prey.IsAlive && morg.DistanceTo(morg.Prey.Location) <= 1.0) morg.Feed(); }