Description:
Clean up some constants and add comments.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -1,4 +1,4 | |||
|
1 | using System; | |
|
1 | using System; | |
|
2 | 2 | using System.Collections.Generic; |
|
3 | 3 | |
|
4 | 4 | namespace isometricparkfna |
@@ -15,7 +15,15 | |||
|
15 | 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 | 28 | public int tree_count |
|
21 | 29 | { |
@@ -58,7 +66,8 | |||
|
58 | 66 | |
|
59 | 67 | this.cells = new List<List<Cell>>(); |
|
60 | 68 | |
|
61 |
this. |
|
|
69 | this.LinearMultiplier = (int)(((this.MapWidth / 50) + (this.MapHeight / 50)) / 2); | |
|
70 | this.AreaMultiplier = (int)((this.MapWidth * this.MapHeight) / (50 * 50)); | |
|
62 | 71 | |
|
63 | 72 | for (int i = 0; i < height; i++) |
|
64 | 73 | { |
@@ -117,7 +126,7 | |||
|
117 | 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 | 131 | //iterates over neighbors (clockwise starting at noon/midnight) |
|
123 | 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 | 176 | private int countNeighbors(int x, int y) |
|
158 | 177 | { |
|
159 | 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 | 181 | if (neighbor.HasTree) { |
|
163 | 182 | count++; |
@@ -31,8 +31,6 | |||
|
31 | 31 | private int MapWidth; |
|
32 | 32 | private int MapHeight; |
|
33 | 33 | |
|
34 | private int MapMultiplier; //Adjustment factor for larger maps | |
|
35 | ||
|
36 | 34 | private Simulation simulation; |
|
37 | 35 | private Grammar grammar; |
|
38 | 36 | |
@@ -47,7 +45,6 | |||
|
47 | 45 | this.simulation = simulation; |
|
48 | 46 | this.grammar = grammar; |
|
49 | 47 | |
|
50 | this.MapMultiplier = this.simulation.map.MapMultiplier; | |
|
51 | 48 | } |
|
52 | 49 | private Vector2 FindStart(HashSet<Vector2> occupied_squares) |
|
53 | 50 | { |
@@ -72,7 +69,7 | |||
|
72 | 69 | var squares_to_add = new HashSet<Vector2>(); |
|
73 | 70 | |
|
74 | 71 | var attempts = 0; |
|
75 |
var maxAttempts = max_size * this. |
|
|
72 | var maxAttempts = max_size * this.simulation.map.LinearMultiplier * 10; | |
|
76 | 73 | |
|
77 | 74 | while (squares.Count < max_size) |
|
78 | 75 | { |
@@ -144,10 +141,10 | |||
|
144 | 141 | var image_index = random_generator.Next(1, 7); |
|
145 | 142 | |
|
146 | 143 | int max_squares = (organization_type, message.min_squares) switch { |
|
147 |
(OrganizationType.Family, null) => random_generator.Next(50, 100 * this. |
|
|
148 |
(OrganizationType.LargeCorporation, null) => random_generator.Next(90, 250 * this. |
|
|
149 |
(OrganizationType.Cooperative, null) => random_generator.Next(50, 75 * this. |
|
|
150 |
(_, null) => random_generator.Next(DEFAULT_MIN_SQUARES, DEFAULT_SQUARES * this. |
|
|
144 | (OrganizationType.Family, null) => random_generator.Next(50, 100 * this.simulation.map.LinearMultiplier), | |
|
145 | (OrganizationType.LargeCorporation, null) => random_generator.Next(90, 250 * this.simulation.map.LinearMultiplier), | |
|
146 | (OrganizationType.Cooperative, null) => random_generator.Next(50, 75 * this.simulation.map.LinearMultiplier), | |
|
147 | (_, null) => random_generator.Next(DEFAULT_MIN_SQUARES, DEFAULT_SQUARES * this.simulation.map.LinearMultiplier), | |
|
151 | 148 | _ => (message.max_squares == 0) ? DEFAULT_SQUARES : message.max_squares |
|
152 | 149 | }; |
|
153 | 150 |
@@ -66,6 +66,8 | |||
|
66 | 66 | public const int MAX_TREES_TO_PLANT = 25; |
|
67 | 67 | public const int MAX_TREES_TO_CLEAR = 25; |
|
68 | 68 | |
|
69 | public const decimal STARTING_FUNDS = 100_000M; | |
|
70 | ||
|
69 | 71 | public SimulationBridgeEngine BridgeEngine { get; private set; } |
|
70 | 72 | |
|
71 | 73 | public decimal Subsidy { |
@@ -244,7 +246,7 | |||
|
244 | 246 | this.DateTime = new DateTime(START_YEAR, START_MONTH, START_DAY); |
|
245 | 247 | |
|
246 | 248 | this.map = new CellMap(width, height); |
|
247 |
this.money = |
|
|
249 | this.money = STARTING_FUNDS; | |
|
248 | 250 | this.millisecondsPerAdvance = millisecondsPerAdvance; |
|
249 | 251 | |
|
250 | 252 | this.paused = true; |
You need to be logged in to leave comments.
Login now