Пример #1
0
    public void CopyBodyGenomeFromTemplate(BodyGenome templateGenome)
    {
        testModuleGenome = new TestModuleGenome(templateGenome.testModuleGenome);

        /*
         * // This method creates a clone of the provided BodyGenome - should have no shared references!!!
         * bodyType = templateGenome.bodyType;
         * // copy module lists:
         * healthModuleList = new List<HealthGenome>();
         * for (int i = 0; i < templateGenome.healthModuleList.Count; i++) {
         *  HealthGenome genomeCopy = new HealthGenome(templateGenome.healthModuleList[i]);
         *  healthModuleList.Add(genomeCopy);
         * }
         * oscillatorInputList = new List<OscillatorGenome>();
         * for (int i = 0; i < templateGenome.oscillatorInputList.Count; i++) {
         *  OscillatorGenome genomeCopy = new OscillatorGenome(templateGenome.oscillatorInputList[i]);
         *  oscillatorInputList.Add(genomeCopy);
         * }
         * valueInputList = new List<ValueInputGenome>();
         * for (int i = 0; i < templateGenome.valueInputList.Count; i++) {
         *  ValueInputGenome genomeCopy = new ValueInputGenome(templateGenome.valueInputList[i]);
         *  valueInputList.Add(genomeCopy);
         * }
         */
    }
Пример #2
0
    //CritterModuleFoodSensorsGenome food;
    //CritterModuleFriendSensorsGenome friend;
    //CritterModuleThreatSensorsGenome threat;
    //CritterModuleEnvironmentSensorsGenome environment;
    //CritterModuleCommunicationGenome communication;

    public void Refresh()
    {
        if (genome?.bodyGenome == null)
        {
            return;
        }

        body = genome.bodyGenome;
        //food = body.foodGenome;
        //friend = body.friendGenome;
        //threat = body.threatGenome;
        //environment = body.environmentalGenome;
        //communication = body.communicationGenome;

        foreach (var sensor in sensors)
        {
            sensor.SetSensorEnabled(IsSensorEnabled(sensor.id));
        }

        if (!agent)
        {
            return;
        }

        foreach (var sensor in sensors)
        {
            sensor.SetSensorTooltip(GetSensorTooltipText(sensor));
        }
    }
Пример #3
0
    public CritterInitData(BodyGenome bodyGenome)
    {
        boundingBoxSize     = bodyGenome.GetFullsizeBoundingBox();
        spawnSizePercentage = 0.1f;
        maxEnergy           = Mathf.Min(boundingBoxSize.x * boundingBoxSize.y, 0.5f);
        maxStomachCapacity  = 1f;
        primaryHue          = bodyGenome.appearanceGenome.huePrimary;
        secondaryHue        = bodyGenome.appearanceGenome.hueSecondary;
        biteConsumeRadius   = 1f;
        biteTriggerRadius   = 1f;
        biteTriggerLength   = 1f;
        eatEfficiencyPlant  = 1f;
        eatEfficiencyDecay  = 1f;
        eatEfficiencyMeat   = 1f;

        // 0 = longest, 1 = shortest
        float swimLerp = Mathf.Clamp01((bodyGenome.coreGenome.creatureAspectRatio - 0.175f) / 0.35f);

        // Mag range: 2 --> 0.5
        // freq range: 1 --> 2
        swimMagnitude = Mathf.Lerp(0.225f, 1.1f, swimLerp);
        swimFrequency = Mathf.Lerp(1.5f, 0.6f, swimLerp);
        swimAnimSpeed = 6f;

        bodyCoord  = bodyGenome.coreGenome.bodyCoord;
        headCoord  = bodyGenome.coreGenome.headCoord;
        mouthCoord = bodyGenome.coreGenome.mouthCoord;
        bendiness  = 1f;
        speciesID  = 0;

        // what grid cell of texture sheet to use
        bodyPatternX = bodyGenome.appearanceGenome.bodyStrokeBrushTypeX;
        bodyPatternY = bodyGenome.appearanceGenome.bodyStrokeBrushTypeY;
    }
