Пример #1
0
        public Team Mutate(Team team)
        {
            var mutatedTeam = team.ShallowClone();

            var randomPosition = Random.Next(mutatedTeam.Players.Count);
            var playerToRemove = mutatedTeam.Players[randomPosition];
            var replacementPlayer = SelectRandomPlayer(ReducedPlayerPool,
                playerToRemove.Position);

            mutatedTeam.Players.Remove(playerToRemove);
            mutatedTeam.Players.Insert(randomPosition, replacementPlayer);

            return IsTeamValid(mutatedTeam) ? mutatedTeam : null;
        }