public static IEnumerable <ISwitchableGroup <T> > Mutate <T>(this ISwitchableGroup <T> switchableGroup, IRando rando, double mutationRate, IEnumerable <Guid> newGuids) { var mutationSource = rando.MakeSwitchables <T>(switchableGroup.KeyCount).ToMoveNext(); foreach (var newGuid in newGuids) { var switchables = switchableGroup.Switchables.Mutate(rando.ToBoolEnumerator(mutationRate), t => mutationSource.Next()); yield return(new SwitchableGroupImpl <T> ( guid: newGuid, keyCount: switchableGroup.KeyCount, switchables: switchables )); } }
public static ISwitchableGroup <T> ToSwitchableGroup <T>(this IRando rando, Guid guid, int keyCount, int switchableCount) { return(new SwitchableGroupImpl <T>(guid, keyCount, rando.MakeSwitchables <T>(keyCount).Take(switchableCount))); }