Esempio n. 1
0
    public AgentGenome GetGenomeFromFitnessLottery()
    {
        int numCandidates = leaderboardGenomesList.Count;
        float[] rankedFitnessScoresArray = new float[numCandidates];
        int[] rankedIndicesList = new int[numCandidates];
        float totalFitness = 0f;

        //string leaderboardGenomesListString = "LEADERBOARD GENOMES (" + speciesID.ToString() + ")";
        // Rank current leaderBoard list based on score
        for (int i = 0; i < numCandidates; i++) {
            float fitnessScore = 0.00001f;
            fitnessScore += leaderboardGenomesList[i].performanceData.totalTicksAlive;
            rankedFitnessScoresArray[i] = fitnessScore;
            rankedIndicesList[i] = i;
            totalFitness += fitnessScore;

            //leaderboardGenomesListString += "\n#" + i.ToString() + ", score= " + fitnessScore.ToString();
        }
        //Debug.Log(leaderboardGenomesListString);

        // Sort By Fitness
        for (int i = 0; i < numCandidates - 1; i++)
        {
            for (int j = 0; j < numCandidates - 1; j++)
            {
                float swapFitA = rankedFitnessScoresArray[j];
                float swapFitB = rankedFitnessScoresArray[j + 1];
                int swapIdA = rankedIndicesList[j];
                int swapIdB = rankedIndicesList[j + 1];

                // bigger is better now after inversion
                if (swapFitA < swapFitB)
                {
                    rankedFitnessScoresArray[j] = swapFitB;
                    rankedFitnessScoresArray[j + 1] = swapFitA;
                    rankedIndicesList[j] = swapIdB;
                    rankedIndicesList[j + 1] = swapIdA;
                }
            }
        }

        int selectedIndex = 0;

        // generate random lottery value between 0f and totalFitness:
        float lotteryValue = Random.Range(0f, totalFitness);
        float currentValue = 0f;
        for (int i = 0; i < numCandidates; i++) {
            if (lotteryValue >= currentValue && lotteryValue < (currentValue + rankedFitnessScoresArray[i])) {
                // Jackpot!
                selectedIndex = rankedIndicesList[i];
                //Debug.Log("Selected: " + selectedIndex.ToString() + "! (" + i.ToString() + ") fit= " + currentValue.ToString() + "--" + (currentValue + (1f - rankedFitnessList[i])).ToString() + " / " + totalFitness.ToString() + ", lotto# " + lotteryValue.ToString() + ", fit= " + (1f - rankedFitnessList[i]).ToString());
            }
            currentValue += rankedFitnessScoresArray[i]; // add this agent's fitness to current value for next check
        }
        //return selectedIndex;
        // choose genome by lottery
        AgentGenome parentGenome = leaderboardGenomesList[selectedIndex].candidateGenome;

        return parentGenome;
    }
Esempio n. 2
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);
    }
Esempio n. 3
0
    // WPP: empty constructor is redundant, compiler creates this by default
    //public MasterGenomePool() { }

    public void FirstTimeInitialize(MutationSettingsInstance mutationSettings)
    {
        debugRecentlyDeletedCandidateIDsList = new List <int>();

        nextCandidateIndex           = 0;
        this.mutationSettings        = mutationSettings;
        currentlyActiveSpeciesIDList = new List <int>();
        completeSpeciesPoolsList     = new List <SpeciesGenomePool>();

        //SpeciesGenomePool rootSpecies = new SpeciesGenomePool(0, -1, 0, 0, mutationSettingsRef);
        //rootSpecies.FirstTimeInitializeROOT(numAgentGenomes, 0);
        //currentlyActiveSpeciesIDList.Add(0);
        //completeSpeciesPoolsList.Add(rootSpecies);

        for (int i = 0; i < numInitSpecies; i++)
        {
            //float lerpV = Mathf.Clamp01((i + 0.1f) / (numInitSpecies + 1) + 0.06f) * 0.8f + 0.1f;
            //float lerpV = 0.5f;

            SpeciesGenomePool newSpecies = new SpeciesGenomePool(i, -1, 0, 0, mutationSettings);
            AgentGenome       seedGenome = new AgentGenome(mutationSettings.brainInitialConnectionChance, simulation.numInitialHiddenNeurons);

            newSpecies.FirstTimeInitialize(new CandidateAgentData(seedGenome, i), 0);
            currentlyActiveSpeciesIDList.Add(i);
            completeSpeciesPoolsList.Add(newSpecies);
        }

        selectionManager.SetSelected(completeSpeciesPoolsList[0].candidateGenomesList[0]);
    }
Esempio n. 4
0
    public void InitializeModules(AgentGenome genome, Agent agent, StartPositionGenome startPos)
    {
        testModule = new TestModule();
        testModule.Initialize(genome.bodyGenome.testModuleGenome, agent, startPos);


        /*
         * healthModuleList = new List<HealthModule>();
         * valueList = new List<InputValue>();
         *
         * for (int i = 0; i < genome.bodyGenome.healthModuleList.Count; i++) {
         *  HealthModule healthModule = new HealthModule();
         *  //agent.segmentList[genome.healthModuleList[i].parentID].AddComponent<HealthModuleComponent>();
         *  healthModule.Initialize(genome.bodyGenome.healthModuleList[i], agent);
         *  healthModuleList.Add(healthModule);
         *  //healthModuleList[i].Initialize(genome.healthModuleList[i]);
         * }
         * for (int i = 0; i < genome.bodyGenome.valueInputList.Count; i++) {
         *  InputValue inputValue = new InputValue();
         *  inputValue.Initialize(genome.bodyGenome.valueInputList[i], agent);
         *  valueList.Add(inputValue);
         *  //valueList[i].Initialize(genome.valueInputList[i]);
         * }
         */
    }
Esempio n. 5
0
    public LinkGenome GetLeaderboardLinkGenome(int index, int linkedListIndex)
    {
        AgentGenome genome = GetLeaderboardGenome(index);

        if (genome.brainGenome.linkCount > linkedListIndex)
            return null;

        return genome.brainGenome.links[linkedListIndex];
    }
 public void AddNewHistoricalRepresentative(AgentGenome newGenome)
 {
     if (historicGenomePool.Count >= maxHistoricGenomePoolSize)    // Hit max number of stored genomes
     {
         int randRemoveIndex = Mathf.RoundToInt(UnityEngine.Random.Range(0f, (float)historicGenomePool.Count - 1f));
         historicGenomePool.RemoveAt(randRemoveIndex); // remove an existing member of the list at random to make room for new genome
     }
     historicGenomePool.Add(newGenome);
 }
Esempio n. 7
0
    private void CreateSpeciesIcon(SpeciesGenomePool pool)
    {
        AgentGenome templateGenome = masterGenomePool.completeSpeciesPoolsList[pool.speciesID].leaderboardGenomesList[0].candidateGenome;
        Color       color          = new Color(templateGenome.bodyGenome.appearanceGenome.huePrimary.x, templateGenome.bodyGenome.appearanceGenome.huePrimary.y, templateGenome.bodyGenome.appearanceGenome.huePrimary.z);

        var icon = Instantiate(prefabSpeciesIcon).GetComponent <SpeciesIconUI>();

        icon.Initialize(speciesIcons.Count - 1, masterGenomePool.completeSpeciesPoolsList[pool.speciesID], anchor, color);
        speciesIcons.Add(icon);
    }
Esempio n. 8
0
    private void BeginLifeStageGrowing(Agent parent, AgentGenome parentGenome, Vector3 startPos)
    {
        curLifeStage = EggLifeStage.Growing;
        lifeStageTransitionTimeStepCounter = 0;
        parentAgent           = parent;
        birthTimeStepsCounter = 0;

        curNumEggs            = maxNumEggs;
        developmentProgress   = 0f;
        growthScaleNormalized = 0.01f;
        decayStatus           = 0f;

        rigidbodyRef.mass            = 5f;
        rigidbodyRef.velocity        = Vector2.zero;
        rigidbodyRef.angularVelocity = 0f;
        rigidbodyRef.drag            = 7.5f;
        rigidbodyRef.angularDrag     = 1.5f;

        isProtectedByParent = parent;
        isAttachedBySpring  = parent;

        if (!parent)
        {
            transform.localPosition = startPos;

            // REVISIT THIS:
            var   parentBoundingBox = parentGenome.bodyGenome.GetFullsizeBoundingBox();
            float parentScale       = (parentBoundingBox.x + parentBoundingBox.y) * 0.5f;
            fullSize.x = parentScale;  // golden ratio? // easter egg for math nerds?
            fullSize.y = parentScale;
        }
        else
        {
            //currentBiomass = 0.05f;
            //parentAgentRef.currentBiomass -= 0.05f; // *** Handled within agent initPregnancy
            rigidbodyRef.transform.position = parent.bodyRigidbody.position;

            fixedJoint.connectedBody = parent.bodyRigidbody;
            fixedJoint.autoConfigureConnectedAnchor = false;
            fixedJoint.anchor          = new Vector2(0f, parent.fullSizeBoundingBox.y * 0.25f);
            fixedJoint.connectedAnchor = new Vector2(0f, parent.fullSizeBoundingBox.y * -0.25f);
            fixedJoint.enableCollision = false;
            fixedJoint.enabled         = true;
            fixedJoint.frequency       = springJointMaxStrength;
        }

        mainCollider.enabled = true;

        isDepleted  = false;
        isBeingBorn = false;
        prevPos     = transform.position;

        UpdateEggSackSize(0.05f, true);
    }
