コード例 #1
0
    void Start()
    {
        targetText.text       = targetString;
        CurrentPopulationSize = populationSize;

        if (string.IsNullOrEmpty(targetString))
        {
            Debug.LogError("Target string is null or empty");
            this.enabled = false;
        }

        random = new System.Random();
        ga     = new Andre.AI.GeneticAlgorithm <char>(populationSize, targetString.Length,
                                                      random, elitism, mercy, GetRandomCharacter, FitnessFunction, null, mutationRate);

        //if (Encrypt)
        //    fullSavePath = Application.persistentDataPath + "/" + SaveName + "_Encrypted.GA2B";
        //else
        //    fullSavePath = Application.persistentDataPath + "/" + SaveName + ".GA2B";
        //if (Load)
        //{
        //    ga.LoadGeneration(fullSavePath, Encrypt);
        //    Load = false;
        //}
        //Load();
        UpdateText(ga.BestGenes, ga.BestFitness, ga.Generation);
    }
コード例 #2
0
    // Start is called before the first frame update
    void Start()
    {
        CurrentPopulationSize = populationSize;
        SpeedyGeneration      = new List <TestSpeedy>();
        random = new System.Random();
        ga     = new Andre.AI.GeneticAlgorithm <float>(populationSize, 3, random, elitism, mercy, GetRandomFloat, FitnessFunction, Mutate, mutationRate);

        //if (Encrypt)
        //    fullSavePath = Application.persistentDataPath + "/" + SaveName + "_Encrypted.GA2B";
        //else
        //    fullSavePath = Application.persistentDataPath + "/" + SaveName + ".GA2B";
        //if (Load)
        //{
        //    ga.LoadGeneration(fullSavePath, Encrypt);
        //    Load = false;
        //}
        SpawnSpeedies(populationSize);
        Run(true);
        UpdateUI();
    }