/// <summary> /// The creature can mate with another creature if it is of the same species /// /// The child gets energy from both parents. This is ReproductionCosts of the Species. /// Both parents loose the ReproductionCosts amount of energy. /// </summary> private void Mate() { var creature = _context.GetCreatures(Species, XPos, YPos, this).FirstOrDefault(); if (creature == null) { return; } // Transfer energy to the child var energy = Species.ReproductionCosts * 2; Energy -= Species.ReproductionCosts; creature.Energy -= Species.ReproductionCosts; // Give the child strength. Average of both parents ±10% var strength = GetChildValue(Strength, creature.Strength); var c = new Creature(XPos, YPos, _context, energy, strength, Species, GetRandomDirection()); _context.AddNewCreature(c); }