Description:
Clean up some constants and add comments.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r535:0d56136b7883 -

@@ -1,4 +1,4
1 using System;
1 using System;
2 using System.Collections.Generic;
2 using System.Collections.Generic;
3
3
4 namespace isometricparkfna
4 namespace isometricparkfna
@@ -15,7 +15,15
15 public int ZoneHeight = 10;
15 public int ZoneHeight = 10;
16
16
17
17
18 public int MapMultiplier; //Adjusts for larger maps.
18 //These coefficients modify values I set based on the original 50x50 maps.
19 //Eventually I'll probably allow for multiple map sizes, so instead of changing those constants,
20 //I'm adding a multiplier based on the size of the map.
21 //
22 //What's the difference between these two multipliers?
23 //If you double the sides of the map, the linear multiplier is 2,
24 //but the area multiplier is 4 (2 x 2).
25 public int LinearMultiplier;
26 public int AreaMultiplier;
19
27
20 public int tree_count
28 public int tree_count
21 {
29 {
@@ -58,7 +66,8
58
66
59 this.cells = new List<List<Cell>>();
67 this.cells = new List<List<Cell>>();
60
68
61 this.MapMultiplier = (int)(((this.MapWidth / 50) + (this.MapHeight / 50)) / 2);
69 this.LinearMultiplier = (int)(((this.MapWidth / 50) + (this.MapHeight / 50)) / 2);
70 this.AreaMultiplier = (int)((this.MapWidth * this.MapHeight) / (50 * 50));
62
71
63 for (int i = 0; i < height; i++)
72 for (int i = 0; i < height; i++)
64 {
73 {
@@ -117,7 +126,7
117 return MathUtils.BetweenExclusive(x, 0, MapWidth - 1) && MathUtils.BetweenExclusive(y, 0, MapHeight - 1);
126 return MathUtils.BetweenExclusive(x, 0, MapWidth - 1) && MathUtils.BetweenExclusive(y, 0, MapHeight - 1);
118 }
127 }
119
128
120 public System.Collections.Generic.IEnumerable<Cell> iterate_neighbors(int x, int y)
129 public System.Collections.Generic.IEnumerable<Cell> iterate_neighbor_cells(int x, int y)
121 {
130 {
122 //iterates over neighbors (clockwise starting at noon/midnight)
131 //iterates over neighbors (clockwise starting at noon/midnight)
123 if (inBounds(x, y + 1))
132 if (inBounds(x, y + 1))
@@ -154,10 +163,20
154 }
163 }
155 }
164 }
156
165
166 public System.Collections.Generic.IEnumerable<Cell> iterate_neighbors(int x, int y)
167 {
168 foreach (Cell neighbor in this.iterate_neighbor_cells(x, y))
169 {
170 if (neighbor.HasTree) {
171 yield return neighbor;
172 }
173 }
174 }
175
157 private int countNeighbors(int x, int y)
176 private int countNeighbors(int x, int y)
158 {
177 {
159 int count = 0;
178 int count = 0;
160 foreach (Cell neighbor in this.iterate_neighbors(x, y))
179 foreach (Cell neighbor in this.iterate_neighbor_cells(x, y))
161 {
180 {
162 if (neighbor.HasTree) {
181 if (neighbor.HasTree) {
163 count++;
182 count++;
@@ -31,8 +31,6
31 private int MapWidth;
31 private int MapWidth;
32 private int MapHeight;
32 private int MapHeight;
33
33
34 private int MapMultiplier; //Adjustment factor for larger maps
35
36 private Simulation simulation;
34 private Simulation simulation;
37 private Grammar grammar;
35 private Grammar grammar;
38
36
@@ -47,7 +45,6
47 this.simulation = simulation;
45 this.simulation = simulation;
48 this.grammar = grammar;
46 this.grammar = grammar;
49
47
50 this.MapMultiplier = this.simulation.map.MapMultiplier;
51 }
48 }
52 private Vector2 FindStart(HashSet<Vector2> occupied_squares)
49 private Vector2 FindStart(HashSet<Vector2> occupied_squares)
53 {
50 {
@@ -72,7 +69,7
72 var squares_to_add = new HashSet<Vector2>();
69 var squares_to_add = new HashSet<Vector2>();
73
70
74 var attempts = 0;
71 var attempts = 0;
75 var maxAttempts = max_size * this.MapMultiplier * 10;
72 var maxAttempts = max_size * this.simulation.map.LinearMultiplier * 10;
76
73
77 while (squares.Count < max_size)
74 while (squares.Count < max_size)
78 {
75 {
@@ -144,10 +141,10
144 var image_index = random_generator.Next(1, 7);
141 var image_index = random_generator.Next(1, 7);
145
142
146 int max_squares = (organization_type, message.min_squares) switch {
143 int max_squares = (organization_type, message.min_squares) switch {
147 (OrganizationType.Family, null) => random_generator.Next(50, 100 * this.MapMultiplier),
144 (OrganizationType.Family, null) => random_generator.Next(50, 100 * this.simulation.map.LinearMultiplier),
148 (OrganizationType.LargeCorporation, null) => random_generator.Next(90, 250 * this.MapMultiplier),
145 (OrganizationType.LargeCorporation, null) => random_generator.Next(90, 250 * this.simulation.map.LinearMultiplier),
149 (OrganizationType.Cooperative, null) => random_generator.Next(50, 75 * this.MapMultiplier),
146 (OrganizationType.Cooperative, null) => random_generator.Next(50, 75 * this.simulation.map.LinearMultiplier),
150 (_, null) => random_generator.Next(DEFAULT_MIN_SQUARES, DEFAULT_SQUARES * this.MapMultiplier),
147 (_, null) => random_generator.Next(DEFAULT_MIN_SQUARES, DEFAULT_SQUARES * this.simulation.map.LinearMultiplier),
151 _ => (message.max_squares == 0) ? DEFAULT_SQUARES : message.max_squares
148 _ => (message.max_squares == 0) ? DEFAULT_SQUARES : message.max_squares
152 };
149 };
153
150
@@ -66,6 +66,8
66 public const int MAX_TREES_TO_PLANT = 25;
66 public const int MAX_TREES_TO_PLANT = 25;
67 public const int MAX_TREES_TO_CLEAR = 25;
67 public const int MAX_TREES_TO_CLEAR = 25;
68
68
69 public const decimal STARTING_FUNDS = 100_000M;
70
69 public SimulationBridgeEngine BridgeEngine { get; private set; }
71 public SimulationBridgeEngine BridgeEngine { get; private set; }
70
72
71 public decimal Subsidy {
73 public decimal Subsidy {
@@ -244,7 +246,7
244 this.DateTime = new DateTime(START_YEAR, START_MONTH, START_DAY);
246 this.DateTime = new DateTime(START_YEAR, START_MONTH, START_DAY);
245
247
246 this.map = new CellMap(width, height);
248 this.map = new CellMap(width, height);
247 this.money = 100000M;
249 this.money = STARTING_FUNDS;
248 this.millisecondsPerAdvance = millisecondsPerAdvance;
250 this.millisecondsPerAdvance = millisecondsPerAdvance;
249
251
250 this.paused = true;
252 this.paused = true;
You need to be logged in to leave comments. Login now