示例#1
0
    /* When this script is started:
     *   1. Instantiate the genepool
     *   2. Start function that will check on gene pool periodically
     *   3. Initialize dashboard
     */
    void Start()
    {
        // Need an even and positive population size
        if (POPULATION_SIZE % 2 != 0 || POPULATION_SIZE < 2)
        {
            POPULATION_SIZE = 50;
        }

        if (WEIGHTS_FILE != "")
        {
            try
            {
                genePool = new Genepool(new List <Structure>(), POPULATION_SIZE, MUTATION_RATE, MUTATION_RADIUS, WEIGHTS_FILE);
            }
            catch
            {
                Debug.Log("Weights file doesn't exist");
                genePool = new Genepool(new List <Structure>(), POPULATION_SIZE, MUTATION_RATE, MUTATION_RADIUS);
            }
        }
        else
        {
            Debug.Log("Weights file not set");
            genePool = new Genepool(new List <Structure>(), POPULATION_SIZE, MUTATION_RATE, MUTATION_RADIUS);
        }

        // If user has choosen to load weights
        InvokeRepeating("CheckOnGeneration", 5.0f, 5.0f);

        // Initialize the dashboard
        generationNumber = 1;
        dashboard.InitializeDashboard(this.GetGenerationData());
    }
示例#2
0
文件: Program.cs 项目: qantip/GeneoCs
        static void Main(string[] args)
        {
            Dna      temp  = new Dna(5);
            Genepool gpool = new Genepool(temp, 10);

            gpool.Randomize();
            gpool.Render();
        }