Esempio n. 1
0
    public void GenerateArrayFromIndividual()
    {
        int count = 0;

        // PUtting this here to get the project done,
        // it just sees if the winner beat the overal best guy, if not, it makes the winner array[0] a replicate
        // of the overall champ

        if (Winners[0].GetFitness() < OverallChampion.GetFitness())
        {
            Winners[0] = OverallChampion.Replicate("ReplacementWinner");
        }
        for (int i = 0; i < Mathf.Sqrt(numOfCreatures); i++)
        {
            for (int j = 0; j < Math.Sqrt(numOfCreatures); j++)
            {
                if (i == 0 && j < pickedWinnersEachGen) // if we're in the first row, and we want to recreate our winners from last round
                {
                    Creatures[count] = Winners[count % pickedWinnersEachGen].Replicate("Gen" + CurrentGenerationCount + "Creature" + count);
                    Creatures[count].SetCreatureName("Gen" + CurrentGenerationCount + "Creature" + count);
                }
                else // we want to make the creature after we mutated it
                {
                    Creatures[count] = Winners[count % pickedWinnersEachGen].Replicate("Gen" + CurrentGenerationCount + "Creature" + count);
                    Creatures[count].MutateDNA(blockMutationChance, blockMutationChance, jointMutationChance, jointMutationMagnitude);
                    Creatures[count].SetCreatureName("Gen" + CurrentGenerationCount + "Creature" + count);
                }
                count++;
            }
        }
    }