public override double Sense(Universe universe, CreatureElement parent) { Vector orientation = parent.Orientation + DirectionFromParent; Vector displacement; double foodSense = 0; foreach (FoodElement food in universe.Elements.OfType<FoodElement>()) { displacement = food.Position - parent.Position; if (Vector.AngleBetween(orientation, displacement) < Range) { foodSense += (1 / displacement.LengthSquared) * food.GetSize(); } } return foodSense; }
public PlaygroundElement(Universe universe) { Universe = universe; }
public Engine() { Universe = new Universe(); }
public abstract double Sense(Universe universe, Vector parentDirection);