// * WPP: use getter for AgentData plus RepeatWhileEnabled to remove UIManager dependency public void Tick(CandidateAgentData agentData) { if (agentData.candidateEventDataList == null) { return; } /* * // Agent Event Log: * int maxEventsToDisplayLog = 16; * //int numEventsLog = Mathf.Min(agent.agentEventDataList.Count, maxEventsToDisplayLog); * int startIndexLog = Mathf.Max(0, agentData.candidateEventDataList.Count - maxEventsToDisplayLog); * string eventLogString = "Event Log! Candidate#[" + agentData.candidateID + "] " + agentData.candidateEventDataList.Count; * * for(int q = agentData.candidateEventDataList.Count - 1; q >= startIndexLog; q--) { * float dimAmount = Mathf.Clamp01((agentData.candidateEventDataList.Count - q - 1) * 0.55f); * * bool isDim = dimAmount > dimThreshold; * bool isGood = agentData.candidateEventDataList[q].goodness > goodThreshold; * eventLogString += EventColorString(isDim, isGood); * * eventLogString += "\n[" + agentData.candidateEventDataList[q].eventFrame + "] " + agentData.candidateEventDataList[q].eventText; * eventLogString += "</color>"; * } * * //eventsLog += eventLogString; * textEventsLog.text = eventLogString; */ }
public void UpdateBars(CandidateAgentData candidate) { Color activeColor = Color.white; Color inactiveColor = Color.clear; behaviorBarRest.transform.localScale = Vector3.one; UpdateBarColor(behaviorBarRest.GetComponent <Image>(), 0f, false); behaviorBarRest.GetComponent <TooltipUI>().tooltipString = "Rest"; behaviorBarDash.transform.localScale = Vector3.one; UpdateBarColor(behaviorBarDash.GetComponent <Image>(), 0f, false); behaviorBarDash.GetComponent <TooltipUI>().tooltipString = "Dash"; behaviorBarGuard.transform.localScale = Vector3.one; UpdateBarColor(behaviorBarGuard.GetComponent <Image>(), 0f, false); behaviorBarGuard.GetComponent <TooltipUI>().tooltipString = "Guard"; behaviorBarBite.transform.localScale = Vector3.one; UpdateBarColor(behaviorBarBite.GetComponent <Image>(), 0f, false); behaviorBarBite.GetComponent <TooltipUI>().tooltipString = "Bite"; behaviorBarAttack.transform.localScale = Vector3.one; UpdateBarColor(behaviorBarAttack.GetComponent <Image>(), 0f, false); behaviorBarAttack.GetComponent <TooltipUI>().tooltipString = "Attack"; //UpdateBarColor(behaviorBarOther.GetComponent<Image>(), 0f, false); //textOther.gameObject.SetActive(false); throttleGO.gameObject.SetActive(false); }
public void ProcessCompletedCandidate(CandidateAgentData candidateData, MasterGenomePool masterGenomePool) { numAgentsEvaluated++; leaderboardGenomesList.Insert(0, candidateData); // place at front of leaderboard list (genomes eligible for being parents) if(leaderboardGenomesList.Count > maxLeaderboardGenomePoolSize) { leaderboardGenomesList.RemoveAt(leaderboardGenomesList.Count - 1); } int beforeCount = candidateGenomesList.Count; int listIndex = -1; for (int i = 0; i < candidateGenomesList.Count; i++) { if(candidateData.candidateID == candidateGenomesList[i].candidateID) { listIndex = i; } } //Debug.Log("Removed! " + beforeCount.ToString() + " #: " + listIndex.ToString() + ", candID: " + candidateData.candidateID.ToString()); if (listIndex > -1) { //Debug.Log("RemoveAt(" + listIndex.ToString() + "),[" + candidateGenomesList[listIndex].candidateID.ToString() + "], candID: " + candidateData.candidateID.ToString() + ", SpeciesPool: " + this.speciesID.ToString() + ", CDSID: " + candidateData.speciesID.ToString()); candidateGenomesList.RemoveAt(listIndex); // Will this work? never used this before masterGenomePool.debugRecentlyDeletedCandidateIDsList.Insert(0, candidateData.candidateID); if (masterGenomePool.debugRecentlyDeletedCandidateIDsList.Count > 512) { masterGenomePool.debugRecentlyDeletedCandidateIDsList.RemoveAt(masterGenomePool.debugRecentlyDeletedCandidateIDsList.Count - 1); } } else { Debug.LogError(candidateGenomesList.Count <= 0 ? "META-ERROR NO INDEX FOUND! " : $"ERROR NO INDEX FOUND! {candidateData.candidateID}, species: {speciesID}, CDSID: {candidateData.speciesID}, [0]: {candidateGenomesList[0].candidateID}"); masterGenomePool.GlobalFindCandidateID(candidateData.candidateID); // temp debug } // *** NOTE! *** List.Remove() was unreliable - worked sometimes but not others? still unsure about it }
private void UpdateCreatureEventIcons(CandidateAgentData candidate) { if (candidate?.candidateEventDataList == null || creatureEventIcons.Count == 0 || candidate.candidateEventDataList.Count == 0) { return; } ClearDeadCreatureEventIcons(); for (int i = 0; i < creatureEventIcons.Count; i++) { if (curPanelMode != HistoryPanelMode.CreatureTimeline) { // Hide icons when not on Timeline screen creatureEventIcons[i].gameObject.SetActive(false); continue; } var active = i < candidate.candidateEventDataList.Count; creatureEventIcons[i].gameObject.SetActive(active); if (!active) { continue; } Vector2 eventCoords = Vector2.zero; eventCoords.x = (float)(candidate.candidateEventDataList[i].eventFrame - candidate.performanceData.timeStepHatched) / (float)(simManager.simAgeTimeSteps - candidate.performanceData.timeStepHatched); eventCoords.x *= displayWidth + marginLeft; eventCoords.y = (1f - ((float)candidate.candidateEventDataList[i].type / 12f)) * displayHeight + marginBottom; creatureEventIcons[i].UpdateIconPrefabData(candidate.candidateEventDataList[i], i); creatureEventIcons[i].SetTargetCoords(eventCoords); creatureEventIcons[i].SetDisplay(); } }
public void Tick() { if (agent == null || agent.coreModule == null) { return; } CandidateAgentData candidate = selectionManager.currentSelection.candidate; if (agent.curLifeStage != AgentLifeStage.Mature) { panelStatusBars.SetActive(false); } else { panelStatusBars.SetActive(true); } if (agent.candidateRef.candidateID == candidate.candidateID) { var lifeStageData = lookup.GetAgentLifeStageData(agent.curLifeStage, agent.isYoung); tooltipState.tooltipString = lifeStageData.stateName + "\nAge: " + agent.ageCounter + "\nSize: " + (agent.currentBiomass / agent.fullsizeBiomass * 100f).ToString("F0") + "% Grown";// + agent.currentBiomass.ToString("F3"); tooltipImage.sprite = lifeStageData.icon; tooltipHealth.tooltipString = "Health: " + (agent.coreModule.health * 100f).ToString("F0") + "%"; imageMeterBarHealth.transform.localScale = new Vector3(1f, agent.coreModule.health, 1f); tooltipEnergy.tooltipString = "Energy: " + agent.coreModule.energy.ToString("F0"); imageMeterBarEnergy.transform.localScale = new Vector3(1f, Mathf.Clamp01(agent.coreModule.energy * 0.005f), 1f); tooltipStomachFood.tooltipString = "Stomach: " + (agent.coreModule.stomachContentsPercent * 100f).ToString("F0"); imageMeterBarStomach.transform.localScale = new Vector3(1f, agent.coreModule.stomachContentsPercent, 1f); tooltipWaste.tooltipString = "Waste: (tbd)"; // + agent.coreModule.was.ToString("F0"); imageMeterBarWaste.transform.localScale = new Vector3(1f, 0f, 1f); imageGrowthPercent.transform.localScale = Vector3.one * agent.sizePercentage; } else { var lifeStageData = lookup.GetAgentLifeStageData(AgentLifeStage.Dead); tooltipState.tooltipString = lifeStageData.stateName + ", Age: " + candidate.performanceData.totalTicksAlive; // + ", Size: " + candidate.performanceData.grow.ToString("F3"); tooltipImage.sprite = lifeStageData.icon; tooltipHealth.tooltipString = "Health:"; imageMeterBarHealth.transform.localScale = new Vector3(1f, 0f, 1f); tooltipEnergy.tooltipString = "Energy:"; imageMeterBarEnergy.transform.localScale = new Vector3(1f, 0f, 1f); tooltipStomachFood.tooltipString = "Stomach:"; imageMeterBarStomach.transform.localScale = new Vector3(1f, 0f, 1f); tooltipWaste.tooltipString = "Waste: (tbd)"; imageMeterBarWaste.transform.localScale = new Vector3(1f, 0f, 1f); } }
void CreateCreatureLine(int line, int point, Vector2 cursorCoords, WorldTreeLineData[] worldTreeLines) { int index = (line + worldTreeNumSpeciesLines) * worldTreeNumPointsPerLine + point; SpeciesGenomePool pool = simManager.masterGenomePool.completeSpeciesPoolsList[selectionManager.currentSelection.historySelectedSpeciesID]; if (line >= pool.candidateGenomesList.Count) { return; } WorldTreeLineData data = new WorldTreeLineData(); CandidateAgentData cand = pool.candidateGenomesList[line]; float xCoord = (float)point / (float)worldTreeNumPointsPerLine; int numAgentsDisplayed = Mathf.Max(pool.GetNumberAgentsEvaluated(), 1); // Prevent divide by 0 float yCoord = 1f - (float)line / (float)numAgentsDisplayed; int timeStepStart = Mathf.RoundToInt(timelineStartTimeStep); float xStart = (float)(pool.candidateGenomesList[line].performanceData.timeStepHatched - timeStepStart) / (float)(simManager.simAgeTimeSteps - timeStepStart); float xEnd = 1f; if (pool.isExtinct || cand.performanceData.timeStepDied > 1) { xEnd = (float)(cand.performanceData.timeStepDied - timeStepStart) / (float)(simManager.simAgeTimeSteps - timeStepStart); } bool inXBounds = xStart <= xCoord && xEnd >= xCoord; Vector3 hue = pool.foundingCandidate.candidateGenome.bodyGenome.appearanceGenome.huePrimary * 1.5f; data.color = GetCreatureLineColor(hue, cand, inXBounds); // new Color(hue.x, hue.y, hue.z);// Color.HSVToRGB(lerp, 1f - lerp, 1f); // Color.Lerp(Color.white, Color.black, lineID * 0.11215f); xCoord = xCoord * displayWidth + marginLeft; // rescaling --> make this more robust yCoord = yCoord * displayHeight + marginBottom; data.worldPos = new Vector3(xCoord, yCoord, 0f); // Mouse hover highlight if ((new Vector2(xCoord, yCoord) - cursorCoords).magnitude < 0.05f) { data.color = Color.white; } if (isTimelineMode) //if (isPopulationMode || isTimelineMode) { { data.worldPos = Vector3.zero; data.color = new Color(0f, 0f, 0f, 0f); } worldTreeLines[index] = data; }
public void UpdateLongestLife(Agent agent) { if(agent.ageCounter <= recordLongestLife) return; recordLongestLife = agent.ageCounter; recordHolderLongestLife = agent.candidateRef; if(numAgentsEvaluated > maxLeaderboardGenomePoolSize) { hallOfFameGenomesList.Add(agent.candidateRef); } //Debug.Log("it works! " + speciesPool.recordLongestLife.ToString() + ", candidate: " + agentRef.candidateRef.candidateID.ToString() + ", species: " + agentRef.candidateRef.speciesID.ToString()); }
public void UpdateMostEaten(Agent agent) { float totalEaten = agent.totalEaten; if (totalEaten <= recordMostEaten) return; recordMostEaten = totalEaten; recordHolderMostEaten = agent.candidateRef; if (numAgentsEvaluated > maxLeaderboardGenomePoolSize) { hallOfFameGenomesList.Add(agent.candidateRef); } }
public void SetSelectedFromSpeciesUI(int speciesID) { //currentSelection.historySelectedSpeciesID = id; if (speciesID == currentSelection.historySelectedSpeciesID) { return; } SpeciesGenomePool pool = simulation.masterGenomePool.completeSpeciesPoolsList[speciesID]; CandidateAgentData cand = pool.foundingCandidate; if (!pool.isExtinct && pool.candidateGenomesList.Count > 0) { cand = pool.candidateGenomesList[0]; } SetSelected(cand); Debug.Log("Selected! " + speciesID + ", " + cand.candidateID); }
public CandidateAgentData GetNextAvailableCandidate() { CandidateAgentData candidateData = null; if (candidateGenomesList.Count > 0) { foreach (var candidate in candidateGenomesList) { if (candidate.isBeingEvaluated) continue; candidateData = candidate; break; } } else { candidateData = new CandidateAgentData(representativeCandidate.candidateGenome, speciesID); Debug.LogError("GetNextAvailableCandidate(): candidateData representativeGenome!!!! " + candidateData); } return candidateData; }
private void UpdateBrainFossil(CandidateAgentData candidate) { newInspectAgentCurActivityMat.SetInt("_CurActivityID", 0); newInspectAgentThrottleMat.SetFloat("_ThrottleX", 0f); newInspectAgentThrottleMat.SetFloat("_ThrottleY", 0f); newInspectAgentThrottleMat.SetTexture("_VelocityTex", fluidManager._VelocityPressureDivergenceMain); newInspectAgentThrottleMat.SetFloat("_AgentCoordX", 0f); newInspectAgentThrottleMat.SetFloat("_AgentCoordY", 0f); agentBehaviorOneHot.UpdateBars(candidate); // * WPP: what concept does this condition represent? -> convert to getter in Agent callTickCounter = agent.communicationModule.outComm3[0] > 0.25f ? Mathf.Min(200, callTickCounter++) : Mathf.Max(0, callTickCounter--); agentBehaviorOneHot.UpdateExtras(candidate); }
public void SetSelected(CandidateAgentData candidate) { if (currentSelection == null) { currentSelection = new SelectionData(); } currentSelection.candidate = candidate; // Check if corresponding agent exists: bool hasAgent = false; foreach (var agent in simulation.agents) { if (currentSelection.candidate.candidateID != agent.candidateRef.candidateID) { continue; } hasAgent = true; currentSelection.agent = agent; theRenderKing.InitializeCreaturePortrait(currentSelection.candidate.candidateGenome); uiManager.genomeViewerUI.brainGenomeImage.SetTexture(currentSelection.candidate.candidateGenome.brainGenome); CameraManager.instance.targetAgent = agent; CameraManager.instance.targetAgentTransform = agent.bodyGO.transform; CameraManager.instance.targetAgentIndex = agent.index; break; } currentSelection.isGenomeOnly = !hasAgent; currentSelection.historySelectedSpeciesID = currentSelection.candidate.speciesID; //SetHistorySelectedSpeciesUI(candidate.speciesID); uiManager.historyPanelUI.InitializePanel(); //uiManager.historyPanelUI.RefreshFocusedAgent(currentSelection.agent); uiManager.speciesOverviewUI.RebuildGenomeButtons(); if (hasAgent) { unlockedTech = currentSelection.candidate.candidateGenome.bodyGenome.unlockedTech; //PrintTech(); } }
// * WPP: extremely inefficient! // Remove GetComponent calls, use nested struct pattern to store references public void UpdateExtras(CandidateAgentData candidate) { //textRest.gameObject.SetActive(false); //textDash.gameObject.SetActive(false); //textGuard.gameObject.SetActive(false); //textBite.gameObject.SetActive(false); //textAttack.gameObject.SetActive(false); //textOther.gameObject.SetActive(false); outComm0.GetComponent <Image>().color = Color.Lerp(Color.black, Color.white, 0f); outComm0.GetComponent <TooltipUI>().tooltipString = "OutComm0"; outComm1.GetComponent <Image>().color = Color.Lerp(Color.black, Color.white, 0f); outComm1.GetComponent <TooltipUI>().tooltipString = "OutComm1"; outComm2.GetComponent <Image>().color = Color.Lerp(Color.black, Color.white, 0f); outComm2.GetComponent <TooltipUI>().tooltipString = "OutComm2"; outComm3.GetComponent <Image>().color = Color.Lerp(Color.black, Color.white, 0f); outComm3.GetComponent <TooltipUI>().tooltipString = "OutComm3"; float sigma = 0f; throttleGO.transform.rotation = Quaternion.Euler(0f, 0f, sigma); throttleGO.transform.localScale = Vector3.zero; float sigmaWater = 0f; waterVelGO.transform.rotation = Quaternion.Euler(0f, 0f, sigmaWater); waterVelGO.transform.localScale = Vector3.zero; contactForceGO.SetActive(false); float sigmaFood0 = 0f; food0.transform.rotation = Quaternion.Euler(0f, 0f, sigmaFood0); float sigmaFood1 = 0f; food1.transform.rotation = Quaternion.Euler(0f, 0f, sigmaFood1); float sigmaFood2 = 0f; food2.transform.rotation = Quaternion.Euler(0f, 0f, sigmaFood2); }
// * Consider Refactor: move life stage to candidate public void SetDisplay(CandidateAgentData candidate) { var iconSprite = lookup.GetAgentLifeStageIcon(AgentLifeStage.Dead, true); // Fossil // POSITION currentCoords = Vector2.Lerp(currentCoords, targetCoords, 0.75f); gameObject.transform.localPosition = new Vector3(currentCoords.x * 360f, currentCoords.y * 360f, 0f); string statusStr = ""; if (candidate.isBeingEvaluated) { Agent matchingAgent = simulationManager.GetAgent(candidate); bool isFocus = selectionManager.IsSelected(candidate); ColorBlock block = button.colors; block.colorMultiplier = isFocus ? 2f : 1f; button.colors = block; statusStr = isFocus ? SetBackground(selectedState) : SetBackgroundByLifeStage(matchingAgent); iconSprite = lookup.GetAgentLifeStageIcon(matchingAgent.curLifeStage, matchingAgent.isYoung); } else { var background = candidate.allEvaluationsComplete ? fossilState : unbornState; statusStr = SetBackground(background); if (!candidate.allEvaluationsComplete) { gameObject.SetActive(false); } } backgroundImage.sprite = iconSprite; //tooltip.genomeViewerUIRef = uiManagerRef.genomeViewerUI; tooltip.tooltipString = "" + candidate.candidateGenome.name + "\nAge " + candidate.performanceData.totalTicksAlive;// + ", " + statusStr; //uiManagerRef.speciesOverviewUI.leaderboardGenomeButtonsList.Add(buttonScript); }
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); }
Color GetCreatureLineColor(Vector3 hue, CandidateAgentData candidate, bool inXBounds) { Color color = new Color(hue.x, hue.y, hue.z); //if (xStart > xCoord || xEnd < xCoord) { if (!inXBounds) { //hue = Vector3.zero; color.a = 0f; } else if (candidate.candidateID == selectionManager.currentSelection.candidate.candidateID) { //hue = Vector3.one; color.r = 1f; color.g = 1f; color.b = 1f; color.a = 1f; } if (!candidate.isBeingEvaluated && candidate.numCompletedEvaluations == 0) { //hue = Vector3.zero; color.a = 0f; } if (candidate.performanceData.timeStepHatched <= 1) { //hue = Vector3.zero; color.a = 0f; } if (candidate.performanceData.totalTicksAlive >= 1) { color.r *= 0.35f; color.g *= 0.35f; color.b *= 0.35f; } return(color); }
/// Simple list, evenly spaced private void UpdateSpeciesIconsSinglePop() { foreach (var icon in speciesIcons) { // DEFAULTS float xCoord = -0.2f; float yCoord = 0.2f;// (float)s / Mathf.Max(speciesIconsList.Count - 1, 1f); int prevSpeciesIndex = selectionManager.currentSelection.historySelectedSpeciesID - 1; if (prevSpeciesIndex < 0) { prevSpeciesIndex = masterGenomePool.completeSpeciesPoolsList.Count - 1; } int nextSpeciesIndex = selectionManager.currentSelection.historySelectedSpeciesID + 1; if (nextSpeciesIndex >= masterGenomePool.completeSpeciesPoolsList.Count) { nextSpeciesIndex = 0; } // CYCLE PREV SPECIES if (icon.linkedPool.speciesID == prevSpeciesIndex) { xCoord = 0f; yCoord = 1f; } // SELECTED if (icon.linkedPool.speciesID == selectionManager.currentSelection.historySelectedSpeciesID) { xCoord = 0f; yCoord = 0.5f; } // CYCLE NEXT SPECIES if (icon.linkedPool.speciesID == nextSpeciesIndex) { xCoord = 0f; yCoord = 0f; } xCoord = xCoord * displayWidth + marginLeft; yCoord = yCoord * displayHeight + marginBottom; icon.SetTargetCoords(new Vector2(xCoord, yCoord)); } //*** UPDATE CREATURE ICONS!!!!!! v v v SpeciesGenomePool pool = simManager.masterGenomePool.completeSpeciesPoolsList[selectionManager.currentSelection.historySelectedSpeciesID]; int numAgentsDisplayed = Mathf.Max(pool.GetNumberAgentsEvaluated(), 1); // avoid divide by 0 for (int line = 0; line < worldTreeNumCreatureLines; line++) { if (line >= pool.candidateGenomesList.Count) { continue; } CandidateAgentData cand = pool.candidateGenomesList[line]; float xCoord = 1f; float yCoord = 1f - (float)line / (float)numAgentsDisplayed; Vector3 hue = pool.foundingCandidate.candidateGenome.bodyGenome.appearanceGenome.huePrimary * 2f; int timeStepStart = Mathf.RoundToInt(timelineStartTimeStep); if (pool.isExtinct || cand.performanceData.timeStepDied > 1) { xCoord = (float)(cand.performanceData.timeStepDied - timeStepStart) / (float)(simManager.simAgeTimeSteps - timeStepStart); } xCoord = xCoord * displayWidth + marginLeft; yCoord = yCoord * displayHeight + marginBottom; //***EAC FIX! uiManagerRef.speciesOverviewUI.SetButtonPos(line, new Vector3(xCoord * (float)panelSizePixels, yCoord * (float)panelSizePixels, 0f)); } }
public void AddNewCandidateGenome(AgentGenome newGenome) { //Debug.Log("AddedNewCandidate! " + candidateGenomesList.Count.ToString()); CandidateAgentData newCandidateData = new CandidateAgentData(newGenome, speciesID); candidateGenomesList.Add(newCandidateData); }
private void CreateNewAverageCandidate() { AgentGenome blankGenome = new AgentGenome(.1f, 0); avgCandidateData = new CandidateAgentData(blankGenome, speciesID); avgCandidateData.SetToAverage(leaderboardGenomesList); }
//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(); }
public void UpdateButtonPrefab(CandidateAgentData data) { candidateData = data; }
public bool IsSelected(CandidateAgentData candidate) { return(candidate.candidateID == currentSelection.candidate.candidateID); }