Esempio n. 9
0
    public void Refresh()
    {
        genome = cand.candidateGenome;
        brain  = genome.brainGenome;
        core   = genome.bodyGenome.coreGenome;

        float lifespan = cand.performanceData.totalTicksAlive;

        textGeneration.text = "Gen: " + genome.generationCount;
        textBodySize.text   = "Size: " + (100f * core.creatureBaseLength).ToString("F0") + ", Aspect 1:" + (1f / core.creatureAspectRatio).ToString("F0");
        textBrainSize.text  = "Brain Size: " + brain.inOutNeurons.Count + "--" + brain.links.Count;
    }
Esempio n. 10
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();
    }
Esempio n. 11
0
    public void InitializeEggSackFromGenome(int index, AgentGenome agentGenome, Agent parentAgent, Vector3 startPos)
    {
        //currentBiomass = 0.01f; // immaculate eggsacks given free mass?

        if (parentAgent)
        {
            parentAgentIndex = parentAgent.index;
        }

        this.index = index;
        fullSize   = Vector2.one * (agentGenome.bodyGenome.GetFullsizeBoundingBox().x + agentGenome.bodyGenome.GetFullsizeBoundingBox().y) * 0.5f; // new Vector2(agentGenome.bodyGenome.fullsizeBoundingBox.x, agentGenome.bodyGenome.fullsizeBoundingBox.y) * 1f;

        BeginLifeStageGrowing(parentAgent, agentGenome, startPos);
    }
Esempio n. 12
0
    public CritterModuleMovement(AgentGenome agentGenome)
    {
        ownVelX    = new float[1];
        ownVelY    = new float[1];
        facingDirX = new float[1];
        facingDirY = new float[1];
        throttleX  = new float[1];
        throttleY  = new float[1];
        dash       = new float[1];

        float invAspectRatio = agentGenome.bodyGenome.coreGenome.creatureAspectRatio;

        speedBonus = Mathf.Lerp(0.7f, 1.4f, 1f - invAspectRatio);
    }
Esempio n. 13
0
    public void InitializeAgentFromTemplate(AgentGenome genome, StartPositionGenome startPos)
    {
        // Initialize Modules --
        //Debug.Log("Agent Initialize Modules() segment count: " + segmentList.Count.ToString() + ", visCount: " + visibleObjectList.Count.ToString());
        // -- Setup that used to be done in the constructors
        InitializeModules(genome, this, startPos);

        // Visible/Non-Visible:
        //if (isVisible) {
        //    for (int i = 0; i < visibleObjectList.Count; i++) {
        //        visibleObjectList[i].SetActive(true);
        //    }
        //}
        // Construct Brain:
        brain = new Brain(genome.brainGenome, this);
    }
Esempio n. 14
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);
    }
    private void InitializeCritter()
    {
        // Delete existing children GameObjects:
        foreach (Transform child in transform)
        {
            Destroy(child.gameObject);
        }

        // Create dummy genome
        testAgentGenome = new AgentGenome(0f, 0);

        // Create container Agent:
        GameObject agentGO = new GameObject("Agent" + 0);

        agentGO.transform.parent = transform;
        testAgent = agentGO.AddComponent <Agent>();

        //testAgent.humanControlLerp = 1f;
        //testAgent.humanControlled = true;

        //testAgentGenome.bodyGenome.coreGenome.numSegments = numSegments;
        //testAgentGenome.bodyGenome.coreGenome.fullBodyLength = bodyLength;

        testAgent.speed = speed;

        /*
         * testAgent.frequency = frequency;
         * testAgent.amplitude = amplitude;
         * testAgent.offsetDelay = offsetDelay;
         * testAgent.headDrag = headDrag;
         * testAgent.bodyDrag = bodyDrag;
         * testAgent.headMass = headMass;
         * testAgent.bodyMass = bodyMass;
         * testAgent.jointSpeed = jointSpeed;
         * testAgent.jointMaxTorque = jointMaxTorque;
         * testAgent.swimAnimationCycleSpeed = swimAnimationCycleSpeed;
         * testAgent.smoothedThrottleLerp = smoothedThrottleLerp;
         * testAgent.restingJointTorque = restingJointTorque;
         * testAgent.bendRatioHead = bendRatioHead;
         * testAgent.bendRatioTailTip = bendRatioTailTip;
         */
        // initialize Agent based on genome:
        //StartPositionGenome startPosGenome = new StartPositionGenome(Vector3.zero, Quaternion.identity);
        //testAgent.InitializeAgentFromGenome(0, testAgentGenome, startPosGenome);  // This also rebuilds GameObjects
    }
Esempio n. 16
0
    public CandidateAgentData(AgentGenome genome, int speciesID)
    {
        //Debug.Log("NewCandidateData: " + MasterGenomePool.nextCandidateIndex.ToString());
        MasterGenomePool.nextCandidateIndex++;
        causeOfDeath            = "Alive!";
        candidateID             = MasterGenomePool.nextCandidateIndex;
        this.speciesID          = speciesID;
        candidateGenome         = genome;
        numCompletedEvaluations = 0;
        //evaluationScoresList = new List<float>();
        allEvaluationsComplete = false;
        isBeingEvaluated       = false;

        //name = GenerateTempCritterName();

        candidateEventDataList = new List <CandidateEventData>();
        performanceData        = new PerformanceData();
    }
Esempio n. 17
0
    // static helper methods :::: ?

    public static BrushPoint ProcessBrushPoint(BrushPoint inPoint, AgentGenome genome)
    {
        ProcessBrushPointBaseBody(ref inPoint, genome); // basic proportions

        // calculate normals & stuff:
        // Smooth & fix overly jagged/weird spots/shapes:

        // Colors?

        // Extras:
        // fins, etc.


        // OLD:
        //Vector2 CSScale = GetInitCrossSectionScale(inPoint.initCoordsNormalized.z, genome);
        //Vector3 bindPos = new Vector3(inPoint.initCoordsNormalized.x * CSScale.x, inPoint.initCoordsNormalized.y * CSScale.y, inPoint.initCoordsNormalized.z * fullsizeCritterLength - fullsizeCritterLength * 0.5f); //coords;
        //inPoint.bindPos = bindPos;
        return(inPoint);
    }
Esempio n. 18
0
    public void PrepareTournament(AgentGenome playerGenome)
    {
        List <EnvironmentGenome> environmentGenomeList = new List <EnvironmentGenome>();
        List <AgentGenome>       competitorGenomeList  = new List <AgentGenome>();

        // Load environments and competitors?
        for (int e = 0; e < environmentsFileList.Count; e++)
        {
            string            path       = Application.dataPath + "/IndividualSaves/Environments/" + environmentsFileList[e] + ".json";
            string            dataAsJson = File.ReadAllText(path);
            EnvironmentGenome genome     = JsonUtility.FromJson <EnvironmentGenome>(dataAsJson);
            environmentGenomeList.Add(genome);
        }
        // might need to check for null!
        if (competitorsFileList != null)
        {
            // Load competitor Agent Genomes!
            for (int a = 0; a < competitorsFileList.Count; a++)
            {
                string      path       = Application.dataPath + "/IndividualSaves/Agents/" + competitorsFileList[a] + ".json";
                string      dataAsJson = File.ReadAllText(path);
                AgentGenome genome     = JsonUtility.FromJson <AgentGenome>(dataAsJson);
                competitorGenomeList.Add(genome);
            }
        }

        // Fill in Rounds & Matchups!
        this.winnerID           = -1;
        this.tournamentFinished = false;
        for (int i = 0; i < tournamentRoundList.Count; i++)
        {
            tournamentRoundList[i].winnerID      = -1;
            tournamentRoundList[i].roundFinished = false;
            for (int j = 0; j < tournamentRoundList[i].matchupList.Count; j++)
            {
                // Creates and fills in EvaluationTicket for this matchup with actual Genomes (before it was just coded with IDs)
                tournamentRoundList[i].matchupList[j].PrepareMatchup(environmentGenomeList, competitorGenomeList, playerGenome, (numOpponents + 1), tournamentRoundList[i].maxTimeSteps);
            }
        }
    }
