/// <summary> /// Creates a mutated copy of a species /// </summary> public Species CreateMutatedSpecies(Species species) { switch (species) { case MicrobeSpecies s: return(mutator.CreateMutatedSpecies(s, NewMicrobeSpecies())); default: throw new ArgumentException("unhandled species type for CreateMutatedSpecies"); } }
private MicrobeSpecies TryBiodiversitySplit(Species splitFrom, bool inCurrentPatch) { var config = new SimulationConfiguration(configuration, map, Constants.AUTO_EVO_VARIANT_SIMULATION_STEPS); var split = (MicrobeSpecies)splitFrom.Clone(); if (configuration.BiodiversitySplitIsMutated) { mutations.CreateMutatedSpecies((MicrobeSpecies)splitFrom, split); } // Set the starting population in the patch split.Population = configuration.NewBiodiversityIncreasingSpeciesPopulation; config.ExtraSpecies.Add(split); config.PatchesToRun.Add(patch); if (inCurrentPatch) { // TODO: should we apply the population reduction to splitFrom? } PopulationSimulation.Simulate(config); var population = config.Results.GetPopulationInPatch(split, patch); if (population < configuration.NewBiodiversityIncreasingSpeciesPopulation) { return(null); } // TODO: could compare the original species population here to determine if this change is beneficial to // it as well (in which case a non-force species split could be done) // Successfully found a species to create in order to increase biodiversity return(split); }