Ejemplo n.º 1
0
    public AgentGenome Mutate(AgentGenome parentGenome, bool bodySettings, bool brainSettings)
    {
        //AgentGenome parentGenome = leaderboardGenomesList[selectedIndex].candidateGenome;

        //***EAC Creature NAME mutation here???
        string parentName = parentGenome.name;
        int randIndex = Random.Range(0, parentName.Length - 1);
        string frontHalf = parentName.Substring(0, randIndex);
        string middleChar = parentName.Substring(randIndex, 1);
        string backHalf = parentName.Substring(randIndex + 1);
        if (RandomStatics.CoinToss(.05f)) {
            middleChar = RandomStatics.GetRandomLetter();
        }
        frontHalf += middleChar;
        string newName = RandomStatics.CoinToss(.025f) ? backHalf + frontHalf : frontHalf + backHalf;

        //--------------------------------------------------------------------------------------------------------------------

        tempMutationSettings = bodySettings ? mutationSettings : cachedNoneMutationSettings;
        BodyGenome newBodyGenome = new BodyGenome(parentGenome.bodyGenome, tempMutationSettings);

        tempMutationSettings = brainSettings ? mutationSettings : cachedNoneMutationSettings;
        BrainGenome newBrainGenome = new BrainGenome(parentGenome.brainGenome, newBodyGenome, tempMutationSettings);

        return new AgentGenome(newBodyGenome, newBrainGenome, parentGenome.generationCount + 1, newName);
    }
Ejemplo n.º 2
0
    string MutateName(string original)
    {
        var newName = "";

        foreach (var letter in original) {
            float randChance1 = Random.Range(0f, 1f);
            if (randChance1 < 0.35) {
                newName += RandomStatics.GetRandomLetter();

                if (randChance1 < 0.05) {
                    newName += RandomStatics.GetRandomLetter();
                }
            }
            else if (randChance1 <= 0.95f) {
                newName += letter;
            }
        }

        return newName;
    }