Example #1
0
    /**
     * Create a new generation of fish from the old generation
     */
    public void CreateNewGeneration()
    {
        // make variable for holding parent genomes
        List <FishGenome> parentGenomes = null;

        // if it's the 0th turn, generate a full set of genomes from nothing
        if (GameManager.Instance.Turn == 1)
        {
            nextGenerationGenomes = FishGenomeUtilities.MakeNewGeneration(initialNumFish, true, true);
        }
        // otherwise, need to make new genomes from the succesful fish's genomes
        // also need to clean out the old fish
        else
        {
            // make new genomes
            parentGenomes         = successfulFishList.Select(fish => fish.GetGenome()).ToList();
            nextGenerationGenomes = FishGenomeUtilities.MakeNewGeneration(parentGenomes, minOffspring, maxOffspring);

            // clean out old fish
            DeleteOldFish();
        }

        // send out notice that new generation has been created
        GameEvents.onNewGeneration.Invoke(parentGenomes, nextGenerationGenomes);
    }