Пример #4
0
 // Mutable by Player
 // Add body-sensor/effector mutations here and cleanup Brain Genome
 void SetToMutatedCopyOfParentGenome(BodyGenome parent, MutationSettingsInstance settings)
 {
     appearanceGenome.SetToMutatedCopyOfParentGenome(parent.appearanceGenome, settings);
     coreGenome.SetToMutatedCopyOfParentGenome(parent.coreGenome, settings);
     unlockedTech            = unlockedTech.GetMutatedCopy();
     newlyUnlockedNeuronInfo = GetNewlyUnlockedNeurons(parent);
 }
Пример #5
0
 public void InitializeRandomBrainGenome(BodyGenome bodyGenome)
 {
     InitializeNewBrainGenomeLists();
     InitializeIONeurons(bodyGenome);
     //PrintNeuronCounts();
     InitializeAxons();
 }
Пример #6
0
 public BrainGenome(BodyGenome bodyGenome, float initialConnectionDensity, int hiddenNeuronCount)
 {
     initialWeightMultiplier  = 1f;
     initialConnectionChance  = initialConnectionDensity;
     initialHiddenNeuronCount = hiddenNeuronCount;
     InitializeRandomBrainGenome(bodyGenome);
 }
Пример #7
0
    public TeamsConfig(int numPlayers, int numEnvironmentReps, int numPlayerReps)
    {
        //EnvironmentGenome templateEnvironmentGenome = GetDefaultTemplateEnvironmentGenome(challengeType);
        EnvironmentGenome templateEnvironmentGenome = new EnvironmentGenome(-1);

        templateEnvironmentGenome.InitializeAsDefaultGenome();  // Temporary hacky solution

        environmentPopulation = new EnvironmentPopulation(templateEnvironmentGenome, numEnvironmentGenomes, numEnvironmentReps);

        // Players:
        playersList = new List <PlayerPopulation>();
        for (int i = 0; i < numPlayers; i++)
        {
            // Might have to revisit how to pass agent templates per population...
            //AgentBodyGenomeTemplate templateAgentGenome = GetDefaultTemplateAgentGenome(challengeType);
            // Temporary hack solution:
            BodyGenome templateBodyGenome = new BodyGenome();
            templateBodyGenome.InitializeGenomeAsDefault();
            if (i == 0f)
            {
                templateBodyGenome.testModuleGenome.maxSpeed = 0.25f;
                templateBodyGenome.testModuleGenome.accel    = 0.025f;
            }
            else
            {
                templateBodyGenome.testModuleGenome.maxSpeed = 1f;
                templateBodyGenome.testModuleGenome.accel    = 0.35f;
            }

            // List of Agent Genomes
            PlayerPopulation player = new PlayerPopulation(i, templateBodyGenome, numAgentGenomesPerPlayer, numPlayerReps);

            playersList.Add(player);
        }
    }
Пример #8
0
    // Constructor
    public AgentGenome(int index)
    {
        this.index = index;

        bodyGenome  = new BodyGenome(); // empty constructors:
        brainGenome = new BrainGenome();
    }
Пример #9
0
    public static float GetBodySizeScore01(BodyGenome genome)
    {
        // Refactor: 25f is hardcoded approximate! // * WPP: approximate of what? (use a constant or exposed value)
        float normalizedSizeScore = Mathf.Clamp01(((genome.GetFullsizeBoundingBox().x + genome.GetFullsizeBoundingBox().z) / genome.GetFullsizeBoundingBox().y) / 25f);

        return(normalizedSizeScore);
    }