Esempio n. 19
0
    private string GetTextAgentBrain()
    {
        string txt      = "";
        int    focusPop = gameManager.trainerRef.evaluationManager.exhibitionTicketList[gameManager.trainerRef.evaluationManager.exhibitionTicketCurrentIndex].focusPopIndex;

        if (focusPop > 0)
        {
            AgentGenome currentAgentGenome = gameManager.trainerRef.evaluationManager.exhibitionTicketList[gameManager.trainerRef.evaluationManager.exhibitionTicketCurrentIndex].agentGenomesList[gameManager.trainerRef.evaluationManager.exhibitionTicketList[gameManager.trainerRef.evaluationManager.exhibitionTicketCurrentIndex].focusPopIndex - 1];
            Agent       currentAgent       = gameManager.trainerRef.evaluationManager.exhibitionInstance.currentAgentsArray[gameManager.trainerRef.evaluationManager.exhibitionTicketList[gameManager.trainerRef.evaluationManager.exhibitionTicketCurrentIndex].focusPopIndex - 1];
            // AGENT:

            // Index:
            txt += "Player: " + gameManager.trainerRef.evaluationManager.exhibitionTicketList[gameManager.trainerRef.evaluationManager.exhibitionTicketCurrentIndex].focusPopIndex.ToString();
            txt += ", Genome: " + currentAgentGenome.index.ToString() + "\n";
            txt += "Genome BodyNeurons: " + currentAgentGenome.brainGenome.bodyNeuronList.Count.ToString() + "\n";
            txt += "Genome HiddenNeurons: " + currentAgentGenome.brainGenome.hiddenNeuronList.Count.ToString() + "\n";
            txt += "Genome Links: " + currentAgentGenome.brainGenome.linkList.Count.ToString() + "\n";
            txt += "Agent: \n";
            txt += "Neurons: " + currentAgent.brain.neuronList.Count.ToString() + "\n";
            txt += "Axons: " + currentAgent.brain.axonList.Count.ToString() + "\n";
            //txt += "Genome Links: " + currentAgentGenome.brainGenome.linkList.Count.ToString() + "\n";

            // Brain List:
            txt += "\nNeurons:\n";
            for (int i = 0; i < currentAgent.brain.neuronList.Count; i++)
            {
                txt += "Neuron[" + i.ToString() + "] (" + currentAgent.brain.neuronList[i].neuronType.ToString() + ") prevVal: " + currentAgent.brain.neuronList[i].previousValue.ToString() + " || curVal: " + currentAgent.brain.neuronList[i].currentValue[0].ToString() + " || inputTotal: " + currentAgent.brain.neuronList[i].inputTotal.ToString() + "\n";
            }
            txt += "\nAxons:\n";
            for (int i = 0; i < currentAgent.brain.axonList.Count; i++)
            {
                txt += "Axon[" + i.ToString() + "] (" + currentAgent.brain.axonList[i].weight.ToString() + ") from: " + currentAgent.brain.axonList[i].fromID.ToString() + " to: " + currentAgent.brain.axonList[i].toID.ToString() + "\n";
            }
        }



        return(txt);
    }
Esempio n. 20
0
    private string GetTextAgentBrainGenome()
    {
        string txt      = "";
        int    focusPop = gameManager.trainerRef.evaluationManager.exhibitionTicketList[gameManager.trainerRef.evaluationManager.exhibitionTicketCurrentIndex].focusPopIndex;

        if (focusPop > 0)
        {
            AgentGenome currentAgentGenome = gameManager.trainerRef.evaluationManager.exhibitionTicketList[gameManager.trainerRef.evaluationManager.exhibitionTicketCurrentIndex].agentGenomesList[gameManager.trainerRef.evaluationManager.exhibitionTicketList[gameManager.trainerRef.evaluationManager.exhibitionTicketCurrentIndex].focusPopIndex - 1];
            //Agent currentAgent = gameManager.trainerRef.evaluationManager.exhibitionInstance.currentAgentsArray[gameManager.trainerRef.evaluationManager.exhibitionTicketList[gameManager.trainerRef.evaluationManager.exhibitionTicketCurrentIndex].focusPopIndex - 1];
            // AGENT:

            // Index:
            txt += "Player: " + gameManager.trainerRef.evaluationManager.exhibitionTicketList[gameManager.trainerRef.evaluationManager.exhibitionTicketCurrentIndex].focusPopIndex.ToString();
            txt += ", Genome: " + currentAgentGenome.index.ToString() + "\n";
            txt += "Genome BodyNeurons: " + currentAgentGenome.brainGenome.bodyNeuronList.Count.ToString() + "\n";
            txt += "Genome HiddenNeurons: " + currentAgentGenome.brainGenome.hiddenNeuronList.Count.ToString() + "\n";
            txt += "Genome Links: " + currentAgentGenome.brainGenome.linkList.Count.ToString() + "\n";

            // Brain List:
            txt += "\nBodyNeurons:\n";
            for (int i = 0; i < currentAgentGenome.brainGenome.bodyNeuronList.Count; i++)
            {
                txt += "Neuron[" + i.ToString() + "] (" + currentAgentGenome.brainGenome.bodyNeuronList[i].neuronType.ToString() + ") NID Module#: " + currentAgentGenome.brainGenome.bodyNeuronList[i].nid.moduleID.ToString() + ", NID Neuron#: " + currentAgentGenome.brainGenome.bodyNeuronList[i].nid.neuronID.ToString() + "\n";
            }
            txt += "\nHiddenNeurons:\n";
            for (int i = 0; i < currentAgentGenome.brainGenome.hiddenNeuronList.Count; i++)
            {
                txt += "Neuron[" + i.ToString() + "] (" + currentAgentGenome.brainGenome.hiddenNeuronList[i].neuronType.ToString() + ") NID Module#: " + currentAgentGenome.brainGenome.hiddenNeuronList[i].nid.moduleID.ToString() + ", NID Neuron#: " + currentAgentGenome.brainGenome.hiddenNeuronList[i].nid.neuronID.ToString() + "\n";
            }
            txt += "\nLinks:\n";
            for (int i = 0; i < currentAgentGenome.brainGenome.linkList.Count; i++)
            {
                txt += "Link[" + i.ToString() + "] (" + currentAgentGenome.brainGenome.linkList[i].weight.ToString() + ") FROM NID: [" + currentAgentGenome.brainGenome.linkList[i].fromModuleID.ToString() + ", " + currentAgentGenome.brainGenome.linkList[i].fromNeuronID.ToString() + "] --> TO NID: [" + currentAgentGenome.brainGenome.linkList[i].toModuleID.ToString() + ", " + currentAgentGenome.brainGenome.linkList[i].toNeuronID.ToString() + "]\n";
            }
        }


        return(txt);
    }
Esempio n. 21
0
    public void RepopulateBaselineGenomes()
    {
        if (baselineGenomePool == null)
        {
            baselineGenomePool = new List <AgentGenome>();
        }
        else
        {
            baselineGenomePool.Clear();
        }


        for (int j = 0; j < numBaseline; j++)
        {
            AgentGenome baselineGenome = new AgentGenome(j);
            baselineGenome.InitializeBodyGenomeFromTemplate(bodyGenomeTemplate);
            float increment   = (float)j / (float)(numBaseline - 1);
            float weightScale = 0f; // how much to scale initial random weights
            baselineGenome.InitializeRandomBrainFromCurrentBody(increment * (float)j * weightScale);
            baselineGenomePool.Add(baselineGenome);
        }
    }
Esempio n. 22
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);
    }
Esempio n. 23
0
    public void FirstTimeInitialize(CandidateAgentData foundingGenome, int depth)
    {
        foundingCandidate = foundingGenome;
        longestLivedCandidate = foundingGenome;
        mostEatenCandidate = foundingGenome;

        InitShared();
        depthLevel = depth;
        Vector3 newHue = Random.insideUnitSphere;

        foundingGenome.candidateGenome.name = MutateName(foundingGenome.candidateGenome.name);
        foundingGenome.candidateGenome.bodyGenome.appearanceGenome.BlendHue(newHue, 0.75f);

        //string debugTxt = "";
        for (int i = 0; i < 16; i++) {
            AgentGenome agentGenome = Mutate(foundingGenome.candidateGenome, true, true);

            CandidateAgentData candidate = new CandidateAgentData(agentGenome, speciesID);
            candidateGenomesList.Add(candidate);
            leaderboardGenomesList.Add(candidate);
            //debugTxt += "" + candidate.candidateGenome.brainGenome.linkList[0].weight.ToString("F2") + "  ";
        }
        //Debug.Log("SPECIES CREATED! " + debugTxt);
        representativeCandidate = foundingGenome;

        coatOfArmsMat = new Material(TheRenderKing.instance.coatOfArmsShader);
        //coatOfArmsTex = TheRenderKing.instance.GenerateSpeciesCoatOfArms(foundingGenome.candidateGenome.bodyGenome.appearanceGenome);
        coatOfArmsMat.SetPass(0);
        coatOfArmsMat.SetTexture("_MainTex", TheRenderKing.instance.shapeTex);
        coatOfArmsMat.SetTexture("_PatternTex", TheRenderKing.instance.patternTex);
        coatOfArmsMat.SetFloat("_PatternX", foundingGenome.candidateGenome.bodyGenome.appearanceGenome.bodyStrokeBrushTypeX);
        coatOfArmsMat.SetFloat("_PatternX", foundingGenome.candidateGenome.bodyGenome.appearanceGenome.bodyStrokeBrushTypeY);
        Vector3 huePri = foundingGenome.candidateGenome.bodyGenome.appearanceGenome.huePrimary;
        Vector3 hueSec = foundingGenome.candidateGenome.bodyGenome.appearanceGenome.hueSecondary;
        coatOfArmsMat.SetColor("_TintPri", new Color(huePri.x, huePri.y, huePri.z));
        coatOfArmsMat.SetColor("_TintSec", new Color(hueSec.x, hueSec.y, hueSec.z));
        coatOfArmsMat.SetFloat("_IsSelected", 0f);
    }
