Description:
Adjust generation for map sizes.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -13,6 +13,9 | |||||
|
13 |
|
13 | ||
|
14 | public int ZoneWidth = 10; |
|
14 | public int ZoneWidth = 10; |
|
15 | public int ZoneHeight = 10; |
|
15 | public int ZoneHeight = 10; |
|
|
16 | |||
|
|
17 | |||
|
|
18 | public int MapMultiplier; //Adjusts for larger maps. | ||
|
16 |
|
19 | ||
|
17 | public int tree_count |
|
20 | public int tree_count |
|
18 | { |
|
21 | { |
@@ -56,6 +59,9 | |||||
|
56 |
|
59 | ||
|
57 | this.cells = new List<List<Cell>>(); |
|
60 | this.cells = new List<List<Cell>>(); |
|
58 |
|
61 | ||
|
|
62 | this.MapMultiplier = (int)(((this.MapWidth / 50) + (this.MapHeight / 50)) / 2); | ||
|
|
63 | |||
|
|
64 | |||
|
59 | for (int i = 0; i < height; i++) |
|
65 | for (int i = 0; i < height; i++) |
|
60 | { |
|
66 | { |
|
61 | List<Cell> newRow = new List<Cell>(); |
|
67 | List<Cell> newRow = new List<Cell>(); |
@@ -32,6 +32,8 | |||||
|
32 | private int MapWidth; |
|
32 | private int MapWidth; |
|
33 | private int MapHeight; |
|
33 | private int MapHeight; |
|
34 |
|
34 | ||
|
|
35 | private int MapMultiplier; //Adjustment factor for larger maps | ||
|
|
36 | |||
|
35 | private Simulation simulation; |
|
37 | private Simulation simulation; |
|
36 | private Grammar grammar; |
|
38 | private Grammar grammar; |
|
37 |
|
39 | ||
@@ -45,7 +47,8 | |||||
|
45 |
|
47 | ||
|
46 | this.simulation = simulation; |
|
48 | this.simulation = simulation; |
|
47 | this.grammar = grammar; |
|
49 | this.grammar = grammar; |
|
48 | } |
|
50 | |
|
|
51 | this.MapMultiplier = this.simulation.map.MapMultiplier; } | ||
|
49 | private Vector2 FindStart(HashSet<Vector2> occupied_squares) |
|
52 | private Vector2 FindStart(HashSet<Vector2> occupied_squares) |
|
50 | { |
|
53 | { |
|
51 |
|
54 | ||
@@ -53,7 +56,7 | |||||
|
53 |
|
56 | ||
|
54 | for (int i = 0; i < 5; i++) |
|
57 | for (int i = 0; i < 5; i++) |
|
55 | { |
|
58 | { |
|
56 |
new_square = new Vector2(random_generator.Next(0, |
|
59 | new_square = new Vector2(random_generator.Next(0, this.MapHeight), random_generator.Next(0, this.MapWidth)); |
|
57 |
|
60 | ||
|
58 | if (!occupied_squares.Contains(new_square)) |
|
61 | if (!occupied_squares.Contains(new_square)) |
|
59 | { |
|
62 | { |
@@ -70,7 +73,7 | |||||
|
70 | var squares_to_add = new HashSet<Vector2>(); |
|
73 | var squares_to_add = new HashSet<Vector2>(); |
|
71 |
|
74 | ||
|
72 | var attempts = 0; |
|
75 | var attempts = 0; |
|
73 | var maxAttempts = max_size * 10; |
|
76 | var maxAttempts = max_size * this.MapMultiplier * 10; |
|
74 |
|
77 | ||
|
75 | while (squares.Count < max_size) |
|
78 | while (squares.Count < max_size) |
|
76 | { |
|
79 | { |
@@ -148,10 +151,10 | |||||
|
148 |
|
151 | ||
|
149 |
|
152 | ||
|
150 | int max_squares = (organization_type, message.min_squares) switch { |
|
153 | int max_squares = (organization_type, message.min_squares) switch { |
|
151 | (OrganizationType.Family, null) => random_generator.Next(50, 100), |
|
154 | (OrganizationType.Family, null) => random_generator.Next(50, 100 * this.MapMultiplier), |
|
152 | (OrganizationType.LargeCorporation, null) => random_generator.Next(90, 250), |
|
155 | (OrganizationType.LargeCorporation, null) => random_generator.Next(90, 250 * this.MapMultiplier), |
|
153 | (OrganizationType.Cooperative, null) => random_generator.Next(50, 75), |
|
156 | (OrganizationType.Cooperative, null) => random_generator.Next(50, 75 * this.MapMultiplier), |
|
154 | (_, null) => random_generator.Next(DEFAULT_MIN_SQUARES, DEFAULT_SQUARES), |
|
157 | (_, null) => random_generator.Next(DEFAULT_MIN_SQUARES, DEFAULT_SQUARES * this.MapMultiplier), |
|
155 | _ => (message.max_squares == 0) ? DEFAULT_SQUARES : message.max_squares |
|
158 | _ => (message.max_squares == 0) ? DEFAULT_SQUARES : message.max_squares |
|
156 | }; |
|
159 | }; |
|
157 |
|
160 |
@@ -39,6 +39,7 | |||||
|
39 | public int trees; |
|
39 | public int trees; |
|
40 | public int dead_trees; |
|
40 | public int dead_trees; |
|
41 | public int crowded_trees; |
|
41 | public int crowded_trees; |
|
|
42 | //Kind of a hack but allos for tracking figures over time without creating a whole new infrastructure | ||
|
42 |
|
43 | ||
|
43 | } |
|
44 | } |
|
44 |
|
45 | ||
@@ -236,9 +237,6 | |||||
|
236 | } |
|
237 | } |
|
237 | } |
|
238 | } |
|
238 |
|
239 | ||
|
239 | //Historical counts |
|
||
|
240 | // public List<int> tree_count |
|
||
|
241 |
|
|||
|
242 | public Simulation(int width, int height, float[] millisecondsPerAdvance) |
|
240 | public Simulation(int width, int height, float[] millisecondsPerAdvance) |
|
243 | { |
|
241 | { |
|
244 | this.random = new Random(); |
|
242 | this.random = new Random(); |
You need to be logged in to leave comments.
Login now