Пример #10
0
    public AgentGenome Mutate(AgentGenome parentGenome, bool bodySettings, bool brainSettings)
    {
        //AgentGenome parentGenome = leaderboardGenomesList[selectedIndex].candidateGenome;

        //***EAC Creature NAME mutation here???
        string parentName = parentGenome.name;
        int randIndex = Random.Range(0, parentName.Length - 1);
        string frontHalf = parentName.Substring(0, randIndex);
        string middleChar = parentName.Substring(randIndex, 1);
        string backHalf = parentName.Substring(randIndex + 1);
        if (RandomStatics.CoinToss(.05f)) {
            middleChar = RandomStatics.GetRandomLetter();
        }
        frontHalf += middleChar;
        string newName = RandomStatics.CoinToss(.025f) ? backHalf + frontHalf : frontHalf + backHalf;

        //--------------------------------------------------------------------------------------------------------------------

        tempMutationSettings = bodySettings ? mutationSettings : cachedNoneMutationSettings;
        BodyGenome newBodyGenome = new BodyGenome(parentGenome.bodyGenome, tempMutationSettings);

        tempMutationSettings = brainSettings ? mutationSettings : cachedNoneMutationSettings;
        BrainGenome newBrainGenome = new BrainGenome(parentGenome.brainGenome, newBodyGenome, tempMutationSettings);

        return new AgentGenome(newBodyGenome, newBrainGenome, parentGenome.generationCount + 1, newName);
    }
Пример #11
0
 public AgentGenome(BodyGenome bodyGenome, BrainGenome brainGenome, int generationCount, string name)
 {
     this.bodyGenome      = bodyGenome;
     this.brainGenome     = brainGenome;
     this.generationCount = generationCount;
     this.name            = name;
     //Debug.Log("Constructing AgentGenome via mutation");
 }
Пример #12
0
    public BodyGenome(BodyGenome parentGenome, MutationSettingsInstance mutationSettings)
    {
        unlockedTech = new UnlockedTech(parentGenome.unlockedTech);
        data         = new BodyGenomeData(unlockedTech);

        FirstTimeInitializeCritterModuleGenomes();
        SetToMutatedCopyOfParentGenome(parentGenome, mutationSettings);
    }
Пример #13
0
    public void InitializeBodyNeurons(BodyGenome bodyGenome)
    {
        bodyGenome.InitializeBrainGenome(bodyNeuronList);

        /*for (int i = 0; i < bodyGenome.healthModuleList.Count; i++) {
         *  bodyGenome.healthModuleList[i].InitializeBrainGenome(bodyNeuronList);
         * }
         * for (int i = 0; i < bodyGenome.valueInputList.Count; i++) {
         *  bodyGenome.valueInputList[i].InitializeBrainGenome(bodyNeuronList);
         * }*/
    }
Пример #14
0
    public void StartNewTrainingMode()
    {
        Destroy(playerGO);

        // Create population brains
        agentGenomeList = new List <AgentGenome>();

        BodyGenome templateBodyGenome = new BodyGenome();

        templateBodyGenome.InitializeGenomeAsDefault();
        //BodyGenome bodyGenomeTemplate = new BodyGenome();
        //bodyGenomeTemplate.CopyBodyGenomeFromTemplate(bodyTemplate);

        for (int i = 0; i < trainingPopulationSize; i++)
        {
            AgentGenome newGenome = new AgentGenome(i);
            newGenome.InitializeBodyGenomeFromTemplate(templateBodyGenome);
            newGenome.InitializeRandomBrainFromCurrentBody(0.033f);
            agentGenomeList.Add(newGenome);
        }

        // CrossoverSettings:
        trainingSettingsManager = new TrainingSettingsManager(0.06f, 0.35f, 0.1f, 0.01f);
        GameObject dummyAgentGO = new GameObject("DummyAgent");

        dummyAgent       = dummyAgentGO.AddComponent <Agent>();
        dummyStartGenome = new StartPositionGenome(Vector3.zero, Quaternion.identity);

        ResetTrainingForNewGen();
        //Brain brain = new Brain()
        //Debug.Log(dummyAgent.testModule.);

        // Create Visible Display Agent to observe behavior

        /*displayStartPos = new StartPositionGenome(Vector3.zero, Quaternion.identity);
         * GameObject agentGO = Instantiate(Resources.Load("PredatorPrey/PredatorPrefab")) as GameObject; ; // GameObject.CreatePrimitive(PrimitiveType.Sphere);
         * //displayAgent
         * agentGO.name = "Guinea Pig";
         * //agentGO.transform.parent = gameObject.transform;
         * agentGO.transform.localPosition = displayStartPos.agentStartPosition;
         * agentGO.transform.localRotation = displayStartPos.agentStartRotation;
         * //agentGO.GetComponent<Collider>().enabled = false;
         * displayAgent = agentGO.AddComponent<Agent>();
         * displayAgent.isVisible = true;
         * displayAgent.InitializeAgentFromTemplate(agentGenomeList[0], displayStartPos);
         * // hook modules:
         * displayAgent.testModule.enemyTransform = targetGO.transform;
         * displayAgent.testModule.bias[0] = 1f;
         * displayAgent.testModule.enemyTestModule = displayAgent.testModule; // self as target, to zero out targetvel
         */
        ResetTrainingAgentAndEnvironment();
    }