Esempio n. 24
0
    private string GetTextAgentModules()
    {
        string txt = "";

        if (gameManager.trainerRef.evaluationManager.exhibitionTicketList[gameManager.trainerRef.evaluationManager.exhibitionTicketCurrentIndex].focusPopIndex < 1)
        {
            // ENVIRONMENT:
            //EnvironmentGenome currentEnvironmentGenome = trainerRef.teamsConfig.environmentPopulation.environmentGenomeList[trainerRef.evaluationManager.exhibitionTicketList[trainerRef.evaluationManager.exhibitionTicketCurrentIndex].genomeIndices[0]];
            EnvironmentGenome currentEnvironmentGenome = gameManager.trainerRef.evaluationManager.exhibitionTicketList[gameManager.trainerRef.evaluationManager.exhibitionTicketCurrentIndex].environmentGenome;
            txt += "Environment Genome: " + currentEnvironmentGenome.index + "\n\n";
            if (currentEnvironmentGenome.useAtmosphere)
            {
                txt += "ATMOSPHERE\nWind: " + currentEnvironmentGenome.atmosphereGenome.windForce.ToString();
                //txt += "\n";
            }
            if (currentEnvironmentGenome.useBasicObstacles)
            {
                txt += "\nOBSTACLES ON\n";
            }
            if (currentEnvironmentGenome.useMeteorites)
            {
                txt += "\nMETEORITES ON\n";
            }
            if (currentEnvironmentGenome.useTargetColumn)
            {
                txt += "\nTARGET LOCATION ON\n";
            }
            if (currentEnvironmentGenome.terrainGenome.useAltitude)
            {
                txt += "\nALTITUDE ON\n";
            }
        }
        else
        {
            // AGENT:
            //AgentGenome currentAgentGenome = trainerRef.teamsConfig.playersList[trainerRef.evaluationManager.exhibitionTicketList[trainerRef.evaluationManager.exhibitionTicketCurrentIndex].focusPopIndex - 1].agentGenomeList[trainerRef.evaluationManager.exhibitionTicketList[trainerRef.evaluationManager.exhibitionTicketCurrentIndex].genomeIndices[trainerRef.evaluationManager.exhibitionTicketList[trainerRef.evaluationManager.exhibitionTicketCurrentIndex].focusPopIndex]];
            AgentGenome currentAgentGenome = gameManager.trainerRef.evaluationManager.exhibitionTicketList[gameManager.trainerRef.evaluationManager.exhibitionTicketCurrentIndex].agentGenomesList[gameManager.trainerRef.evaluationManager.exhibitionTicketList[gameManager.trainerRef.evaluationManager.exhibitionTicketCurrentIndex].focusPopIndex - 1];
            // Index:
            txt += "Player: " + gameManager.trainerRef.evaluationManager.exhibitionTicketList[gameManager.trainerRef.evaluationManager.exhibitionTicketCurrentIndex].focusPopIndex.ToString();
            txt += ", Genome: " + currentAgentGenome.index.ToString() + "\n";
            txt += "BodyNeurons: " + currentAgentGenome.brainGenome.bodyNeuronList.Count.ToString() + "\n";
            txt += "HiddenNeurons: " + currentAgentGenome.brainGenome.hiddenNeuronList.Count.ToString() + "\n";
            txt += "Links: " + currentAgentGenome.brainGenome.linkList.Count.ToString() + "\n";
            // Modules:
            Agent curAgent = gameManager.trainerRef.evaluationManager.exhibitionInstance.currentAgentsArray[gameManager.trainerRef.evaluationManager.exhibitionTicketList[gameManager.trainerRef.evaluationManager.exhibitionTicketCurrentIndex].focusPopIndex - 1];
            if (curAgent.healthModuleList.Count > 0)
            {
                txt += "HEALTH: " + curAgent.healthModuleList[0].health.ToString() + " / " + curAgent.healthModuleList[0].maxHealth.ToString() + "\n";
            }
            if (curAgent.oscillatorList.Count > 0)
            {
                txt += "\nOSCILLATOR INPUTS: ";
                for (int i = 0; i < curAgent.oscillatorList.Count; i++)
                {
                    txt += "\n" + i.ToString() + ": current value= " + curAgent.oscillatorList[i].value[0].ToString();
                }
                txt += "\n";
            }
            if (curAgent.targetSensorList.Count > 0)
            {
                txt += "\nTARGET SENSOR: ";
                if (curAgent.targetSensorList[0].targetPosition != null)
                {
                    txt += curAgent.targetSensorList[0].targetPosition.position.ToString() + "\n";
                    if (currentAgentGenome.bodyGenome.targetSensorList[0].useX)
                    {
                        txt += "DotX = " + curAgent.targetSensorList[0].dotX[0].ToString() + "\n";
                    }
                    if (currentAgentGenome.bodyGenome.targetSensorList[0].useY)
                    {
                        txt += "DotY = " + curAgent.targetSensorList[0].dotY[0].ToString() + "\n";
                    }
                    if (currentAgentGenome.bodyGenome.targetSensorList[0].useZ)
                    {
                        txt += "DotZ = " + curAgent.targetSensorList[0].dotZ[0].ToString() + "\n";
                    }
                    if (currentAgentGenome.bodyGenome.targetSensorList[0].useX && currentAgentGenome.bodyGenome.targetSensorList[0].useVel)
                    {
                        txt += "DotVelX = " + curAgent.targetSensorList[0].dotVelX[0].ToString() + "\n";
                    }
                    if (currentAgentGenome.bodyGenome.targetSensorList[0].useY && currentAgentGenome.bodyGenome.targetSensorList[0].useVel)
                    {
                        txt += "DotVelY = " + curAgent.targetSensorList[0].dotVelY[0].ToString() + "\n";
                    }
                    if (currentAgentGenome.bodyGenome.targetSensorList[0].useZ && currentAgentGenome.bodyGenome.targetSensorList[0].useVel)
                    {
                        txt += "DotVelZ = " + curAgent.targetSensorList[0].dotVelZ[0].ToString() + "\n";
                    }
                    if (currentAgentGenome.bodyGenome.targetSensorList[0].useDist)
                    {
                        txt += "Dist = " + curAgent.targetSensorList[0].dist[0].ToString() + "\n";
                    }
                    if (currentAgentGenome.bodyGenome.targetSensorList[0].useInvDist)
                    {
                        txt += "InvDist = " + curAgent.targetSensorList[0].invDist[0].ToString() + "\n";
                    }
                }
            }
            if (curAgent.raycastSensorList.Count > 0)
            {
                txt += "\nRAYCAST SENSOR:\n";
                txt += "Left = " + curAgent.raycastSensorList[0].distanceLeft[0].ToString() + "\n";
                txt += "LeftCenter = " + curAgent.raycastSensorList[0].distanceLeftCenter[0].ToString() + "\n";
                txt += "CenterShort = " + curAgent.raycastSensorList[0].distanceCenterShort[0].ToString() + "\n";
                txt += "RightCenter = " + curAgent.raycastSensorList[0].distanceRightCenter[0].ToString() + "\n";
                txt += "Right = " + curAgent.raycastSensorList[0].distanceRight[0].ToString() + "\n";
                txt += "CenterLong = " + curAgent.raycastSensorList[0].distanceCenter[0].ToString() + "\n";
                txt += "Back = " + curAgent.raycastSensorList[0].distanceBack[0].ToString() + "\n";
            }
            if (curAgent.thrusterEffectorList.Count > 0)
            {
                txt += "\nTHRUSTER: ";
                for (int i = 0; i < curAgent.thrusterEffectorList.Count; i++)
                {
                    //txt += "\n" + i.ToString() + ": current value= " + curAgent.thrusterEffectorList[i].throttleY[0].ToString();
                    if (currentAgentGenome.bodyGenome.thrusterList[0].useX)
                    {
                        txt += "X = " + curAgent.torqueEffectorList[0].throttleX[0].ToString() + ", ";
                    }
                    if (currentAgentGenome.bodyGenome.thrusterList[0].useY)
                    {
                        txt += "Y = " + curAgent.torqueEffectorList[0].throttleY[0].ToString() + ", ";
                    }
                    if (currentAgentGenome.bodyGenome.thrusterList[0].useZ)
                    {
                        txt += "Z = " + curAgent.torqueEffectorList[0].throttleZ[0].ToString() + "\n";
                    }
                }
                //txt += "\n";
                //txt += curAgent.thrusterEffectorList[0].throttleZ[0].ToString() + "\n";
            }
            if (curAgent.torqueEffectorList.Count > 0)
            {
                //txt += "TORQUE: ";
                txt += "\nTORQUE: ";
                if (currentAgentGenome.bodyGenome.torqueList[0].useX)
                {
                    txt += "X = " + curAgent.torqueEffectorList[0].throttleX[0].ToString() + ", ";
                }
                if (currentAgentGenome.bodyGenome.torqueList[0].useY)
                {
                    txt += "Y = " + curAgent.torqueEffectorList[0].throttleY[0].ToString() + ", ";
                }
                if (currentAgentGenome.bodyGenome.torqueList[0].useZ)
                {
                    txt += "Z = " + curAgent.torqueEffectorList[0].throttleZ[0].ToString() + "\n";
                }
                //txt += curAgent.torqueEffectorList[0].throttleY[0].ToString() + "\n";
            }
            if (curAgent.weaponProjectileList.Count > 0)
            {
                txt += "\nWEAPON-PROJECTILE:\n";
                txt += "Throttle = " + curAgent.weaponProjectileList[0].throttle[0].ToString() + "\n";
                txt += "Damage Inflicted = " + curAgent.weaponProjectileList[0].damageInflicted[0].ToString() + "\n";
                txt += "Energy = " + curAgent.weaponProjectileList[0].energy[0].ToString() + "\n";
            }
            if (curAgent.weaponTazerList.Count > 0)
            {
                txt += "\nWEAPON-TAZER:\n";
                txt += "Throttle = " + curAgent.weaponTazerList[0].throttle[0].ToString() + "\n";
                txt += "Damage Inflicted = " + curAgent.weaponTazerList[0].damageInflicted[0].ToString() + "\n";
                txt += "Energy = " + curAgent.weaponTazerList[0].energy[0].ToString() + "\n";
            }
            if (curAgent.contactSensorList.Count > 0)
            {
                txt += "\nCONTACT:\n";
                txt += "Contact = " + curAgent.contactSensorList[0].contactSensor[0].ToString() + "\n";
            }
            if (curAgent.gravitySensorList.Count > 0)
            {
                txt += "\nGRAVITY SENSOR:\n";
                if (currentAgentGenome.bodyGenome.gravitySensorList[0].useGravityDir)
                {
                    txt += "DotX = " + curAgent.gravitySensorList[0].dotX[0].ToString() + "\n";
                    txt += "DotY = " + curAgent.gravitySensorList[0].dotY[0].ToString() + "\n";
                    txt += "DotZ = " + curAgent.gravitySensorList[0].dotZ[0].ToString() + "\n";
                }
                if (currentAgentGenome.bodyGenome.gravitySensorList[0].useVel)
                {
                    txt += "VelX = " + curAgent.gravitySensorList[0].velX[0].ToString() + "\n";
                    txt += "VelY = " + curAgent.gravitySensorList[0].velY[0].ToString() + "\n";
                    txt += "VelZ = " + curAgent.gravitySensorList[0].velZ[0].ToString() + "\n";
                }
                if (currentAgentGenome.bodyGenome.gravitySensorList[0].useAltitude)
                {
                    txt += "Altitude = " + curAgent.gravitySensorList[0].altitude[0].ToString() + "\n";
                }
            }
            if (curAgent.healthModuleList.Count > 0)
            {
                txt += "\nHEALTH:\n";
                txt += "Health = " + curAgent.healthModuleList[0].healthSensor[0].ToString() + "\n";
                txt += "Damage = " + curAgent.healthModuleList[0].takingDamage[0].ToString() + "\n";
            }
            if (curAgent.basicWheelList.Count > 0)
            {
                txt += "\nBASIC AXLE:\n";
                for (int i = 0; i < curAgent.basicWheelList.Count; i++)
                {
                    txt += "Throttle = " + curAgent.basicWheelList[i].throttle[0].ToString() + "\n";
                    txt += "SteerAngle = " + curAgent.basicWheelList[i].steerAngle[0].ToString() + "\n";
                    txt += "Brake = " + curAgent.basicWheelList[i].brake[0].ToString() + "\n";
                    txt += "Speed = " + curAgent.basicWheelList[i].speed[0].ToString() + "\n\n";
                }
                //txt += "Throttle = " + curAgent.basicWheelList[0].throttle[0].ToString() + "\n";
                //txt += "SteerAngle = " + curAgent.basicWheelList[0].steerAngle[0].ToString() + "\n";
                //txt += "Brake = " + curAgent.basicWheelList[0].brake[0].ToString() + "\n";
                //txt += "Speed = " + curAgent.basicWheelList[0].speed[0].ToString() + "\n";
            }
            if (curAgent.atmosphereSensorList.Count > 0)
            {
                txt += "\nATMOSPHERE SENSOR:\n";
                txt += "WindX = " + curAgent.atmosphereSensorList[0].windDotX[0].ToString() + "\n";
                txt += "WindY = " + curAgent.atmosphereSensorList[0].windDotY[0].ToString() + "\n";
                txt += "WindZ = " + curAgent.atmosphereSensorList[0].windDotZ[0].ToString() + "\n";
            }
        }
        return(txt);
    }
    public void SetRepresentativeGenome(AgentGenome rep)
    {
        representativeGenome = rep;

        UpdateDisplayColor();
    }
