예제 #1
0
    // Representative system will be expanded later - for now, just defaults to Top # of performers
    public PlayerPopulation(int index, BodyGenome bodyTemplate, int numGenomes, int numPerfReps)
    {
        this.index = index;

        // Re-Factor:
        bodyGenomeTemplate = new BodyGenome();
        bodyGenomeTemplate.CopyBodyGenomeFromTemplate(bodyTemplate);
        //graphKing = new TheGraphKing();

        popSize = numGenomes;
        //this.numBaseline = numBaseline;

        // Create blank AgentGenomes for the standard population
        agentGenomeList    = new List <AgentGenome>();
        historicGenomePool = new List <AgentGenome>();
        //baselineGenomePool = new List<AgentGenome>();

        for (int j = 0; j < numGenomes; j++)
        {
            AgentGenome agentGenome = new AgentGenome(j);
            agentGenome.InitializeBodyGenomeFromTemplate(bodyGenomeTemplate);
            agentGenome.InitializeRandomBrainFromCurrentBody(0.2f);
            agentGenomeList.Add(agentGenome);
        }
        //RepopulateBaselineGenomes();
        //AppendBaselineGenomes();

        // Representatives:
        numPerformanceReps = numPerfReps;
        //Debug.Log("historicGenomePool count b4: " + historicGenomePool.Count.ToString());
        int numStartingHistoricalReps = 20;

        for (int h = 0; h < numStartingHistoricalReps; h++)
        {
            historicGenomePool.Add(agentGenomeList[h]); // init
        }
        //Debug.Log("historicGenomePool count after: " + historicGenomePool.Count.ToString());
        ResetRepresentativesList();

        fitnessManager = new FitnessManager();
        SetUpDefaultFitnessComponents(fitnessManager, this.index);
        //fitnessManager.ResetHistoricalData();
        //fitnessManager.ResetCurrentHistoricalDataLists();
        fitnessManager.InitializeForNewGeneration(agentGenomeList.Count);

        trainingSettingsManager = new TrainingSettingsManager(0.075f, 0.04f, 0.015f, 0.003f);
    }
예제 #2
0
    // Representative system will be expanded later - for now, just defaults to Top # of performers
    public PlayerPopulation(Challenge.Type challengeType, BodyGenome bodyTemplate, int numGenomes, int numBaseline, int numReps)
    {
        bodyGenomeTemplate = new BodyGenome();
        bodyGenomeTemplate.CopyBodyGenomeFromTemplate(bodyTemplate);

        graphKing = new TheGraphKing();

        popSize          = numGenomes;
        this.numBaseline = numBaseline;

        // Create blank AgentGenomes for the standard population
        agentGenomeList    = new List <AgentGenome>();
        historicGenomePool = new List <AgentGenome>();
        baselineGenomePool = new List <AgentGenome>();

        for (int j = 0; j < numGenomes; j++)
        {
            AgentGenome agentGenome = new AgentGenome(j);
            agentGenome.InitializeBodyGenomeFromTemplate(bodyGenomeTemplate);
            agentGenome.InitializeRandomBrainFromCurrentBody(0.0f);
            agentGenomeList.Add(agentGenome);
        }
        RepopulateBaselineGenomes();
        AppendBaselineGenomes();

        // Representatives:
        numPerformanceReps = numReps;
        ResetRepresentativesList();
        historicGenomePool.Add(agentGenomeList[0]); // init

        fitnessManager = new FitnessManager();
        SetUpDefaultFitnessComponents(challengeType, fitnessManager);
        fitnessManager.ResetHistoricalData();
        fitnessManager.ResetCurrentHistoricalDataLists();
        fitnessManager.InitializeForNewGeneration(agentGenomeList.Count);

        trainingSettingsManager = new TrainingSettingsManager(0.01f, 0.8f, 0.2f, 0.005f);
    }
예제 #3
0
    public void ChangeBodyTemplate(BodyGenome pendingBody)
    {
        // Change the Body Composition of this population's Agents:
        // -- Replace the BodyGenome of population's existing templateBody with a copy of the pendingBody
        // -- Do the same for all current Agents in the population
        // -- Replace the bodyNeurons for all current Agents in the population
        // -- Remove vestigial brain connections/nodes

        bodyGenomeTemplate.CopyBodyGenomeFromTemplate(pendingBody); // sets contents of body to a copy of the sourceGenome

        RepopulateBaselineGenomes();                                // update the baselineGenomes to have compatible body

        for (int i = 0; i < agentGenomeList.Count; i++)
        {
            agentGenomeList[i].bodyGenome.CopyBodyGenomeFromTemplate(pendingBody);
            agentGenomeList[i].brainGenome.SetBodyNeuronsFromTemplate(pendingBody);
        }

        // once all existing agents are processed, update templateGenome to be the new one
        // population's templateGenome is basically only for body-plan. All agents will share same Input/Output neurons, but differ in their hidden neurons + connections

        //templateGenome = pendingGenome;
    }
예제 #4
0
 public void InitializeBodyGenomeFromTemplate(BodyGenome bodyGenomeTemplate)
 {
     bodyGenome.CopyBodyGenomeFromTemplate(bodyGenomeTemplate);
 }