// 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]); }
// Current Genepool private void RebuildGenomeButtonsCurrent(SpeciesGenomePool pool) { Vector3 hue = pool.foundingCandidate.candidateGenome.bodyGenome.appearanceGenome.huePrimary; genomeLeaderboard.color = new Color(hue.x, hue.y, hue.z); UpdateButtons(pool.candidateGenomesList, SelectionGroup.Candidates); }
//public Sprite sprite; //public Image imageColor1; //public Image imageColor2; //public Image imageColor3; public void Initialize(int index, SpeciesGenomePool pool, Transform anchor, Color color) { linkedPool = pool; speciesID = pool.speciesID; targetCoords = Vector2.zero; //Debug.Log("NEW BUTTON! " + index + ", " + pool.speciesID); transform.SetParent(anchor, false); transform.localPosition = Vector3.zero; transform.localScale = new Vector3(1f, 1f, 1f); image.color = Color.white; image.material = pool.coatOfArmsMat; //image.material.SetPass(0); //sprite = Sprite.Create(pool.GetCoatOfArms(), image.rectTransform.rect, Vector2.one * 0.5f); //sprite.name = "whoaSprite!"; //image.sprite = sprite; //image.GetComponent<CanvasRenderer>().SetTexture(pool.GetCoatOfArms()); if (pool == null) { Debug.LogError("pool NULL"); return; } //text.text = "[" + pool.speciesID + "]";// " + masterGenomePool.completeSpeciesPoolsList[pool.speciesID].foundingCandidate.candidateGenome.bodyGenome.coreGenome.name; }
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); }
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 RebuildGenomeButtons() { SpeciesGenomePool pool = simulationManager.masterGenomePool.completeSpeciesPoolsList[selectionManager.currentSelection.candidate.speciesID]; //SetSpeciesIconColors(pool.appearanceGenome); textSpeciesLineage.gameObject.SetActive(true); textSpeciesLineage.text = GetLineageText(pool); //RebuildGenomeButtonsLineage(pool); RebuildGenomeButtonsCurrent(pool); }
void SortSpeciesIcons(float bestScore) { foreach (var icon in speciesIcons) { SpeciesGenomePool pool = icon.linkedPool; float valStat = pool.avgCandidateDataYearList[pool.avgCandidateDataYearList.Count - 1].performanceData.totalTicksAlive; float xCoord = pool.isExtinct ? (float)pool.timeStepExtinct / Mathf.Max(1f, (float)simManager.simAgeTimeSteps) : 1f; float yCoord = Mathf.Clamp01(valStat / bestScore); xCoord = xCoord * displayWidth + marginLeft; yCoord = yCoord * displayHeight + marginBottom; icon.SetTargetCoords(new Vector2(xCoord, yCoord)); } }
public void AddNewSpecies(MasterGenomePool masterGenomePool, int newSpeciesID) { SpeciesGenomePool speciesPool = masterGenomePool.completeSpeciesPoolsList[newSpeciesID]; // RaycastColliderGameObject: GameObject speciesNodeColliderGO = new GameObject("SpeciesNodeRaycastCollider_" + newSpeciesID.ToString()); speciesNodeColliderGO.transform.parent = treeOfLifeAnchorGO.transform; speciesNodeColliderGO.transform.localPosition = Vector3.zero; // new Vector3(-1f * (float)speciesPool.depthLevel, UnityEngine.Random.Range(-2f, 0f), 0f) * scaleMultiplier; speciesNodeColliderGO.transform.localScale = Vector3.one * colliderBaseScaleMultiplier * camScale; TreeOfLifeNodeRaycastTarget rayTarget = speciesNodeColliderGO.AddComponent <TreeOfLifeNodeRaycastTarget>(); rayTarget.Initialize(speciesPool); rayTarget.rayCollider = speciesNodeColliderGO.AddComponent <CapsuleCollider>(); rayTarget.rayCollider.isTrigger = true; nodeRaycastTargetsList.Add(rayTarget); }
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 void ChangeSelectedGenome(SelectionGroup group, int index) { SpeciesGenomePool pool = simulationManager.GetSelectedGenomePool(); //selectionManager.SetFocusedCandidateGenome(pool, group, index); selectedButtonData = GetSelectionGroupData(group); uiManager.historyPanelUI.buttonSelCreatureEventsLink.gameObject.transform.localPosition = new Vector3(360f, 180f, 0f); if (group == SelectionGroup.Candidates) { selectionManager.SetSelected(pool.candidateGenomesList[index]); } if (selectedButtonData != null && selectedButtonData.image != null) { selectedButtonData.image.color = Color.white; // new Vector3(selectedButtonData.image.rectTransform.localPosition.x + 24f, selectedButtonData.image.rectTransform.localPosition.y, 0f); } panelGenomeViewer.SetActive(true); //uiManager.historyPanelUI.buttonSelCreatureEventsLink.GetComponent<RectTransform>().localPosition = Vector3.one * 4.2f; }
private string GetLineageText(SpeciesGenomePool pool) { int savedSpeciesID = pool.speciesID; int parentSpeciesID = pool.parentSpeciesID; string lineage = savedSpeciesID.ToString(); for (int i = 0; i < 64; i++) { if (parentSpeciesID < 0) { lineage += "*"; break; } SpeciesGenomePool parentPool = simulationManager.GetGenomePoolBySpeciesID(parentSpeciesID); lineage += " <- " + parentPool.speciesID; savedSpeciesID = parentPool.speciesID; parentSpeciesID = parentPool.parentSpeciesID; } return(lineage); }
public void CreateSpeciesLeaderboardGenomeTexture() { int width = 32; int height = 96; speciesPoolGenomeTex.Resize(width, height); SpeciesGenomePool pool = simulationManager.GetSelectedGenomePool(); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { LinkGenome linkGenome = pool.GetLeaderboardLinkGenome(x, y); Color testColor = linkGenome == null ? CLEAR : Color.Lerp(negativeColor, positiveColor, linkGenome.normalizedWeight); speciesPoolGenomeTex.SetPixel(x, y, testColor); } } // Body Genome //int xI = curLinearIndex % speciesPoolGenomeTex.width; //int yI = Mathf.FloorToInt(curLinearIndex / speciesPoolGenomeTex.width); speciesPoolGenomeTex.Apply(); }
public void AddNewSpeciesToPanel(SpeciesGenomePool pool) { //Debug.Log("AddNewSpeciesToPanelUI: " + pool.speciesID); CreateSpeciesIcon(pool); }
// Hall of fame genomes (checkpoints .. every 50 years?) private void RebuildGenomeButtonsLineage(SpeciesGenomePool pool) { UpdateButtons(pool.hallOfFameGenomesList, SelectionGroup.HallOfFame); }
public void UpdateSpeciesTreeDataTextures(int year) { Initialize(); int numActiveSpecies = masterGenomePool.currentlyActiveSpeciesIDList.Count; int numTotalSpecies = masterGenomePool.completeSpeciesPoolsList.Count; //int maxDisplaySpecies = 32; int[] displaySpeciesIndicesArray; displaySpeciesIndicesArray = new int[maxDisplaySpecies]; TreeOfLifeSpeciesKeyData[] speciesKeyDataArray = new TreeOfLifeSpeciesKeyData[32]; // Get Active ones first: for (int i = 0; i < masterGenomePool.currentlyActiveSpeciesIDList.Count; i++) { SpeciesGenomePool pool = masterGenomePool.completeSpeciesPoolsList[masterGenomePool.currentlyActiveSpeciesIDList[i]]; SpeciesGenomePool parentPool; Vector3 parentHue = Vector3.one; if (pool.parentSpeciesID != -1) { parentPool = masterGenomePool.completeSpeciesPoolsList[pool.parentSpeciesID]; parentHue = parentPool.representativeCandidate.candidateGenome.bodyGenome.appearanceGenome.huePrimary; } Vector3 huePrimary = pool.representativeCandidate.candidateGenome.bodyGenome.appearanceGenome.huePrimary; statsSpeciesColorKey?.SetPixel(i, 1, new Color(huePrimary.x, huePrimary.y, huePrimary.z)); //Debug.Log("(" + i.ToString() + ", " + gameManager.simulationManager.masterGenomePool.currentlyActiveSpeciesIDList[i].ToString()); displaySpeciesIndicesArray[i] = masterGenomePool.currentlyActiveSpeciesIDList[i]; var isSelected = selectionManager.currentSelection.historySelectedSpeciesID == masterGenomePool.currentlyActiveSpeciesIDList[i] ? 1f : 0f; TreeOfLifeSpeciesKeyData keyData = new TreeOfLifeSpeciesKeyData(pool, isSelected, parentHue); // WPP: use constructor //Vector3 hueSecondary = pool.representativeCandidate.candidateGenome.bodyGenome.appearanceGenome.hueSecondary; /*keyData.timeCreated = pool.timeStepCreated; // Use TimeSteps instead of Years??? * keyData.timeExtinct = pool.timeStepExtinct; * keyData.huePrimary = huePrimary; * keyData.hueSecondary = hueSecondary; * keyData.parentHue = parentHue; * keyData.isExtinct = pool.isExtinct ? 1f : 0f; * keyData.isOn = 1f; * //int selectedID = treeOfLifeManager.selectedID; * keyData.isSelected = selectionManager.selectedSpeciesID == masterGenomePool.currentlyActiveSpeciesIDList[i] ? 1f : 0f;*/ speciesKeyDataArray[i] = keyData; } // Then fill with most recently extinct: for (int i = numTotalSpecies - 1; i > Mathf.Clamp(numTotalSpecies - maxDisplaySpecies, 0, numTotalSpecies); i--) { SpeciesGenomePool pool = masterGenomePool.completeSpeciesPoolsList[i]; SpeciesGenomePool parentPool = pool.parentSpeciesID == -1 ? pool : masterGenomePool.completeSpeciesPoolsList[pool.parentSpeciesID]; Vector3 huePrimary = pool.representativeCandidate.candidateGenome.bodyGenome.appearanceGenome.huePrimary; Vector3 hueSecondary = pool.representativeCandidate.candidateGenome.bodyGenome.appearanceGenome.hueSecondary; Vector3 parentHue = parentPool.representativeCandidate.candidateGenome.bodyGenome.appearanceGenome.huePrimary; if (masterGenomePool.completeSpeciesPoolsList[i].isExtinct) { huePrimary = Vector3.zero; } statsSpeciesColorKey.SetPixel(i, 1, new Color(huePrimary.x, huePrimary.y, huePrimary.z)); displaySpeciesIndicesArray[i] = i; TreeOfLifeSpeciesKeyData keyData = new TreeOfLifeSpeciesKeyData(); keyData.timeCreated = pool.timeStepCreated; // Use TimeSteps instead of Years??? keyData.timeExtinct = pool.timeStepExtinct; keyData.huePrimary = huePrimary; keyData.hueSecondary = hueSecondary; keyData.parentHue = parentHue; keyData.isExtinct = pool.isExtinct ? 1f : 0f; keyData.isOn = i >= masterGenomePool.completeSpeciesPoolsList.Count || pool.yearCreated == -1 || i == 0 ? 0f : 1f; keyData.isSelected = selectionManager.currentSelection.historySelectedSpeciesID == i ? 1f : 0f; speciesKeyDataArray[i] = keyData; } statsSpeciesColorKey.Apply(); //uiManagerRef.gameManager.simulationManager.theRenderKing.treeOfLifeSpeciesDataKeyCBuffer.SetData(speciesKeyDataArray); // ========== data: =========== // int years = Mathf.Min(2048, year); // cap textures at 2k for now? years = Mathf.Max(1, years); // check for resize before doing it? foreach (var texture in statsTreeOfLifeSpeciesTexArray) { texture.Resize(years, maxDisplaySpecies); } for (int i = 0; i < maxValuesStatArray.Length; i++) { maxValuesStatArray[i] = 0.0000001f; minValuesStatArray[i] = 1000000f; } // for each year & each species, create 2D texture with fitness scores: for (int s = 0; s < maxDisplaySpecies; s++) { if (displaySpeciesIndicesArray[s] < masterGenomePool.completeSpeciesPoolsList.Count) { SpeciesGenomePool speciesPool = masterGenomePool.completeSpeciesPoolsList[displaySpeciesIndicesArray[s]]; if (speciesPool == null) { Debug.LogError("speciesPool is null"); } for (int t = 0; t < years; t++) { for (int a = 0; a < statsTreeOfLifeSpeciesTexArray.Length; a++) { float valStat = 0f; if (speciesPool.avgCandidateDataYearList.Count > t) { valStat = (float)speciesPool.avgCandidateDataYearList[t].performanceData.totalTicksAlive; //0f; //Debug.Log("valStat: " + valStat.ToString()); } if (years > 15) { float time01 = (float)t / (float)years; // Don't use first 5% of history towards stat range! if (time01 >= 0.05f) { minValuesStatArray[a] = Mathf.Min(minValuesStatArray[a], valStat); maxValuesStatArray[a] = Mathf.Max(maxValuesStatArray[a], valStat); } } else { minValuesStatArray[a] = Mathf.Min(minValuesStatArray[a], valStat); maxValuesStatArray[a] = Mathf.Max(maxValuesStatArray[a], valStat); } statsTreeOfLifeSpeciesTexArray[a].SetPixel(t, s, new Color(valStat, valStat, valStat, 1f)); } } } } foreach (var texture in statsTreeOfLifeSpeciesTexArray) { texture.Apply(); } //RefreshGraphMaterial(); }
private void RefreshGraphMaterial() { //Debug.Log("RefreshGraphMaterial " + statsTreeOfLifeSpeciesTexArray[0].width.ToString() + ", " + maxValuesStatArray[0].ToString()); SpeciesGenomePool pool = masterGenomePool.completeSpeciesPoolsList[selectionManager.currentSelection.historySelectedSpeciesID]; switch (selectedGraphCategory) { case GraphCategory.Life: speciesGraphMatLeft.SetTexture("_MainTex", statsTreeOfLifeSpeciesTexArray[0]); speciesGraphMatLeft.SetTexture("_ColorKeyTex", statsSpeciesColorKey); speciesGraphMatLeft.SetFloat("_NumEntries", statsTreeOfLifeSpeciesTexArray[0].width); speciesGraphMatLeft.SetInt("_SelectedSpeciesID", selectionManager.currentSelection.historySelectedSpeciesID); speciesGraphMatLeft.SetFloat("_MaximumValue", maxValuesStatArray[0]); speciesGraphMatLeft.SetFloat("_MinimumValue", minValuesStatArray[0]); speciesGraphMatCenter.SetTexture("_MainTex", statsTreeOfLifeSpeciesTexArray[14]); speciesGraphMatCenter.SetTexture("_ColorKeyTex", statsSpeciesColorKey); speciesGraphMatCenter.SetFloat("_NumEntries", statsTreeOfLifeSpeciesTexArray[14].width); speciesGraphMatCenter.SetInt("_SelectedSpeciesID", selectionManager.currentSelection.historySelectedSpeciesID); speciesGraphMatCenter.SetFloat("_MaximumValue", maxValuesStatArray[14]); speciesGraphMatCenter.SetFloat("_MinimumValue", minValuesStatArray[14]); speciesGraphMatRight.SetTexture("_MainTex", statsTreeOfLifeSpeciesTexArray[15]); speciesGraphMatRight.SetTexture("_ColorKeyTex", statsSpeciesColorKey); speciesGraphMatRight.SetFloat("_NumEntries", statsTreeOfLifeSpeciesTexArray[15].width); speciesGraphMatRight.SetInt("_SelectedSpeciesID", selectionManager.currentSelection.historySelectedSpeciesID); speciesGraphMatRight.SetFloat("_MaximumValue", maxValuesStatArray[15]); speciesGraphMatRight.SetFloat("_MinimumValue", minValuesStatArray[15]); //curSpeciesStatValue = pool.avgDamageDealt; //curSpeciesStatName = "Damage Dealt"; textGraphStatsLeft.text = "LIFESPAN\n" + pool.avgCandidateData.performanceData.totalTicksAlive.ToString(); // + ", M: " + maxValuesStatArray[selectedSpeciesStatsIndex].ToString() + ", m: " + minValuesStatArray[selectedSpeciesStatsIndex].ToString(); textGraphStatsCenter.text = "DMG DEALT\n" + pool.avgCandidateData.performanceData.totalDamageDealt.ToString(); textGraphStatsRight.text = "DMG TAKEN\n" + pool.avgCandidateData.performanceData.totalDamageTaken.ToString(); textGraphCategory.text = "HEALTH"; break; case GraphCategory.Body: speciesGraphMatLeft.SetTexture("_MainTex", statsTreeOfLifeSpeciesTexArray[4]); speciesGraphMatLeft.SetTexture("_ColorKeyTex", statsSpeciesColorKey); speciesGraphMatLeft.SetFloat("_NumEntries", statsTreeOfLifeSpeciesTexArray[4].width); speciesGraphMatLeft.SetInt("_SelectedSpeciesID", selectionManager.currentSelection.historySelectedSpeciesID); speciesGraphMatLeft.SetFloat("_MaximumValue", maxValuesStatArray[4]); speciesGraphMatLeft.SetFloat("_MinimumValue", minValuesStatArray[4]); speciesGraphMatCenter.SetTexture("_MainTex", statsTreeOfLifeSpeciesTexArray[12]); speciesGraphMatCenter.SetTexture("_ColorKeyTex", statsSpeciesColorKey); speciesGraphMatCenter.SetFloat("_NumEntries", statsTreeOfLifeSpeciesTexArray[12].width); speciesGraphMatCenter.SetInt("_SelectedSpeciesID", selectionManager.currentSelection.historySelectedSpeciesID); speciesGraphMatCenter.SetFloat("_MaximumValue", maxValuesStatArray[12]); speciesGraphMatCenter.SetFloat("_MinimumValue", minValuesStatArray[12]); speciesGraphMatRight.SetTexture("_MainTex", statsTreeOfLifeSpeciesTexArray[13]); speciesGraphMatRight.SetTexture("_ColorKeyTex", statsSpeciesColorKey); speciesGraphMatRight.SetFloat("_NumEntries", statsTreeOfLifeSpeciesTexArray[13].width); speciesGraphMatRight.SetInt("_SelectedSpeciesID", selectionManager.currentSelection.historySelectedSpeciesID); speciesGraphMatRight.SetFloat("_MaximumValue", maxValuesStatArray[13]); speciesGraphMatRight.SetFloat("_MinimumValue", minValuesStatArray[13]); //textGraphStatsLeft.text = "BODYSIZE\n" + pool.avgBodySize.ToString(); //textGraphStatsCenter.text = "NEURONS\n" + pool.avgNumNeurons.ToString(); //textGraphStatsRight.text = "AXONS\n" + pool.avgNumAxons.ToString(); textGraphCategory.text = "BODY & BRAIN"; break; case GraphCategory.Talents: speciesGraphMatLeft.SetTexture("_MainTex", statsTreeOfLifeSpeciesTexArray[5]); speciesGraphMatLeft.SetTexture("_ColorKeyTex", statsSpeciesColorKey); speciesGraphMatLeft.SetFloat("_NumEntries", statsTreeOfLifeSpeciesTexArray[5].width); speciesGraphMatLeft.SetInt("_SelectedSpeciesID", selectionManager.currentSelection.historySelectedSpeciesID); speciesGraphMatLeft.SetFloat("_MaximumValue", maxValuesStatArray[5]); speciesGraphMatLeft.SetFloat("_MinimumValue", minValuesStatArray[5]); speciesGraphMatCenter.SetTexture("_MainTex", statsTreeOfLifeSpeciesTexArray[6]); speciesGraphMatCenter.SetTexture("_ColorKeyTex", statsSpeciesColorKey); speciesGraphMatCenter.SetFloat("_NumEntries", statsTreeOfLifeSpeciesTexArray[6].width); speciesGraphMatCenter.SetInt("_SelectedSpeciesID", selectionManager.currentSelection.historySelectedSpeciesID); speciesGraphMatCenter.SetFloat("_MaximumValue", maxValuesStatArray[6]); speciesGraphMatCenter.SetFloat("_MinimumValue", minValuesStatArray[6]); speciesGraphMatRight.SetTexture("_MainTex", statsTreeOfLifeSpeciesTexArray[7]); speciesGraphMatRight.SetTexture("_ColorKeyTex", statsSpeciesColorKey); speciesGraphMatRight.SetFloat("_NumEntries", statsTreeOfLifeSpeciesTexArray[7].width); speciesGraphMatRight.SetInt("_SelectedSpeciesID", selectionManager.currentSelection.historySelectedSpeciesID); speciesGraphMatRight.SetFloat("_MaximumValue", maxValuesStatArray[7]); speciesGraphMatRight.SetFloat("_MinimumValue", minValuesStatArray[7]); textGraphCategory.text = "SPECIALIZATIONS"; break; case GraphCategory.Eaten: speciesGraphMatLeft.SetTexture("_MainTex", statsTreeOfLifeSpeciesTexArray[1]); speciesGraphMatLeft.SetTexture("_ColorKeyTex", statsSpeciesColorKey); speciesGraphMatLeft.SetFloat("_NumEntries", statsTreeOfLifeSpeciesTexArray[1].width); speciesGraphMatLeft.SetInt("_SelectedSpeciesID", selectionManager.currentSelection.historySelectedSpeciesID); speciesGraphMatLeft.SetFloat("_MaximumValue", maxValuesStatArray[1]); speciesGraphMatLeft.SetFloat("_MinimumValue", minValuesStatArray[1]); speciesGraphMatCenter.SetTexture("_MainTex", statsTreeOfLifeSpeciesTexArray[2]); speciesGraphMatCenter.SetTexture("_ColorKeyTex", statsSpeciesColorKey); speciesGraphMatCenter.SetFloat("_NumEntries", statsTreeOfLifeSpeciesTexArray[2].width); speciesGraphMatCenter.SetInt("_SelectedSpeciesID", selectionManager.currentSelection.historySelectedSpeciesID); speciesGraphMatCenter.SetFloat("_MaximumValue", maxValuesStatArray[2]); speciesGraphMatCenter.SetFloat("_MinimumValue", minValuesStatArray[2]); speciesGraphMatRight.SetTexture("_MainTex", statsTreeOfLifeSpeciesTexArray[3]); speciesGraphMatRight.SetTexture("_ColorKeyTex", statsSpeciesColorKey); speciesGraphMatRight.SetFloat("_NumEntries", statsTreeOfLifeSpeciesTexArray[3].width); speciesGraphMatRight.SetInt("_SelectedSpeciesID", selectionManager.currentSelection.historySelectedSpeciesID); speciesGraphMatRight.SetFloat("_MaximumValue", maxValuesStatArray[3]); speciesGraphMatRight.SetFloat("_MinimumValue", minValuesStatArray[3]); textGraphCategory.text = "FOOD CONSUMED"; break; case GraphCategory.DigestSpec: speciesGraphMatLeft.SetTexture("_MainTex", statsTreeOfLifeSpeciesTexArray[10]); speciesGraphMatLeft.SetTexture("_ColorKeyTex", statsSpeciesColorKey); speciesGraphMatLeft.SetFloat("_NumEntries", statsTreeOfLifeSpeciesTexArray[10].width); speciesGraphMatLeft.SetInt("_SelectedSpeciesID", selectionManager.currentSelection.historySelectedSpeciesID); speciesGraphMatLeft.SetFloat("_MaximumValue", maxValuesStatArray[10]); speciesGraphMatLeft.SetFloat("_MinimumValue", minValuesStatArray[10]); speciesGraphMatCenter.SetTexture("_MainTex", statsTreeOfLifeSpeciesTexArray[11]); speciesGraphMatCenter.SetTexture("_ColorKeyTex", statsSpeciesColorKey); speciesGraphMatCenter.SetFloat("_NumEntries", statsTreeOfLifeSpeciesTexArray[11].width); speciesGraphMatCenter.SetInt("_SelectedSpeciesID", selectionManager.currentSelection.historySelectedSpeciesID); speciesGraphMatCenter.SetFloat("_MaximumValue", maxValuesStatArray[11]); speciesGraphMatCenter.SetFloat("_MinimumValue", minValuesStatArray[11]); speciesGraphMatRight.SetTexture("_MainTex", statsTreeOfLifeSpeciesTexArray[9]); speciesGraphMatRight.SetTexture("_ColorKeyTex", statsSpeciesColorKey); speciesGraphMatRight.SetFloat("_NumEntries", statsTreeOfLifeSpeciesTexArray[9].width); speciesGraphMatRight.SetInt("_SelectedSpeciesID", selectionManager.currentSelection.historySelectedSpeciesID); speciesGraphMatRight.SetFloat("_MaximumValue", maxValuesStatArray[9]); speciesGraphMatRight.SetFloat("_MinimumValue", minValuesStatArray[9]); textGraphCategory.text = "DIGESTION BONUSES"; break; default: break; } //speciesGraphImage.material = speciesGraphMatLeft; //speciesGraphImage.gameObject.SetActive(false); //speciesGraphImage.gameObject.SetActive(true); }
/// 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 int speciesID; //public bool isActive; // extinct or not? public TreeOfLifeSpeciesNodeData(SpeciesGenomePool speciesPool) { this.speciesPool = speciesPool; //speciesID = speciesPool.speciesID; //isActive = !speciesPool.isExtinct; }
void CreateSpeciesLine(int line, int point, Vector2 cursorCoords, WorldTreeLineData[] worldTreeLines) { int index = line * worldTreeNumPointsPerLine + point; if (line >= simManager.masterGenomePool.completeSpeciesPoolsList.Count) { return; } SpeciesGenomePool pool = simManager.masterGenomePool.completeSpeciesPoolsList[line]; WorldTreeLineData data = new WorldTreeLineData(); if (isAllSpeciesMode) { if (isGraphMode) { int graphDataYearIndexStart = 0; int graphDataYearIndexEnd = 0; if (pool.avgCandidateDataYearList.Count == 0) { return; } float xCoord = (float)(point % worldTreeNumPointsPerLine) / (float)worldTreeNumPointsPerLine; int count = Mathf.Max(0, pool.avgCandidateDataYearList.Count - 1); graphDataYearIndexStart = Mathf.FloorToInt((float)count * xCoord); graphDataYearIndexEnd = Mathf.CeilToInt((float)count * xCoord); float frac = ((float)count * xCoord) % 1f; float valStart = (float)pool.avgCandidateDataYearList[graphDataYearIndexStart].performanceData.totalTicksAlive / uiManagerRef.speciesGraphPanelUI.maxValuesStatArray[0]; float valEnd = (float)pool.avgCandidateDataYearList[graphDataYearIndexEnd].performanceData.totalTicksAlive / uiManagerRef.speciesGraphPanelUI.maxValuesStatArray[0]; //valEnd = Mathf.Clamp(valEnd, 0, pool.avgCandidateDataYearList.Count - 1); float yCoord = Mathf.Lerp(valStart, valEnd, frac); // Mathf.Sin(xCoord / orbitalPeriod * (simManager.simAgeTimeSteps) * animTimeScale) * 0.075f * (float)lineID + 0.5f; float zCoord = 0f; Vector3 hue = pool.foundingCandidate.candidateGenome.bodyGenome.appearanceGenome.huePrimary; float alpha = 1f; int timeStepStart = Mathf.RoundToInt(timelineStartTimeStep); float xStart01 = (float)(pool.timeStepCreated - timeStepStart) / (float)(simManager.simAgeTimeSteps - timeStepStart); float xEnd01 = pool.isExtinct ? (float)(pool.timeStepExtinct - timeStepStart) / (float)(simManager.simAgeTimeSteps - timeStepStart) : 1f; if (pool.speciesID == selectionManager.currentSelection.historySelectedSpeciesID) { hue = Vector3.one; zCoord = -0.1f; } if (xStart01 > xCoord || xEnd01 < xCoord) { hue = Vector3.zero; alpha = 0f; } xCoord = xCoord * displayWidth + marginLeft; // rescaling --> make this more robust yCoord = yCoord * displayHeight + marginBottom; if ((new Vector2(xCoord, yCoord) - cursorCoords).magnitude < 0.05f) { //data.color = Color.white; hue = Vector3.Lerp(hue, Vector3.one, 0.8f); //alpha = 1f; } data.worldPos = new Vector3(xCoord, yCoord, zCoord); data.color = new Color(hue.x, hue.y, hue.z, alpha);// Color.HSVToRGB(lerp, 1f - lerp, 1f); // Color.Lerp(Color.white, Color.black, lineID * 0.11215f); } else { // LINEAGE: float xCoord = (float)point / (float)worldTreeNumPointsPerLine; float yCoord = 1f - ((float)pool.speciesID / (float)Mathf.Max(simManager.masterGenomePool.completeSpeciesPoolsList.Count - 1, 1)); // Mathf.Sin(xCoord / orbitalPeriod * (simManager.simAgeTimeSteps) * animTimeScale) * 0.075f * (float)lineID + 0.5f; float zCoord = 0f; Vector3 hue = pool.foundingCandidate.candidateGenome.bodyGenome.appearanceGenome.huePrimary; float alpha = 1f; int timeStepStart = Mathf.RoundToInt(timelineStartTimeStep); float xStart01 = (float)(pool.timeStepCreated - timeStepStart) / (float)(simManager.simAgeTimeSteps - timeStepStart); float xEnd01 = 1f; if (pool.isExtinct) { xEnd01 = (float)(pool.timeStepExtinct - timeStepStart) / (float)(simManager.simAgeTimeSteps - timeStepStart); } if (xStart01 > xCoord || xEnd01 < xCoord) { hue = Vector3.zero; alpha = 0f; } if (pool.speciesID == selectionManager.currentSelection.historySelectedSpeciesID) { hue = Vector3.one; zCoord = -0.1f; } data.color = new Color(hue.x, hue.y, hue.z, alpha); // 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; if ((new Vector2(xCoord, yCoord) - cursorCoords).magnitude < 0.05f) { data.color = Color.white; } data.worldPos = new Vector3(xCoord, yCoord, zCoord); } } if (curPanelMode == HistoryPanelMode.SpeciesPopulation || curPanelMode == HistoryPanelMode.CreatureTimeline) { data.worldPos = Vector3.zero; data.color = new Color(0f, 0f, 0f, 0f); } worldTreeLines[index] = data; }
public void Initialize(SpeciesGenomePool speciesRef) { this.speciesRef = speciesRef; }
/* * string[] strSpiritBrushDescriptionArray = new string[6]; // = "Decomposers break down the old so that new life can grow."; * strSpiritBrushDescriptionArray[0] = "Provides information about the world and its contents, and chronicles events through time"; * strSpiritBrushDescriptionArray[1] = "This spirit possesses limited control of life & existence itself"; * strSpiritBrushDescriptionArray[2] = "A mysterious Kelpie able to control the flow of water"; * strSpiritBrushDescriptionArray[3] = "A Watcher Spirit can track an organism's journey through space and time"; * strSpiritBrushDescriptionArray[4] = "Mutate... blah blah"; * strSpiritBrushDescriptionArray[5] = "Extra."; * * string[] strLinkedSpiritDescriptionArray = new string[12]; // = "Decomposers break down the old so that new life can grow."; * strLinkedSpiritDescriptionArray[0] = "The World Spirit provides the spark for a new universe"; * strLinkedSpiritDescriptionArray[1] = "Stone Spirits are some of the oldest known"; * strLinkedSpiritDescriptionArray[2] = "Pebble Spirits are usually found in rivers and streams"; * strLinkedSpiritDescriptionArray[3] = "Sand Spirits"; * strLinkedSpiritDescriptionArray[4] = "Mineral Spirits infuse nutrients into the earth."; * strLinkedSpiritDescriptionArray[5] = "Water Spirits"; * strLinkedSpiritDescriptionArray[6] = "Air Spirits"; * strLinkedSpiritDescriptionArray[7] = "Decomposers break down the old so that new life can grow."; * strLinkedSpiritDescriptionArray[8] = "Algae needs light and nutrients to grow."; * strLinkedSpiritDescriptionArray[9] = "Floating Plants that are a foodsource for Vertebrates"; * strLinkedSpiritDescriptionArray[10] = "Tiny Organisms that feed on Algae"; * strLinkedSpiritDescriptionArray[11] = "Animals that can feed on Plants, Zooplankton, or even other Vertebrates."; * */ public string GetSpeciesDescriptionString() { string str = ""; TrophicSlot slot = uiManager.worldSpiritHubUI.selectedWorldSpiritSlot; // * WPP: calculate values in simResourceManager, retrieve via function. Use switch statement. if (slot.kingdomID == KingdomId.Decomposers) { str = "Bacterial and Fungal organisms that recycle vital nutrients."; // \n\nUses: <b><color=#A97860FF>Waste</color></b>, <b><color=#8EDEEEFF>Oxygen</color></b>\n\nProduces: <b><color=#FBC653FF>Nutrients</color></b>"; str += "\n\n"; str += "<size=13><b>Total Biomass: " + simResourceManager.curGlobalDecomposers.ToString("F1") + "</b></size>\n\n"; str += "<color=#FBC653FF>Nutrient Production: <b>" + simResourceManager.nutrientsProducedByDecomposersLastFrame.ToString("F3") + "</b></color>\n"; str += "<color=#8EDEEEFF>Oxygen Usage: <b>" + simResourceManager.oxygenUsedByDecomposersLastFrame.ToString("F3") + "</b></color>\n"; str += "<color=#A97860FF>Waste Processed: <b>" + simResourceManager.detritusRemovedByDecomposersLastFrame.ToString("F3") + "</b></color>\n"; } else if (slot.id == KnowledgeMapId.Algae) { str = "Microscopic Plants that form the foundation of the ecosystem along with the Decomposers."; // \n\nUses: <b><color=#FBC653FF>Nutrients</color></b>\n\nProduces: <b><color=#8EDEEEFF>Oxygen</color></b>"; str += "\n\n"; str += "<size=13><b>Total Biomass: " + simResourceManager.curGlobalAlgaeReservoir.ToString("F1") + "</b></size>\n\n"; str += "<color=#8EDEEEFF>Oxygen Production: <b>" + simResourceManager.oxygenProducedByAlgaeReservoirLastFrame.ToString("F3") + "</b></color>\n"; str += "<color=#FBC653FF>Nutrient Usage: <b>" + simResourceManager.nutrientsUsedByAlgaeReservoirLastFrame.ToString("F3") + "</b></color>\n"; str += "<color=#A97860FF>Waste Generated: <b>" + simResourceManager.wasteProducedByAlgaeReservoirLastFrame.ToString("F3") + "</b></color>\n"; } else if (slot.id == KnowledgeMapId.Plants) { str = "Larger Plants."; // \n\nUses: <b><color=#FBC653FF>Nutrients</color></b>\n\nProduces: <b><color=#8EDEEEFF>Oxygen</color></b>"; str += "\n\nWelcome to the Big Leagues, chloroplasts"; str += "\n\n"; str += "<size=13><b>Total Biomass: " + simResourceManager.curGlobalPlantParticles.ToString("F1") + "</b></size>\n\n"; str += "<color=#8EDEEEFF>Oxygen Production: <b>" + simResourceManager.oxygenProducedByPlantParticlesLastFrame.ToString("F3") + "</b></color>\n"; str += "<color=#FBC653FF>Nutrient Usage: <b>" + simResourceManager.nutrientsUsedByPlantParticlesLastFrame.ToString("F3") + "</b></color>\n"; str += "<color=#A97860FF>Waste Generated: <b>" + simResourceManager.wasteProducedByPlantParticlesLastFrame.ToString("F3") + "</b></color>\n"; } else if (slot.id == KnowledgeMapId.Microbes) { str = "Tiny Animals that feed on Algae."; // \n\nUses: <b><color=#8EDEEEFF>Oxygen</color></b>\n\nProduces: <b><color=#A97860FF>Waste</color></b>"; str += "\n\n"; str += "<size=13><b>Total Biomass: " + simResourceManager.curGlobalAnimalParticles.ToString("F1") + "</b></size>\n\n"; str += "<color=#8EDEEEFF>Oxygen Usage: <b>" + simResourceManager.oxygenUsedByAnimalParticlesLastFrame.ToString("F3") + "</b></color>\n"; str += "<color=#A97860FF>Waste Generated: <b>" + simResourceManager.wasteProducedByAnimalParticlesLastFrame.ToString("F3") + "</b></color>\n"; } else if (slot.id == KnowledgeMapId.Animals) { str = "Simple Animal that feeds on Plants and Zooplankton."; // \n\nUses: <b><color=#8EDEEEFF>Oxygen</color></b>\n\nProduces: <b><color=#A97860FF>Waste</color></b>"; str += "\n\n"; /*float speciesMass = 0f; * if (slot.slotID == 0) { * speciesMass = simManager.simResourceManager.curGlobalAgentBiomass0; * } * else if(slot.slotID == 1) { * speciesMass = simManager.simResourceManager.curGlobalAgentBiomass1; * } * else if(slot.slotID == 2) { * speciesMass = simManager.simResourceManager.curGlobalAgentBiomass2; * } * else { * speciesMass = simManager.simResourceManager.curGlobalAgentBiomass3; * }*/ str += "<size=13><b>Total Biomass: " + simResourceManager.curGlobalAgentBiomass.ToString("F1") + "</b></size>\n\n";// simManager.simResourceManager.curGlobalAgentBiomass.ToString("F1") + "</b></size>\n\n"; SpeciesGenomePool GenomePool = simulationManager.masterGenomePool.completeSpeciesPoolsList[uiManagerRef.worldSpiritHubUI.selectedWorldSpiritSlot.linkedSpeciesID]; str += "<color=#8EDEEEFF>Oxygen Usage: <b>" + simResourceManager.oxygenUsedByAgentsLastFrame.ToString("F3") + "</b></color>\n"; str += "<color=#A97860FF>Waste Generated: <b>" + simResourceManager.wasteProducedByAgentsLastFrame.ToString("F3") + "</b></color>\n"; //str += "<color=#8BD06AFF>Avg Food Eaten: <b>" + (GenomePool.avgConsumptionPlant + GenomePool.avgConsumptionMeat).ToString("F3") + "</b></color>\n"; //str += "\n\n\nAvg Lifespan: <b>" + (GenomePool.avgLifespan / 1500f).ToString("F1") + " Years</b>\n\n"; /* * str += "Avg Body Size: <b>" + ((GenomePool.representativeCandidate.candidateGenome.bodyGenome.GetFullsizeBoundingBox().x + GenomePool.representativeCandidate.candidateGenome.bodyGenome.GetFullsizeBoundingBox().y) * 0.5f * GenomePool.representativeCandidate.candidateGenome.bodyGenome.GetFullsizeBoundingBox().z).ToString("F2") + "</b>\n"; * str += "Avg Brain Size: <b>" + ((GenomePool.avgNumNeurons + GenomePool.avgNumAxons) * 1f).ToString("F0") + "</b>\n"; * * str += "\nFOOD EATEN:\nPlants: <b>" + ((GenomePool.avgFoodEatenPlant) * 1f).ToString("F3") + "</b> [" + (GenomePool.avgFoodSpecPlant).ToString() + "]\n"; * str += "Meat: <b>" + ((GenomePool.avgFoodEatenZoop) * 1f).ToString("F3") + "</b> [" + (GenomePool.avgFoodSpecMeat).ToString() + "]\n"; * * str += "\nSPECIALIZATIONS:\nAttack: <b>" + ((GenomePool.avgSpecAttack) * 1f).ToString("F2") + "</b>\n"; * str += "Defend: <b>" + ((GenomePool.avgSpecDefend) * 1f).ToString("F2") + "</b>\n"; * str += "Speed: <b>" + ((GenomePool.avgSpecSpeed) * 1f).ToString("F2") + "</b>\n"; * str += "Utility: <b>" + ((GenomePool.avgSpecUtility) * 1f).ToString("F2") + "</b>\n";*/ } // * WPP: simplify, consider moving data to SO else if (slot.kingdomID == KingdomId.Terrain) { if (slot.layerIndex == 0) { str = "World"; str += "\n\nWorld Size: X square meters"; } else if (slot.layerIndex == 1) { str = "Stone"; str += "\n\nTotal Stone: Y lbs"; } else if (slot.layerIndex == 2) { str = "Pebbles"; } else { str = "Fine Sand"; } } else { if (slot.layerIndex == 0) { str = "Minerals"; } else if (slot.layerIndex == 1) { str = "Water"; } else if (slot.layerIndex == 2) { str = "Air"; } } return(str); }