Description:
Spawn trees of similar type to neighbors.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r532:6b7b45b604e5 -

@@ -113,7 +113,7
113 113 return MathUtils.BetweenExclusive(x, 0, MapWidth - 1) && MathUtils.BetweenExclusive(y, 0, MapHeight - 1);
114 114 }
115 115
116 private System.Collections.Generic.IEnumerable<Cell> iterate_neighbors(int x, int y)
116 public System.Collections.Generic.IEnumerable<Cell> iterate_neighbors(int x, int y)
117 117 {
118 118 //iterates over neighbors (clockwise starting at noon/midnight)
119 119 if (inBounds(x, y + 1))
@@ -176,8 +176,21
176 176 }
177 177 }
178 178 }
179 }
179 180
180
181 public System.Collections.Generic.IEnumerable<(int, int)> iterate_cell_locations_with_neighbors(int neighbors)
182 {
183 for (int i = 0; i < MapHeight; i++)
184 {
185 List<Cell> newRow = new List<Cell>();
186 for (int j = 0; j < MapWidth; j++)
187 {
188 if (this.countNeighbors(i, j) >= neighbors)
189 {
190 yield return (i, j);
191 }
192 }
193 }
181 194 }
182 195
183 196 public enum CellStatus {
@@ -125,14 +125,14
125 125 #endregion
126 126 this.simulation.Subsidy = message.Difficulty switch {
127 127 DifficultyLevel.Hard => 0M,
128 DifficultyLevel.Medium => 760M,
129 DifficultyLevel.Easy => 1000M,
128 DifficultyLevel.Medium => 12_550M,
129 DifficultyLevel.Easy => 15_000M,
130 130 _ => 1000M
131 131 };
132 132
133 133 this.simulation.SubsidyDelta = message.Difficulty switch {
134 134 DifficultyLevel.Hard => 0M,
135 DifficultyLevel.Medium => -10M,
135 DifficultyLevel.Medium => -50M,
136 136 DifficultyLevel.Easy => 0M,
137 137 _ => 1000M
138 138 };
@@ -276,12 +276,15
276 276 }
277 277
278 278 int new_planted = 0;
279 foreach (Cell cell in this.map.iterate_cells_with_neighbors(4))
279 foreach (var (x, y) in this.map.iterate_cell_locations_with_neighbors(4))
280 280 {
281 var neighbor = this.map.iterate_neighbors(x, y).First();
282 var cell = this.map.cells[x][y];
283
281 284 if (random.NextDouble() > NEIGHBOR_NEW_TREE_CHANCE)
282 285 {
283 286 var random_type = random.Next(0, 4);
284 cell.AddTree(this.DateTime, (TreeType)random_type);
287 cell.AddTree(this.DateTime, neighbor.Type);
285 288 new_planted += 1;
286 289 }
287 290 }
You need to be logged in to leave comments. Login now