diff --git a/isometric-park-fna/CellMap.cs b/isometric-park-fna/CellMap.cs --- a/isometric-park-fna/CellMap.cs +++ b/isometric-park-fna/CellMap.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; namespace isometricparkfna @@ -15,7 +15,15 @@ public int ZoneHeight = 10; - public int MapMultiplier; //Adjusts for larger maps. + //These coefficients modify values I set based on the original 50x50 maps. + //Eventually I'll probably allow for multiple map sizes, so instead of changing those constants, + //I'm adding a multiplier based on the size of the map. + // + //What's the difference between these two multipliers? + //If you double the sides of the map, the linear multiplier is 2, + //but the area multiplier is 4 (2 x 2). + public int LinearMultiplier; + public int AreaMultiplier; public int tree_count { @@ -58,7 +66,8 @@ this.cells = new List>(); - this.MapMultiplier = (int)(((this.MapWidth / 50) + (this.MapHeight / 50)) / 2); + this.LinearMultiplier = (int)(((this.MapWidth / 50) + (this.MapHeight / 50)) / 2); + this.AreaMultiplier = (int)((this.MapWidth * this.MapHeight) / (50 * 50)); for (int i = 0; i < height; i++) { @@ -117,7 +126,7 @@ return MathUtils.BetweenExclusive(x, 0, MapWidth - 1) && MathUtils.BetweenExclusive(y, 0, MapHeight - 1); } - public System.Collections.Generic.IEnumerable iterate_neighbors(int x, int y) + public System.Collections.Generic.IEnumerable iterate_neighbor_cells(int x, int y) { //iterates over neighbors (clockwise starting at noon/midnight) if (inBounds(x, y + 1)) @@ -154,10 +163,20 @@ } } + public System.Collections.Generic.IEnumerable iterate_neighbors(int x, int y) + { + foreach (Cell neighbor in this.iterate_neighbor_cells(x, y)) + { + if (neighbor.HasTree) { + yield return neighbor; + } + } + } + private int countNeighbors(int x, int y) { int count = 0; - foreach (Cell neighbor in this.iterate_neighbors(x, y)) + foreach (Cell neighbor in this.iterate_neighbor_cells(x, y)) { if (neighbor.HasTree) { count++; diff --git a/isometric-park-fna/Engines/Spawners/ContractSpawner.cs b/isometric-park-fna/Engines/Spawners/ContractSpawner.cs --- a/isometric-park-fna/Engines/Spawners/ContractSpawner.cs +++ b/isometric-park-fna/Engines/Spawners/ContractSpawner.cs @@ -31,8 +31,6 @@ private int MapWidth; private int MapHeight; - private int MapMultiplier; //Adjustment factor for larger maps - private Simulation simulation; private Grammar grammar; @@ -47,7 +45,6 @@ this.simulation = simulation; this.grammar = grammar; - this.MapMultiplier = this.simulation.map.MapMultiplier; } private Vector2 FindStart(HashSet occupied_squares) { @@ -72,7 +69,7 @@ var squares_to_add = new HashSet(); var attempts = 0; - var maxAttempts = max_size * this.MapMultiplier * 10; + var maxAttempts = max_size * this.simulation.map.LinearMultiplier * 10; while (squares.Count < max_size) { @@ -144,10 +141,10 @@ var image_index = random_generator.Next(1, 7); int max_squares = (organization_type, message.min_squares) switch { - (OrganizationType.Family, null) => random_generator.Next(50, 100 * this.MapMultiplier), - (OrganizationType.LargeCorporation, null) => random_generator.Next(90, 250 * this.MapMultiplier), - (OrganizationType.Cooperative, null) => random_generator.Next(50, 75 * this.MapMultiplier), - (_, null) => random_generator.Next(DEFAULT_MIN_SQUARES, DEFAULT_SQUARES * this.MapMultiplier), + (OrganizationType.Family, null) => random_generator.Next(50, 100 * this.simulation.map.LinearMultiplier), + (OrganizationType.LargeCorporation, null) => random_generator.Next(90, 250 * this.simulation.map.LinearMultiplier), + (OrganizationType.Cooperative, null) => random_generator.Next(50, 75 * this.simulation.map.LinearMultiplier), + (_, null) => random_generator.Next(DEFAULT_MIN_SQUARES, DEFAULT_SQUARES * this.simulation.map.LinearMultiplier), _ => (message.max_squares == 0) ? DEFAULT_SQUARES : message.max_squares }; diff --git a/isometric-park-fna/Simulation.cs b/isometric-park-fna/Simulation.cs --- a/isometric-park-fna/Simulation.cs +++ b/isometric-park-fna/Simulation.cs @@ -66,6 +66,8 @@ public const int MAX_TREES_TO_PLANT = 25; public const int MAX_TREES_TO_CLEAR = 25; + public const decimal STARTING_FUNDS = 100_000M; + public SimulationBridgeEngine BridgeEngine { get; private set; } public decimal Subsidy { @@ -244,7 +246,7 @@ this.DateTime = new DateTime(START_YEAR, START_MONTH, START_DAY); this.map = new CellMap(width, height); - this.money = 100000M; + this.money = STARTING_FUNDS; this.millisecondsPerAdvance = millisecondsPerAdvance; this.paused = true;