# HG changeset patch # User alys # Date 2021-02-04 06:22:28 # Node ID b8267925cc8a249e1c5d451ef6946d9d6cbf2092 # Parent ee4f9a04be8fcfeb51fe6a06f7294537043c06b0 Add health measure. diff --git a/isometric-park-fna/Simulation.cs b/isometric-park-fna/Simulation.cs --- a/isometric-park-fna/Simulation.cs +++ b/isometric-park-fna/Simulation.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using static isometricparkfna.CellMap; +using System.Linq; namespace isometricparkfna { @@ -41,8 +42,8 @@ private const float NEIGHBOR_NEW_TREE_CHANCE = 0.995f; private const float NEIGHBOR_CROWDS_TREE_CHANCE = 0.995f; - public const int TREE_PLANT_COST = 100; - public const int TREE_CLEAR_COST = 50; + public const int TREE_PLANT_COST = 1000; + public const int TREE_CLEAR_COST = 750; public int Tick { @@ -130,8 +131,7 @@ private Random random; - //budget params - + //forest policy params public int _tree_planting; public int tree_planting { @@ -153,6 +153,13 @@ } } + public float healthy_percent + { + get { + return ((float)(this.map.tree_count - this.map.iterate_cells_with_neighbors(7).Count()) / this.map.tree_count) * 100; + } + } + public Simulation(int width, int height, float millisecondsPerAdvance) diff --git a/isometric-park-fna/UI/ForestWindow.cs b/isometric-park-fna/UI/ForestWindow.cs --- a/isometric-park-fna/UI/ForestWindow.cs +++ b/isometric-park-fna/UI/ForestWindow.cs @@ -43,6 +43,7 @@ sim.tree_clearing = new_tree_clearing; ImGui.Text(string.Format("Crowded Trees: {0}", sim.map.iterate_cells_with_neighbors(7).Count())); //via LINQ + ImGui.Text(string.Format("Percent Healthy Trees: {0:F2}", sim.healthy_percent)); if (ImGui.Button("Okay")) {