Esempio n. 26
0
    public void PrepareMatchup(List <EnvironmentGenome> environmentGenomeList, List <AgentGenome> competitorGenomeList, AgentGenome playerGenome, int numEntrants, int maxTimeSteps)
    {
        winnerID        = -1;
        matchupFinished = false;
        //EnvironmentGenome loadedGenome1 = JsonUtility.FromJson<EnvironmentGenome>(dataAsJson);
        List <AgentGenome> agentGenomesList = new List <AgentGenome>();

        for (int i = 0; i < competitorIDs.Length; i++)
        {
            // -1 value is code to use player's genome here
            if (competitorIDs[i] == -1)
            {
                agentGenomesList.Add(playerGenome);
            }
            else
            {
                agentGenomesList.Add(competitorGenomeList[competitorIDs[i]]);
            }
        }

        evalTicket = new EvaluationTicket(environmentGenomeList[environmentID], agentGenomesList, 1, maxTimeSteps);


        contestantScoresArray = new float[1];  // ASSUMES ! PLAYER AT A TIME!!!!

        Debug.Log("contestantScoresArray.Length: " + contestantScoresArray.Length.ToString());
    }
Esempio n. 27
0
    public void InitializeModules(AgentGenome genome, Agent agent)
    {
        atmosphereSensorList = new List <AtmosphereSensor>();
        basicJointList       = new List <BasicJoint>();
        basicWheelList       = new List <BasicWheel>();
        contactSensorList    = new List <ContactSensor>();
        gravitySensorList    = new List <GravitySensor>();
        healthModuleList     = new List <HealthModule>();
        oscillatorList       = new List <InputOscillator>();
        raycastSensorList    = new List <RaycastSensor>();
        shieldList           = new List <Shield>();
        targetSensorList     = new List <TargetSensor>();
        thrusterEffectorList = new List <ThrusterEffector>();
        torqueEffectorList   = new List <TorqueEffector>();
        trajectorySensorList = new List <TrajectorySensor>();
        valueList            = new List <InputValue>();
        weaponProjectileList = new List <WeaponProjectile>();
        weaponTazerList      = new List <WeaponTazer>();

        for (int i = 0; i < genome.bodyGenome.atmosphereSensorList.Count; i++)
        {
            AtmosphereSensor atmosphereSensor = new AtmosphereSensor();
            atmosphereSensor.Initialize(genome.bodyGenome.atmosphereSensorList[i], agent);
            atmosphereSensorList.Add(atmosphereSensor);
        }
        for (int i = 0; i < genome.bodyGenome.basicJointList.Count; i++)
        {
            BasicJoint basicJoint = new BasicJoint();
            basicJoint.Initialize(genome.bodyGenome.basicJointList[i], agent);
            basicJointList.Add(basicJoint);
            //basicJointList[i].Initialize(genome.basicJointList[i]);
        }
        for (int i = 0; i < genome.bodyGenome.basicWheelList.Count; i++)
        {
            BasicWheel basicWheel = new BasicWheel();
            basicWheel.Initialize(genome.bodyGenome.basicWheelList[i], agent);
            basicWheelList.Add(basicWheel);
            //OLD:
            //basicWheelList[i].Initialize(genome.basicWheelList[i]);
        }
        for (int i = 0; i < genome.bodyGenome.contactSensorList.Count; i++)
        {
            ContactSensor contactSensor = new ContactSensor();
            //agent.segmentList[genome.contactSensorList[i].parentID].AddComponent<ContactSensorComponent>();
            contactSensor.Initialize(genome.bodyGenome.contactSensorList[i], agent);
            contactSensorList.Add(contactSensor);

            //contactSensorList[i].Initialize(genome.contactSensorList[i]);
        }
        for (int i = 0; i < genome.bodyGenome.gravitySensorList.Count; i++)
        {
            GravitySensor gravitySensor = new GravitySensor();
            gravitySensor.Initialize(genome.bodyGenome.gravitySensorList[i], agent);
            gravitySensorList.Add(gravitySensor);
        }
        for (int i = 0; i < genome.bodyGenome.healthModuleList.Count; i++)
        {
            HealthModule healthModule = new HealthModule();
            //agent.segmentList[genome.healthModuleList[i].parentID].AddComponent<HealthModuleComponent>();
            healthModule.Initialize(genome.bodyGenome.healthModuleList[i], agent);
            healthModuleList.Add(healthModule);
            //healthModuleList[i].Initialize(genome.healthModuleList[i]);
        }
        for (int i = 0; i < genome.bodyGenome.oscillatorInputList.Count; i++)
        {
            InputOscillator inputOscillator = new InputOscillator();
            inputOscillator.Initialize(genome.bodyGenome.oscillatorInputList[i], agent);
            oscillatorList.Add(inputOscillator);
            //oscillatorList[i].Initialize(genome.oscillatorInputList[i]);
        }
        for (int i = 0; i < genome.bodyGenome.raycastSensorList.Count; i++)
        {
            RaycastSensor raycastSensor = new RaycastSensor();
            raycastSensor.Initialize(genome.bodyGenome.raycastSensorList[i], agent);
            raycastSensorList.Add(raycastSensor);
            //raycastSensorList[i].Initialize(genome.raycastSensorList[i]);
        }
        for (int i = 0; i < genome.bodyGenome.shieldList.Count; i++)
        {
            Shield shield = new Shield();
            shield.Initialize(genome.bodyGenome.shieldList[i], agent);
            shieldList.Add(shield);
        }
        for (int i = 0; i < genome.bodyGenome.targetSensorList.Count; i++)
        {
            TargetSensor targetSensor = new TargetSensor();
            targetSensor.Initialize(genome.bodyGenome.targetSensorList[i], agent);
            targetSensorList.Add(targetSensor);
            //targetSensorList[i].Initialize(genome.targetSensorList[i]);
        }
        for (int i = 0; i < genome.bodyGenome.thrusterList.Count; i++)
        {
            // Create Functional GameObjects & Components:
            // none in this case

            // Create Logic Module:
            ThrusterEffector thrusterEffector = new ThrusterEffector();
            // Initialize and HookUp Logic Module:
            thrusterEffector.Initialize(genome.bodyGenome.thrusterList[i], agent);
            // If Visible, Create Renderable GameObjects & Components:
            if (isVisible)
            {
                // Find appropriate Prefab based on Agent & Module Genome:
                GameObject thrusterGO = Instantiate(Resources.Load("Prefabs/Modules/Thrusters/thrusterTest")) as GameObject;
                thrusterGO.transform.parent        = agent.segmentList[genome.bodyGenome.thrusterList[i].parentID].transform;
                thrusterGO.transform.localPosition = genome.bodyGenome.thrusterList[i].forcePoint;
                thrusterGO.transform.localRotation = Quaternion.identity;
                // Hook into Logic Module
                thrusterEffector.thrusterComponent = thrusterGO.GetComponent <ThrusterComponent>();
            }
            // Add Logic Module to Agent's Master List
            thrusterEffectorList.Add(thrusterEffector);
        }
        for (int i = 0; i < genome.bodyGenome.torqueList.Count; i++)
        {
            TorqueEffector torqueEffector = new TorqueEffector();
            torqueEffector.Initialize(genome.bodyGenome.torqueList[i], agent);
            torqueEffectorList.Add(torqueEffector);
            //torqueEffectorList[i].Initialize(genome.torqueList[i]);
        }
        for (int i = 0; i < genome.bodyGenome.trajectorySensorList.Count; i++)
        {
            TrajectorySensor trajectorySensor = new TrajectorySensor();
            trajectorySensor.Initialize(genome.bodyGenome.trajectorySensorList[i], agent);
            trajectorySensorList.Add(trajectorySensor);
        }
        for (int i = 0; i < genome.bodyGenome.valueInputList.Count; i++)
        {
            InputValue inputValue = new InputValue();
            inputValue.Initialize(genome.bodyGenome.valueInputList[i], agent);
            valueList.Add(inputValue);
            //valueList[i].Initialize(genome.valueInputList[i]);
        }
        for (int i = 0; i < genome.bodyGenome.weaponProjectileList.Count; i++)
        {
            WeaponProjectile weaponProjectile = new WeaponProjectile();
            weaponProjectile.Initialize(genome.bodyGenome.weaponProjectileList[i], agent);

            if (isVisible)
            {
                // Find appropriate Prefab based on Agent & Module Genome:
                GameObject weaponGO = Instantiate(Resources.Load("Prefabs/Modules/WeaponProjectiles/projectileTest")) as GameObject;
                weaponGO.transform.parent        = agent.segmentList[genome.bodyGenome.weaponProjectileList[i].parentID].transform;
                weaponGO.transform.localPosition = genome.bodyGenome.weaponProjectileList[i].muzzleLocation;
                weaponGO.transform.localRotation = Quaternion.identity;
                // Hook into Logic Module
                weaponProjectile.weaponProjectileComponent = weaponGO.GetComponent <WeaponProjectileComponent>();
            }

            weaponProjectileList.Add(weaponProjectile);

            /*weaponProjectileList[i].Initialize(genome.weaponProjectileList[i]);
             *
             * if (isVisible) {
             *  GameObject particleGO = Instantiate(Resources.Load(weaponProjectileList[i].GetParticleSystemURL())) as GameObject;
             *  ParticleSystem particle = particleGO.GetComponent<ParticleSystem>();
             *  ParticleSystem.EmissionModule emission = particle.emission;
             *  emission.enabled = false;
             *  particle.gameObject.transform.parent = rootObject.transform;
             *  particle.gameObject.transform.localPosition = new Vector3(0f, 0.5f, 0f);
             *  particle.gameObject.transform.localRotation = Quaternion.identity;
             *  weaponProjectileList[i].particles = particle; // save reference
             * }
             */
        }
        for (int i = 0; i < genome.bodyGenome.weaponTazerList.Count; i++)
        {
            WeaponTazer weaponTazer = new WeaponTazer();
            weaponTazer.Initialize(genome.bodyGenome.weaponTazerList[i], agent);

            if (isVisible)
            {
                // Find appropriate Prefab based on Agent & Module Genome:
                GameObject weaponGO = Instantiate(Resources.Load("Prefabs/Modules/WeaponTazers/tazerTest")) as GameObject;
                weaponGO.transform.parent        = agent.segmentList[genome.bodyGenome.weaponTazerList[i].parentID].transform;
                weaponGO.transform.localPosition = genome.bodyGenome.weaponTazerList[i].muzzleLocation;
                weaponGO.transform.localRotation = Quaternion.identity;
                // Hook into Logic Module
                weaponTazer.weaponTazerComponent = weaponGO.GetComponent <WeaponTazerComponent>();
            }

            weaponTazerList.Add(weaponTazer);

            /*weaponTazerList[i].Initialize(genome.weaponTazerList[i]);
             * if (isVisible) {
             *  GameObject particleGO = Instantiate(Resources.Load(weaponTazerList[i].GetParticleSystemURL())) as GameObject;
             *  ParticleSystem particle = particleGO.GetComponent<ParticleSystem>();
             *  ParticleSystem.EmissionModule emission = particle.emission;
             *  emission.enabled = false;
             *  particle.gameObject.transform.parent = weaponTazerList[i].parentBody.transform;
             *  particle.gameObject.transform.localPosition = weaponTazerList[i].muzzleLocation;
             *  particle.gameObject.transform.localRotation = Quaternion.identity;
             *  weaponTazerList[i].particles = particle; // save reference
             * }
             */
        }
    }
