Centralize simulation balancing values
This commit is contained in:
@@ -34,10 +34,10 @@ public sealed record GridPosition(int X, int Y)
|
||||
{
|
||||
public IEnumerable<GridPosition> Neighbors()
|
||||
{
|
||||
yield return new(X - 1, Y);
|
||||
yield return new(X + 1, Y);
|
||||
yield return new(X, Y - 1);
|
||||
yield return new(X, Y + 1);
|
||||
yield return new(X - Balancing.NeighborDistance, Y);
|
||||
yield return new(X + Balancing.NeighborDistance, Y);
|
||||
yield return new(X, Y - Balancing.NeighborDistance);
|
||||
yield return new(X, Y + Balancing.NeighborDistance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public sealed record HazardState
|
||||
public int LiquidFuel { get; init; }
|
||||
public int CoolantPooling { get; init; }
|
||||
public int ElectricalCharge { get; init; }
|
||||
public int Stability { get; init; } = 10;
|
||||
public int Stability { get; init; } = Balancing.DefaultHazardStability;
|
||||
public bool Fire { get; init; }
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public sealed record CellState
|
||||
public EPipeMedium Pipe { get; init; }
|
||||
public int Flow { get; init; }
|
||||
public int Pressure { get; init; }
|
||||
public int Integrity { get; init; } = 10;
|
||||
public int Integrity { get; init; } = Balancing.DefaultCellIntegrity;
|
||||
public int LeakRate { get; init; }
|
||||
public bool PipeOpen { get; init; } = true;
|
||||
public bool Powered { get; init; }
|
||||
@@ -85,11 +85,11 @@ public sealed record CellState
|
||||
public sealed record GlobalState
|
||||
{
|
||||
public int Turn { get; init; }
|
||||
public int ActionsPerTurn { get; init; } = 3;
|
||||
public int CoreHeat { get; init; } = 5;
|
||||
public int FacilityStability { get; init; } = 10;
|
||||
public int Power { get; init; } = 5;
|
||||
public int Cooling { get; init; } = 0;
|
||||
public int ActionsPerTurn { get; init; } = Balancing.DefaultActionsPerTurn;
|
||||
public int CoreHeat { get; init; } = Balancing.DefaultCoreHeat;
|
||||
public int FacilityStability { get; init; } = Balancing.DefaultFacilityStability;
|
||||
public int Power { get; init; } = Balancing.DefaultPower;
|
||||
public int Cooling { get; init; } = Balancing.DefaultCooling;
|
||||
public bool ReactorActivated { get; init; }
|
||||
public bool Lost { get; init; }
|
||||
public string Status { get; init; } = "STABILIZE SYSTEMS";
|
||||
@@ -101,15 +101,15 @@ public sealed record LevelState
|
||||
{
|
||||
public static LevelState Create(string name, int width, int height)
|
||||
{
|
||||
if (width < 4 || height < 4)
|
||||
throw new ArgumentOutOfRangeException(nameof(width), "Levels must be at least 4x4.");
|
||||
if (width < Balancing.MinimumLevelSize || height < Balancing.MinimumLevelSize)
|
||||
throw new ArgumentOutOfRangeException(nameof(width), $"Levels must be at least {Balancing.MinimumLevelSize}x{Balancing.MinimumLevelSize}.");
|
||||
|
||||
var cells = CreateCells(width, height);
|
||||
for (var y = 0; y < height; y++)
|
||||
for (var y = Balancing.FirstGridCoordinate; y < height; y++)
|
||||
{
|
||||
for (var x = 0; x < width; x++)
|
||||
for (var x = Balancing.FirstGridCoordinate; x < width; x++)
|
||||
{
|
||||
if (x == 0 || y == 0 || x == width - 1 || y == height - 1)
|
||||
if (x == Balancing.FirstGridCoordinate || y == Balancing.FirstGridCoordinate || x == width - Balancing.NeighborDistance || y == height - Balancing.NeighborDistance)
|
||||
cells[y * width + x] = cells[y * width + x] with { Kind = ECellKind.Wall };
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public sealed record LevelState
|
||||
Width = width,
|
||||
Height = height,
|
||||
Cells = cells,
|
||||
Robot = new(1, 1)
|
||||
Robot = new(Balancing.DefaultRobotCoordinate, Balancing.DefaultRobotCoordinate)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public sealed record LevelState
|
||||
|
||||
public bool InBounds(GridPosition position)
|
||||
{
|
||||
return position.X >= 0 && position.Y >= 0 && position.X < Width && position.Y < Height;
|
||||
return position.X >= Balancing.FirstGridCoordinate && position.Y >= Balancing.FirstGridCoordinate && position.X < Width && position.Y < Height;
|
||||
}
|
||||
|
||||
public int Index(GridPosition position)
|
||||
@@ -155,14 +155,14 @@ public sealed record LevelState
|
||||
|
||||
private static CellState[] CreateCells(int width, int height)
|
||||
{
|
||||
return Enumerable.Range(0, width * height).Select(_ => new CellState()).ToArray();
|
||||
return Enumerable.Range(Balancing.FirstGridCoordinate, width * height).Select(_ => new CellState()).ToArray();
|
||||
}
|
||||
|
||||
public string Name { get; init; } = "New Reactor";
|
||||
public int Width { get; init; } = 16;
|
||||
public int Height { get; init; } = 12;
|
||||
public CellState[] Cells { get; init; } = CreateCells(16, 12);
|
||||
public GridPosition Robot { get; init; } = new(1, 1);
|
||||
public int Width { get; init; } = Balancing.DefaultLevelWidth;
|
||||
public int Height { get; init; } = Balancing.DefaultLevelHeight;
|
||||
public CellState[] Cells { get; init; } = CreateCells(Balancing.DefaultLevelWidth, Balancing.DefaultLevelHeight);
|
||||
public GridPosition Robot { get; init; } = new(Balancing.DefaultRobotCoordinate, Balancing.DefaultRobotCoordinate);
|
||||
public GlobalState Global { get; init; } = new();
|
||||
public IReadOnlyList<Forecast> Forecasts { get; init; } = Array.Empty<Forecast>();
|
||||
}
|
||||
@@ -171,6 +171,6 @@ internal static class Rules
|
||||
{
|
||||
public static int Clamp(int value)
|
||||
{
|
||||
return Math.Clamp(value, 0, 10);
|
||||
return Math.Clamp(value, Balancing.MinHazardValue, Balancing.MaxHazardValue);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user