Ejemplo n.º 1
0
    public static void SetInitialSpeciesProperties(MicrobeSpecies species)
    {
        species.IsBacteria = true;
        species.SetInitialCompoundsForDefault();
        species.Genus   = "Primum";
        species.Epithet = "Thrivium";

        species.MembraneType = SimulationParameters.Instance.GetMembrane("single");

        species.Organelles.Add(new OrganelleTemplate(
                                   SimulationParameters.Instance.GetOrganelleType("cytoplasm"), new Hex(0, 0), 0));
    }
Ejemplo n.º 2
0
    /// <summary>
    ///   Creates a mutated version of a species
    /// </summary>
    public MicrobeSpecies CreateMutatedSpecies(MicrobeSpecies parent, MicrobeSpecies mutated)
    {
        var simulation    = SimulationParameters.Instance;
        var nameGenerator = simulation.NameGenerator;

        mutated.IsBacteria = parent.IsBacteria;

        // Mutate the epithet
        if (random.Next(0, 101) < Constants.MUTATION_WORD_EDIT)
        {
            mutated.Epithet = MutateWord(parent.Epithet);
        }
        else
        {
            mutated.Epithet = nameGenerator.GenerateNameSection();
        }

        mutated.Genus = parent.Genus;

        MutateBehaviour(parent, mutated);

        if (random.Next(0, 101) <= Constants.MUTATION_CHANGE_GENUS)
        {
            // We can do more fun stuff here later
            if (random.Next(0, 101) < Constants.MUTATION_WORD_EDIT)
            {
                mutated.Genus = MutateWord(parent.Genus);
            }
            else
            {
                mutated.Genus = nameGenerator.GenerateNameSection();
            }
        }

        MutateMicrobeOrganelles(parent.Organelles, mutated.Organelles, mutated.IsBacteria);

        // There is a small chance of evolving into a eukaryote
        var nucleus = simulation.GetOrganelleType("nucleus");

        if (mutated.Organelles.Any(o => o.Definition == nucleus))
        {
            mutated.IsBacteria = false;
        }

        var colour = mutated.IsBacteria ? RandomProkayroteColour() :
                     RandomColour();

        if (random.Next(0, 101) <= 20)
        {
            // Could perhaps use a weighted entry model here... the
            // earlier one is listed, the more likely currently (I
            // think). That may be an issue.
            if (random.Next(0, 101) < 50)
            {
                mutated.MembraneType = simulation.GetMembrane("single");
            }
            else if (random.Next(0, 101) < 50)
            {
                mutated.MembraneType = simulation.GetMembrane("double");
                colour.a             = RandomOpacityChitin();
            }
            else if (random.Next(0, 101) < 50)
            {
                mutated.MembraneType = simulation.GetMembrane("cellulose");
            }
            else if (random.Next(0, 101) < 50)
            {
                mutated.MembraneType = simulation.GetMembrane("chitin");
                colour.a             = RandomOpacityChitin();
            }
            else if (random.Next(0, 101) < 50)
            {
                mutated.MembraneType = simulation.GetMembrane("calcium_carbonate");
                colour.a             = RandomOpacityChitin();
            }
            else
            {
                mutated.MembraneType = simulation.GetMembrane("silica");
                colour.a             = RandomOpacityChitin();
            }
        }
        else
        {
            mutated.MembraneType = parent.MembraneType;
        }

        mutated.MembraneRigidity = Math.Max(Math.Min(parent.MembraneRigidity +
                                                     random.Next(-25, 26) / 100.0f, 1), -1);

        // If you have iron (f is the symbol for rusticyanin)
        var rusticyanin  = simulation.GetOrganelleType("rusticyanin");
        var chemo        = simulation.GetOrganelleType("chemoplast");
        var chemoProtein = simulation.GetOrganelleType("chemoSynthesizingProteins");

        if (mutated.Organelles.Any(o => o.Definition == rusticyanin))
        {
            mutated.SetInitialCompoundsForIron();
        }
        else if (mutated.Organelles.Any(o => o.Definition == chemo ||
                                        o.Definition == chemoProtein))
        {
            mutated.SetInitialCompoundsForChemo();
        }
        else
        {
            mutated.SetInitialCompoundsForDefault();
        }

        return(mutated);
    }