/// <summary> /// Get's called when a fight is finished /// </summary> /// <param name="won">The cell that won</param> /// <param name="lose">The cell that lost</param> private void FightCallback(Cell won, Cell lose) { FightsDone++; lock (_warriorLocker) { // Call's check function's to see if interval has passed CheckForSleeper(); CheckForReplace(); GridWarrior loser = lose.Owner; if (Statics.MainRandom.NextDouble() < Parameters.EvolverParameters.EvolutionChance) { bool crossover = false; Warrior evolveWarrior = _evolver.EvolveWarrior(won.Owner.Warrior, lose.Owner.Warrior, ref crossover); GridWarrior newWarrior = new GridWarrior( evolveWarrior, !crossover ? ColorHelper.IncreaseColor(won.Owner.Color, Statics.MainRandom.Next(-25, 25), Statics.MainRandom.Next(-25, 25), Statics.MainRandom.Next(-25, 25)) : ColorHelper.Mix(won.Owner.Color, lose.Owner.Color)); Warriors.Add(newWarrior); lose.ChangeOwner(newWarrior); } else { lose.ChangeOwner(won.Owner); } if (loser.OwnedCells.Count == 0) { Warriors.Remove(loser); } } }