Пример #15
0
    public void SetBodyNeuronsFromTemplate(BodyGenome templateBody)
    {
        if (bodyNeuronList == null)
        {
            bodyNeuronList = new List <NeuronGenome>();
        }
        else
        {
            bodyNeuronList.Clear();
        }

        InitializeBodyNeurons(templateBody);
    }
Пример #16
0
 public void UpdateActorModules(int focusPop, EnvironmentGenome pendingEnvGenome, BodyGenome pendingBodyGenome)
 {
     if (focusPop == 0)  // Environment:
     //Debug.Log("UpdateActorModules startPosCount: " + pendingEnvGenome.agentStartPositionsList.Count.ToString());
     {
         teamsConfig.environmentPopulation.ChangeGenomeTemplate(pendingEnvGenome);
         //Debug.Log("")
     }
     else    // Agent:
     {
         teamsConfig.playersList[focusPop - 1].ChangeBodyTemplate(pendingBodyGenome);
     }
     ResetGeneration();
 }
Пример #17
0
    IEnumerator Start()
    {
        trans = GetComponent <Transform>();

        BestGenomes               = new BodyGenome[5];
        BestGenomes[0]            = new BodyGenome();
        BestGenomes[0].RightGenes = new LegGenes(0.60f, 0, 4f, 0);
        BestGenomes[0].LeftGenes  = new LegGenes(0.60f, 0, 4f, Mathf.PI / 2);

        creatures = new List <Body>();
        while (true)
        {
            GenerationCount++;
            GenerationLabel.text = "Generation: " + GenerationCount;
            TimeOffset           = Time.time;
            for (int i = 0; i < BestGenomes.Length; i++)
            {
                Transform bodyTrans = Instantiate <Transform>(Creature);
                bodyTrans.position = trans.position;
                Body body = bodyTrans.GetComponent <Body>();
                body.Genome = BestGenomes[i];
                creatures.Add(body);
                body.SetColor(Colors[i]);
                for (int j = 1; j < CreatureCount; j++)
                {
                    bodyTrans          = Instantiate <Transform>(Creature);
                    bodyTrans.position = trans.position;
                    body        = bodyTrans.GetComponent <Body>();
                    body.Genome = BestGenomes[i];
                    body.Genome.Mutate();
                    creatures.Add(body);
                    body.SetColor(Color.Lerp(Colors[i], Color.white, (float)j / (float)CreatureCount / 2f));
                }
            }

            yield return(new WaitForSeconds(RunTime));

            creatures.Sort(new System.Comparison <Body>((x, y) => x.Score > y.Score ? -1 : 0));
            for (int i = 0; i < BestGenomes.Length; i++)
            {
                BestGenomes[i] = creatures[i].Genome;
            }
            foreach (Body creature in creatures)
            {
                Destroy(creature.gameObject);
            }
            creatures.Clear();
        }
    }
Пример #18
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);
    }
Пример #19
0
    List <NeuronGenome> GetNewlyUnlockedNeurons(BodyGenome genome)
    {
        var result = new List <NeuronGenome>();

        foreach (var neuron in inOutNeurons)
        {
            foreach (var newNeuron in genome.newlyUnlockedNeuronInfo)
            {
                if (neuron.data == newNeuron)
                {
                    result.Add(neuron);
                }
            }
        }

        return(result);
    }
