Description:
Scale tree planting based on preserve.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -266,6 +266,14 | |||||
|
266 | this.PreserveCounts = new int[this.map.MapWidth, this.map.MapHeight]; |
|
266 | this.PreserveCounts = new int[this.map.MapWidth, this.map.MapHeight]; |
|
267 | } |
|
267 | } |
|
268 |
|
268 | ||
|
|
269 | private double interpolate(double percent, double start, double end) { | ||
|
|
270 | var low = Math.Min(start, end); | ||
|
|
271 | var high = Math.Max(start, end); | ||
|
|
272 | var range = high - low; | ||
|
|
273 | |||
|
|
274 | return range * percent + low; | ||
|
|
275 | } | ||
|
|
276 | |||
|
269 | private void advanceSimulation() |
|
277 | private void advanceSimulation() |
|
270 | { |
|
278 | { |
|
271 | var oldSeason = this.Season; |
|
279 | var oldSeason = this.Season; |
@@ -282,7 +290,8 | |||||
|
282 | for(int j = 0; j < this.map.MapHeight; j++) |
|
290 | for(int j = 0; j < this.map.MapHeight; j++) |
|
283 | { |
|
291 | { |
|
284 | var cell = this.map.cells[i][j]; |
|
292 | var cell = this.map.cells[i][j]; |
|
285 |
|
|
293 | var rate = interpolate((8 - (double)this.PreserveCounts[i, j] / 8.0d, PRESERVE_SPONTANEOUS_NEW_TREE_CHANCE, SPONTANEOUS_NEW_TREE_CHANCE); |
|
|
294 | if (random.NextDouble() > rate) | ||
|
286 | { |
|
295 | { |
|
287 | var random_type = random.Next(0, 4); |
|
296 | var random_type = random.Next(0, 4); |
|
288 | cell.AddTree(this.DateTime, (TreeType)random_type); |
|
297 | cell.AddTree(this.DateTime, (TreeType)random_type); |
You need to be logged in to leave comments.
Login now