Esempio n. 28
0
 private void CreateNewAverageCandidate()
 {
     AgentGenome blankGenome = new AgentGenome(.1f, 0);
     avgCandidateData = new CandidateAgentData(blankGenome, speciesID);
     avgCandidateData.SetToAverage(leaderboardGenomesList);
 }
Esempio n. 29
0
    //CritterModuleFoodSensorsGenome foodGenome;

    // * WPP: break code sections into methods, call from here
    private void UpdateUI()
    {
        if (!agent)
        {
            return;
        }

        agentIndex      = agent.index;
        candidate       = agent.candidateRef;
        coreModule      = agent.coreModule;
        brain           = agent.brain;
        candidateGenome = candidate.candidateGenome;
        brainGenome     = candidateGenome.brainGenome;
        bodyGenome      = candidateGenome.bodyGenome;
        coreGenome      = bodyGenome.coreGenome;
        foodModule      = agent.foodModule;
        movementModule  = agent.movementModule;
        //foodGenome = bodyGenome.foodGenome;

        if (!agent.isInert)
        {
            // DebugTxt1 : use this for selected creature stats:
            int curCount = 0;
            int maxCount = 1;
            if (agent.isEgg)
            {
                curCount = agent.lifeStageTransitionTimeStepCounter;
                maxCount = agent.gestationDurationTimeSteps;
            }
            if (agent.isMature)
            {
                curCount = agent.ageCounter;
                maxCount = agent.maxAgeTimeSteps;
            }
            if (agent.isDead)
            {
                curCount = agent.lifeStageTransitionTimeStepCounter;
                maxCount = curCount; // agentRef._DecayDurationTimeSteps;
            }
            int    progressPercent      = Mathf.RoundToInt((float)curCount / (float)maxCount * 100f);
            string lifeStageProgressTxt = " " + agent.curLifeStage + " " + curCount + "/" + maxCount + "  " + progressPercent + "% ";

            // &&&& INDIVIDUAL AGENT: &&&&
            string debugTxtAgent = "";
            debugTxtAgent += "CRITTER# [" + agentIndex + "]     SPECIES# [" + agent.speciesIndex + "]\n\n";
            // Init Attributes:
            // Body:
            debugTxtAgent += "Base Size: " + coreGenome.creatureBaseLength.ToString("F2") + ",  Aspect: " + coreGenome.creatureAspectRatio.ToString("F2") + "\n";
            debugTxtAgent += "Fullsize Dimensions: ( " + agent.fullSizeBoundingBox.x.ToString("F2") + ", " + agent.fullSizeBoundingBox.y.ToString("F2") + ", " + agent.fullSizeBoundingBox.z.ToString("F2") + " )\n";
            debugTxtAgent += "BONUS - Damage: " + coreModule.damageBonus.ToString("F2") + ", Speed: " + coreModule.speedBonus.ToString("F2") + ", Health: " + coreModule.healthBonus.ToString("F2") + ", Energy: " + coreModule.energyBonus.ToString("F2") + "\n";
            debugTxtAgent += "DIET - Decay: " + coreModule.digestEfficiencyDecay.ToString("F2") + ", Plant: " + coreModule.digestEfficiencyPlant.ToString("F2") + ", Meat: " + coreModule.digestEfficiencyMeat.ToString("F2") + "\n";
            //string mouthType = "Active";
            //if (agentRef.mouthRef.isPassive) { mouthType = "Passive"; }
            //debugTxtAgent += "Mouth: [" + mouthType + "]\n";
            debugTxtAgent += "# Neurons: " + brain.neurons.Count + ", # Axons: " + brain.axons.Count + "\n";
            debugTxtAgent += "# In/Out Nodes: " + brainGenome.inOutNeurons.Count + ", # Hidden Nodes: " + brainGenome.hiddenNeurons.Count + ", # Links: " + brainGenome.links.Count + "\n";

            debugTxtAgent += "\nSENSORS:\n";
            debugTxtAgent += "Comms= " + bodyGenome.data.hasComms + "\n";
            debugTxtAgent += "Enviro: WaterStats: " + bodyGenome.data.useWaterStats + ", Cardinals= " + bodyGenome.data.useCardinals + ", Diagonals= " + bodyGenome.data.useDiagonals + "\n";
            //debugTxtAgent += "Food: Nutrients= " + foodGenome.useNutrients + ", Pos= " + foodGenome.usePos + ",  Dir= " + foodGenome.useDir + ",  Stats= " + foodGenome.useStats + ", useEggs: " + foodGenome.useEggs + ", useCorpse: " + foodGenome.useCorpse + "\n";
            //debugTxtAgent += "Friend: Pos= " + bodyGenome.friendGenome.usePos + ",  Dir= " + bodyGenome.friendGenome.useDir + ",  Vel= " + bodyGenome.friendGenome.useVel + "\n";
            //debugTxtAgent += "Threat: Pos= " + bodyGenome.threatGenome.usePos + ",  Dir= " + bodyGenome.threatGenome.useDir + ",  Vel= " + bodyGenome.threatGenome.useVel + ",  Stats= " + bodyGenome.threatGenome.useStats + "\n";
            // Realtime Values:
            debugTxtAgent += "\nREALTIME DATA:";
            //debugTxtAgent += "\nExp: " + agentRef.totalExperience.ToString("F2") + ",  fitnessScore: " + agentRef.masterFitnessScore.ToString("F2") + ", LVL: " + agentRef.curLevel.ToString();
            debugTxtAgent += "\n(" + lifeStageProgressTxt + ") Growth: " + (agent.sizePercentage * 100f).ToString("F0") + "%, Age: " + agent.ageCounter + " Frames\n\n";

            debugTxtAgent += "Nearest Food: [" + foodModule.nearestFoodParticleIndex +
                             "] Amount: " + foodModule.nearestFoodParticleAmount.ToString("F4") +
                             "\nPos: ( " + foodModule.nearestFoodParticlePos.x.ToString("F2") +
                             ", " + foodModule.nearestFoodParticlePos.y.ToString("F2") +
                             " ), Dir: ( " + foodModule.foodPlantDirX[0].ToString("F2") +
                             ", " + foodModule.foodPlantDirY[0].ToString("F2") + " )" +
                             "\n";
            debugTxtAgent += "\nNutrients: " + foodModule.nutrientDensity[0].ToString("F4") + ", Stamina: " + coreModule.stamina[0].ToString("F3") + "\n";
            debugTxtAgent += "Gradient Dir: (" + foodModule.nutrientGradX[0].ToString("F2") + ", " + foodModule.nutrientGradY[0].ToString("F2") + ")\n";
            //debugTxtAgent += "Total Food Eaten -- Decay: n/a, Plant: " + agentRef.totalFoodEatenPlant.ToString("F2") + ", Meat: " + agentRef.totalFoodEatenZoop.ToString("F2") + "\nFood Stored: " + agentRef.coreModule.foodStored[0].ToString() + ", Corpse Food Amount: " + agentRef.currentBiomass.ToString("F3") + "\n";

            //debugTxtAgent += "\nFullSize: " + agentRef.fullSizeBoundingBox.ToString() + ", Volume: " + agentRef.fullSizeBodyVolume.ToString() + "\n";
            //debugTxtAgent += "( " + (agentRef.sizePercentage * 100f).ToString("F0") + "% )\n";

            debugTxtAgent += "\nCurVel: " + agent.curVel.ToString("F3") + ", CurAccel: " + agent.curAccel.ToString("F3") + ", AvgVel: " + agent.avgVel.ToString("F3") + "\n";

            debugTxtAgent += "\nWater Depth: " + agent.waterDepth.ToString("F3") + ", Vel: " + (agent.avgFluidVel * 10f).ToString("F3") + "\n";
            debugTxtAgent += "Throttle: [ " + movementModule.throttleX[0].ToString("F3") + ", " + movementModule.throttleY[0].ToString("F3") + " ]\n";
            debugTxtAgent += "FeedEffector: " + coreModule.mouthFeedEffector[0].ToString("F2") + "\n";
            debugTxtAgent += "AttackEffector: " + coreModule.mouthAttackEffector[0].ToString("F2") + "\n";
            debugTxtAgent += "DefendEffector: " + coreModule.defendEffector[0].ToString("F2") + "\n";
            debugTxtAgent += "DashEffector: " + coreModule.dashEffector[0].ToString("F2") + "\n";
            debugTxtAgent += "HealEffector: " + coreModule.healEffector[0].ToString("F2") + "\n";

            //+++++++++++++++++++++++++++++++++++++ CRITTER: ++++++++++++++++++++++++++++++++++++++++++++
            string debugTxtGlobalSim = "";
            debugTxtGlobalSim += "\n\nNumChildrenBorn: " + simulation.numAgentsBorn + ", numDied: " + simulation.numAgentsDied + ", ~Gen: " + ((float)simulation.numAgentsBorn / (float)simulation.numAgents);
            debugTxtGlobalSim += "\nSimulation Age: " + simulation.simAgeTimeSteps;
            debugTxtGlobalSim += "\nYear " + simulation.curSimYear + "\n\n";
            int numActiveSpecies = masterGenomePool.currentlyActiveSpeciesIDList.Count;
            debugTxtGlobalSim += numActiveSpecies + " Active Species:\n";

            for (int s = 0; s < numActiveSpecies; s++)
            {
                int speciesID = masterGenomePool.currentlyActiveSpeciesIDList[s];
                //int parentSpeciesID = simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].parentSpeciesID;
                int numCandidates = masterGenomePool.completeSpeciesPoolsList[speciesID].candidateGenomesList.Count;
                int numLeaders    = masterGenomePool.completeSpeciesPoolsList[speciesID].leaderboardGenomesList.Count;
                //int numBorn = simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].numAgentsEvaluated;
                int speciesPopSize = 0;
                //float avgFitness = simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgPerformanceData.totalTicksAlive;
                for (int a = 0; a < simulation.numAgents; a++)
                {
                    if (simulation.agents[a].speciesIndex == speciesID)
                    {
                        speciesPopSize++;
                    }
                }
                if (masterGenomePool.completeSpeciesPoolsList[speciesID].isFlaggedForExtinction)
                {
                    debugTxtGlobalSim += "xxx ";
                }

                /*debugTxtGlobalSim += "Species[" + speciesID.ToString() + "] p(" + parentSpeciesID.ToString() + "), size: " + speciesPopSize.ToString() + ", #cands: " + numCandidates.ToString() + ", numEvals: " + numBorn.ToString() +
                 *           ",   avgFitness: " + avgFitness.ToString("F2") +
                 *           ",   avgConsumption: (" + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgFoodEatenCorpse.ToString("F4") + ", " + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgFoodEatenPlant.ToString("F4") + ", " + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgFoodEatenZoop.ToString("F4") + ", " + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgFoodEatenEgg.ToString("F4") + ", " + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgFoodEatenCreature.ToString("F4") +
                 *           "),   avgBodySize: " + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgBodySize.ToString("F3") +
                 *           ",   avgTalentSpec: (" + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgSpecAttack.ToString("F2") + ", " + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgSpecDefend.ToString("F2") + ", " + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgSpecSpeed.ToString("F2") + ", " + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgSpecUtility.ToString("F2") +
                 *           "),   avgDiet: (" + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgFoodSpecDecay.ToString("F2") + ", " + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgFoodSpecPlant.ToString("F2") + ", " + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgFoodSpecMeat.ToString("F2") +
                 *           "),   avgNumNeurons: " + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgNumNeurons.ToString("F1") +
                 *           ",   avgNumAxons: " + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgNumAxons.ToString("F1") +
                 *           ", total: " + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgFitnessScore.ToString("F2") +
                 *           ", avgExp: " + simManager.masterGenomePool.completeSpeciesPoolsList[speciesID].avgExperience.ToString() + "\n\n";*/
            }

            /*debugTxtGlobalSim += "\n\nAll-Time Species List:\n";
             * for (int p = 0; p < simManager.masterGenomePool.completeSpeciesPoolsList.Count; p++) {
             *  string extString = "Active!";
             *  if (simManager.masterGenomePool.completeSpeciesPoolsList[p].isExtinct) {
             *      extString = "Extinct!";
             *  }
             *  debugTxtGlobalSim += "Species[" + p.ToString() + "] p(" + simManager.masterGenomePool.completeSpeciesPoolsList[p].parentSpeciesID.ToString() + ") " + extString + "\n";
             * }*/

            textDebugTrainingInfo1.text = debugTxtAgent;
            textDebugTrainingInfo3.text = debugTxtGlobalSim;
        }

        string debugTxtResources = "";

        debugTxtResources += "GLOBAL RESOURCES:\n";
        debugTxtResources += "\nSunlight: " + environmentSettings._BaseSolarEnergy;
        debugTxtResources += "\nOxygen: " + simResourceManager.curGlobalOxygen;
        debugTxtResources += "\n     + " + simResourceManager.oxygenProducedByAlgaeReservoirLastFrame + " ( algae reservoir )";
        debugTxtResources += "\n     + " + simResourceManager.oxygenProducedByPlantParticlesLastFrame + " ( algae particles )";
        debugTxtResources += "\n     - " + simResourceManager.oxygenUsedByDecomposersLastFrame + " ( decomposers )";
        debugTxtResources += "\n     - " + simResourceManager.oxygenUsedByAnimalParticlesLastFrame + " ( zooplankton )";
        debugTxtResources += "\n     - " + simResourceManager.oxygenUsedByAgentsLastFrame + " ( agents )";
        debugTxtResources += "\nNutrients: " + simResourceManager.curGlobalNutrients;
        debugTxtResources += "\n     + " + simResourceManager.nutrientsProducedByDecomposersLastFrame + " ( decomposers )";
        debugTxtResources += "\n     - " + simResourceManager.nutrientsUsedByAlgaeReservoirLastFrame + " ( algae reservoir )";
        debugTxtResources += "\n     - " + simResourceManager.nutrientsUsedByPlantParticlesLastFrame + " ( algae particles )";
        debugTxtResources += "\nDetritus: " + simResourceManager.curGlobalDetritus;
        debugTxtResources += "\n     + " + simResourceManager.wasteProducedByAlgaeReservoirLastFrame + " ( algae reservoir )";
        debugTxtResources += "\n     + " + simResourceManager.wasteProducedByPlantParticlesLastFrame + " ( algae particles )";
        debugTxtResources += "\n     + " + simResourceManager.wasteProducedByAnimalParticlesLastFrame + " ( zooplankton )";
        debugTxtResources += "\n     + " + simResourceManager.wasteProducedByAgentsLastFrame + " ( agents )";
        debugTxtResources += "\n     - " + simResourceManager.detritusRemovedByDecomposersLastFrame + " ( decomposers )";
        debugTxtResources += "\nDecomposers: " + simResourceManager.curGlobalDecomposers;
        debugTxtResources += "\nAlgae (Reservoir): " + simResourceManager.curGlobalAlgaeReservoir;
        debugTxtResources += "\nAlgae (Particles): " + simResourceManager.curGlobalPlantParticles;
        debugTxtResources += "\nZooplankton: " + simResourceManager.curGlobalAnimalParticles;
        debugTxtResources += "\nLive Agents: " + simResourceManager.curGlobalAgentBiomass;
        debugTxtResources += "\nDead Agents: " + simResourceManager.curGlobalCarrionVolume;
        debugTxtResources += "\nEggSacks: " + simResourceManager.curGlobalEggSackVolume;
        debugTxtResources += "\nGlobal Mass: " + simResourceManager.curTotalMass;
        Vector4 resourceGridSample = simulation.SampleTexture(vegetationManager.resourceGridRT1, theCursorCzar.curMousePositionOnWaterPlane / SimulationManager._MapSize);
        Vector4 simTansferSample   = simulation.SampleTexture(vegetationManager.resourceSimTransferRT, theCursorCzar.curMousePositionOnWaterPlane / SimulationManager._MapSize) * 100f;

        //Debug.Log("curMousePositionOnWaterPlane: " + curMousePositionOnWaterPlane.ToString());
        debugTxtResources += "\nresourceGridSample: (" + resourceGridSample.x.ToString("F4") + ", " + resourceGridSample.y.ToString("F4") + ", " + resourceGridSample.z.ToString("F4") + ", " + resourceGridSample.w.ToString("F4") + ")";
        debugTxtResources += "\nsimTansferSample: (" + simTansferSample.x.ToString("F4") + ", " + simTansferSample.y.ToString("F4") + ", " + simTansferSample.z.ToString("F4") + ", " + simTansferSample.w.ToString("F4") + ")";

        textDebugTrainingInfo2.text = debugTxtResources;

        if (debugTextureViewerArray == null)
        {
            CreateDebugRenderViewerArray();
        }

        debugTextureViewerMat.SetPass(0);
        debugTextureViewerMat.SetVector("_Zoom", _Zoom);
        debugTextureViewerMat.SetFloat("_Amplitude", _Amplitude);
        debugTextureViewerMat.SetVector("_ChannelMask", _ChannelMask);
        debugTextureViewerMat.SetInt("_ChannelSoloIndex", _ChannelSoloIndex);
        debugTextureViewerMat.SetFloat("_IsChannelSolo", _IsChannelSolo);
        debugTextureViewerMat.SetFloat("_Gamma", _Gamma);
        //debugTextureViewerMat.
        if (debugTextureViewerArray[_DebugTextureIndex])
        {
            debugTextureViewerMat.SetTexture("_MainTex", debugTextureViewerArray[_DebugTextureIndex]);
            int      channelID       = 4;
            string[] channelLabelTxt = new string[5];
            channelLabelTxt[0] = " (X Solo)";
            channelLabelTxt[1] = " (Y Solo)";
            channelLabelTxt[2] = " (Z Solo)";
            channelLabelTxt[3] = " (W Solo)";
            channelLabelTxt[4] = " (Color)";
            if (_IsChannelSolo > 0.5f)
            {
                channelID = _ChannelSoloIndex;
            }
            textDebugTextureName.text = debugTextureViewerArray[_DebugTextureIndex].name + channelLabelTxt[channelID];
        }

        textDebugTextureZoomX.text            = _Zoom.x.ToString();
        textDebugTextureZoomY.text            = _Zoom.y.ToString();
        textDebugTextureAmplitude.text        = _Amplitude.ToString();
        textDebugTextureSoloChannelIndex.text = _ChannelSoloIndex.ToString();
        textDebugTextureGamma.text            = _Gamma.ToString();
    }
Esempio n. 30
0
 public void AddNewCandidateGenome(AgentGenome newGenome)
 {
     //Debug.Log("AddedNewCandidate! " + candidateGenomesList.Count.ToString());
     CandidateAgentData newCandidateData = new CandidateAgentData(newGenome, speciesID);
     candidateGenomesList.Add(newCandidateData);
 }