Пример #20
0
    public void SetToMutatedCopyOfParentGenome(BrainGenome parentGenome, BodyGenome bodyGenome, MutationSettingsInstance settings)
    {
        /*
         * //this.bodyNeuronList = parentGenome.bodyNeuronList; // UNSUSTAINABLE!!! might work now since all neuronLists are identical ******
         *
         * // Copy from parent brain or rebuild neurons from scratch based on the new mutated bodyGenome???? --- ******
         * for(int i = 0; i < parentGenome.bodyNeuronList.Count; i++) {
         *  NeuronGenome newBodyNeuronGenome = new NeuronGenome(parentGenome.bodyNeuronList[i]);
         *  this.bodyNeuronList.Add(newBodyNeuronGenome);
         * }
         * // Alternate: SetBodyNeuronsFromTemplate(BodyGenome templateBody);
         */

        // Rebuild BodyNeuronGenomeList from scratch based on bodyGenome
        InitializeBodyNeuronList();
        InitializeIONeurons(bodyGenome);

        hiddenNeurons = MutateHiddenNeurons(parentGenome.hiddenNeurons);
        links         = MutateLinks(parentGenome.links, settings);

        if (RandomStatics.CoinToss(settings.brainCreateNewLinkChance))
        {
            AddNewLink(settings);
        }

        if (RandomStatics.CoinToss(settings.brainCreateNewHiddenNodeChance))
        {
            AddNewHiddenNeuron();
        }

        var newNeurons = GetNewlyUnlockedNeurons(bodyGenome);

        //Debug.Log($"Initializing axons with {newNeurons.Count} new neurons from " +
        //          $"{bodyGenome.newlyUnlockedNeuronInfo.Count} new tech.");
        foreach (var neuron in newNeurons)
        {
            SortIONeuron(neuron);
            LinkNeuronToLayer(neuron);
        }
        //RemoveVestigialLinks();
    }
Пример #21
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);
    }
Пример #22
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;
    }
Пример #23
0
    List <MetaNeuron> GetNewlyUnlockedNeurons(BodyGenome parent)
    {
        var newTech = new List <TechElement>();

        foreach (var tech in unlockedTech.values)
        {
            if (!parent.unlockedTech.Contains(tech))
            {
                newTech.Add(tech);
            }
        }

        var newMetaNeurons = new List <MetaNeuron>();

        foreach (var tech in newTech)
        {
            foreach (var unlock in tech.unlocks)
            {
                newMetaNeurons.Add(unlock);
            }
        }

        return(newMetaNeurons);
    }
Пример #24
0
 public void InitializeBodyNeurons(BodyGenome bodyGenome)
 {
     for (int i = 0; i < bodyGenome.atmosphereSensorList.Count; i++)
     {
         bodyGenome.atmosphereSensorList[i].InitializeBrainGenome(bodyNeuronList);
     }
     for (int i = 0; i < bodyGenome.basicWheelList.Count; i++)
     {
         bodyGenome.basicWheelList[i].InitializeBrainGenome(bodyNeuronList); // Creates Neurons based on this Module and adds them to provided List
     }
     for (int i = 0; i < bodyGenome.basicJointList.Count; i++)
     {
         bodyGenome.basicJointList[i].InitializeBrainGenome(bodyNeuronList);
     }
     for (int i = 0; i < bodyGenome.contactSensorList.Count; i++)
     {
         bodyGenome.contactSensorList[i].InitializeBrainGenome(bodyNeuronList);
     }
     for (int i = 0; i < bodyGenome.gravitySensorList.Count; i++)
     {
         bodyGenome.gravitySensorList[i].InitializeBrainGenome(bodyNeuronList);
     }
     for (int i = 0; i < bodyGenome.healthModuleList.Count; i++)
     {
         bodyGenome.healthModuleList[i].InitializeBrainGenome(bodyNeuronList);
     }
     for (int i = 0; i < bodyGenome.oscillatorInputList.Count; i++)
     {
         bodyGenome.oscillatorInputList[i].InitializeBrainGenome(bodyNeuronList);
     }
     for (int i = 0; i < bodyGenome.raycastSensorList.Count; i++)
     {
         bodyGenome.raycastSensorList[i].InitializeBrainGenome(bodyNeuronList);
     }
     for (int i = 0; i < bodyGenome.shieldList.Count; i++)
     {
         bodyGenome.shieldList[i].InitializeBrainGenome(bodyNeuronList);
     }
     for (int i = 0; i < bodyGenome.targetSensorList.Count; i++)
     {
         bodyGenome.targetSensorList[i].InitializeBrainGenome(bodyNeuronList);
     }
     for (int i = 0; i < bodyGenome.thrusterList.Count; i++)
     {
         bodyGenome.thrusterList[i].InitializeBrainGenome(bodyNeuronList);
     }
     for (int i = 0; i < bodyGenome.torqueList.Count; i++)
     {
         bodyGenome.torqueList[i].InitializeBrainGenome(bodyNeuronList);
     }
     for (int i = 0; i < bodyGenome.valueInputList.Count; i++)
     {
         bodyGenome.valueInputList[i].InitializeBrainGenome(bodyNeuronList);
     }
     for (int i = 0; i < bodyGenome.weaponProjectileList.Count; i++)
     {
         bodyGenome.weaponProjectileList[i].InitializeBrainGenome(bodyNeuronList);
     }
     for (int i = 0; i < bodyGenome.weaponTazerList.Count; i++)
     {
         bodyGenome.weaponTazerList[i].InitializeBrainGenome(bodyNeuronList);
     }
 }
Пример #25
0
 public void InitializeRandomBrainGenome(BodyGenome bodyGenome, float initialWeightMultiplier)
 {
     InitializeNewBrainGenomeLists();
     InitializeBodyNeurons(bodyGenome);
     InitializeAxons(initialWeightMultiplier);
 }
Пример #26
0
    public void CopyBodyGenomeFromTemplate(BodyGenome templateGenome)
    {
        // This method creates a clone of the provided BodyGenome - should have no shared references!!!

        bodyType = templateGenome.bodyType;
        // copy module lists:
        atmosphereSensorList = new List <AtmosphereSensorGenome>();
        for (int i = 0; i < templateGenome.atmosphereSensorList.Count; i++)
        {
            AtmosphereSensorGenome genomeCopy = new AtmosphereSensorGenome(templateGenome.atmosphereSensorList[i]);
            atmosphereSensorList.Add(genomeCopy);
        }
        basicJointList = new List <BasicJointGenome>();
        for (int i = 0; i < templateGenome.basicJointList.Count; i++)
        {
            BasicJointGenome genomeCopy = new BasicJointGenome(templateGenome.basicJointList[i]);
            basicJointList.Add(genomeCopy);
        }
        basicWheelList = new List <BasicWheelGenome>();
        for (int i = 0; i < templateGenome.basicWheelList.Count; i++)
        {
            BasicWheelGenome genomeCopy = new BasicWheelGenome(templateGenome.basicWheelList[i]);
            basicWheelList.Add(genomeCopy);
        }
        contactSensorList = new List <ContactGenome>();
        for (int i = 0; i < templateGenome.contactSensorList.Count; i++)
        {
            ContactGenome genomeCopy = new ContactGenome(templateGenome.contactSensorList[i]);
            contactSensorList.Add(genomeCopy);
        }
        gravitySensorList = new List <GravitySensorGenome>();
        for (int i = 0; i < templateGenome.gravitySensorList.Count; i++)
        {
            GravitySensorGenome genomeCopy = new GravitySensorGenome(templateGenome.gravitySensorList[i]);
            gravitySensorList.Add(genomeCopy);
        }
        healthModuleList = new List <HealthGenome>();
        for (int i = 0; i < templateGenome.healthModuleList.Count; i++)
        {
            HealthGenome genomeCopy = new HealthGenome(templateGenome.healthModuleList[i]);
            healthModuleList.Add(genomeCopy);
        }
        oscillatorInputList = new List <OscillatorGenome>();
        for (int i = 0; i < templateGenome.oscillatorInputList.Count; i++)
        {
            OscillatorGenome genomeCopy = new OscillatorGenome(templateGenome.oscillatorInputList[i]);
            oscillatorInputList.Add(genomeCopy);
        }
        raycastSensorList = new List <RaycastSensorGenome>();
        for (int i = 0; i < templateGenome.raycastSensorList.Count; i++)
        {
            RaycastSensorGenome genomeCopy = new RaycastSensorGenome(templateGenome.raycastSensorList[i]);
            raycastSensorList.Add(genomeCopy);
        }
        shieldList = new List <ShieldGenome>();
        for (int i = 0; i < templateGenome.shieldList.Count; i++)
        {
            ShieldGenome genomeCopy = new ShieldGenome(templateGenome.shieldList[i]);
            shieldList.Add(genomeCopy);
        }
        targetSensorList = new List <TargetSensorGenome>();
        for (int i = 0; i < templateGenome.targetSensorList.Count; i++)
        {
            TargetSensorGenome genomeCopy = new TargetSensorGenome(templateGenome.targetSensorList[i]);
            targetSensorList.Add(genomeCopy);
        }
        thrusterList = new List <ThrusterGenome>();
        for (int i = 0; i < templateGenome.thrusterList.Count; i++)
        {
            ThrusterGenome genomeCopy = new ThrusterGenome(templateGenome.thrusterList[i]);
            thrusterList.Add(genomeCopy);
        }
        torqueList = new List <TorqueGenome>();
        for (int i = 0; i < templateGenome.torqueList.Count; i++)
        {
            TorqueGenome genomeCopy = new TorqueGenome(templateGenome.torqueList[i]);
            torqueList.Add(genomeCopy);
        }
        trajectorySensorList = new List <TrajectorySensorGenome>();
        for (int i = 0; i < templateGenome.trajectorySensorList.Count; i++)
        {
            TrajectorySensorGenome genomeCopy = new TrajectorySensorGenome(templateGenome.trajectorySensorList[i]);
            trajectorySensorList.Add(genomeCopy);
        }
        valueInputList = new List <ValueInputGenome>();
        for (int i = 0; i < templateGenome.valueInputList.Count; i++)
        {
            ValueInputGenome genomeCopy = new ValueInputGenome(templateGenome.valueInputList[i]);
            valueInputList.Add(genomeCopy);
        }
        weaponProjectileList = new List <WeaponProjectileGenome>();
        for (int i = 0; i < templateGenome.weaponProjectileList.Count; i++)
        {
            WeaponProjectileGenome genomeCopy = new WeaponProjectileGenome(templateGenome.weaponProjectileList[i]);
            weaponProjectileList.Add(genomeCopy);
        }
        weaponTazerList = new List <WeaponTazerGenome>();
        for (int i = 0; i < templateGenome.weaponTazerList.Count; i++)
        {
            WeaponTazerGenome genomeCopy = new WeaponTazerGenome(templateGenome.weaponTazerList[i]);
            weaponTazerList.Add(genomeCopy);
        }
    }
Пример #27
0
 public void InitializeBodyGenomeFromTemplate(BodyGenome bodyGenomeTemplate)
 {
     bodyGenome.CopyBodyGenomeFromTemplate(bodyGenomeTemplate);
 }
Пример #28
0
 public void InitializeIONeurons(BodyGenome bodyGenome)
 {
     bodyGenome.InitializeBrainGenome(inOutNeurons);
     SortIONeurons();
 }
Пример #29
0
 public BrainGenome(BrainGenome parentGenome, BodyGenome bodyGenome, MutationSettingsInstance mutationSettings)
 {
     SetToMutatedCopyOfParentGenome(parentGenome, bodyGenome, mutationSettings);
 }
Пример #30
0
 void ConstructRandom(float initialConnectionDensity, int hiddenNeuronCount)
 {
     bodyGenome  = new BodyGenome();
     brainGenome = new BrainGenome(bodyGenome, initialConnectionDensity, hiddenNeuronCount);
 }