Update rewrite docs and cleanup

This commit is contained in:
2026-05-10 18:09:43 +02:00
parent 7ffaa140a8
commit d22c4a7528
51 changed files with 129 additions and 141 deletions

View File

@@ -46,6 +46,13 @@
- Added tests for network-band rules, reactor-ready rules, inventory rules, removal effects, electricity leak access, and invalid rule targets. - Added tests for network-band rules, reactor-ready rules, inventory rules, removal effects, electricity leak access, and invalid rule targets.
- Verified `dotnet test tests/ReactorMaintenance.Simulation.Tests/ReactorMaintenance.Simulation.Tests.csproj` passes after the rule slice: 21 passed. - Verified `dotnet test tests/ReactorMaintenance.Simulation.Tests/ReactorMaintenance.Simulation.Tests.csproj` passes after the rule slice: 21 passed.
- Ran `jb cleanupcode --build=False ...` and `python D:\Code\crlf.py ...` for touched C# files after the rule slice. - Ran `jb cleanupcode --build=False ...` and `python D:\Code\crlf.py ...` for touched C# files after the rule slice.
- Split serializable simulation records and enums from the monolithic `Models.cs` file into individual files under `Models`.
- Moved level creation, grid mutation helpers, surface clamping, grid geometry, and inventory operations out of serializable model records.
- Replaced separate T-junction and cross-junction props/tools with one topology-inferred `Junction` prop and one editor tool.
- Moved junction ratio presets into balancing data.
- Replaced hardcoded `EPairEffect` variants with parameterized surface interaction verbs and balance-owned magnitudes.
- Introduced a small public `SimulationEngine` facade over an internal simulation system implementation.
- Updated design documentation for generic junctions and parameterized surface interactions.
## Current Work ## Current Work
@@ -53,7 +60,7 @@
## Future Work ## Future Work
1. Expand simulation fidelity where the first slice is intentionally simplified: complete pair table coverage and stronger forecast proof cases. 1. Continue splitting the internal simulation system into smaller action, network, consumer, leak, surface interaction, robot safety, reactor, rule, and forecast systems.
2. Add advanced editor workflows for explicit reactor binding selection, explicit door edge selection, electricity wall leak face selection, and rule event authoring. 2. Add advanced editor workflows for explicit reactor binding selection, explicit door edge selection, electricity wall leak face selection, and rule event authoring.
3. Verify and polish the Win2D app on Windows where the XAML compiler can run. 3. Verify and polish the Win2D app on Windows where the XAML compiler can run.
4. Update README and any affected docs to reflect the new schema, .NET target, editor controls, and deterministic defaults. 4. Update README and any affected docs to reflect the new schema, .NET target, editor controls, and deterministic defaults.

View File

@@ -1,4 +1,4 @@
# Reactor Maintenance Design # Reactor Maintenance Design
## Concept ## Concept
@@ -114,8 +114,7 @@ Surface prop categories:
- flow prop - flow prop
- consumer prop - consumer prop
- T-junction prop - junction prop
- cross-junction prop
- door prop - door prop
- all-seeing-eye terminal prop - all-seeing-eye terminal prop
- remedy supply prop - remedy supply prop
@@ -155,24 +154,9 @@ The level is invalid if any binding is missing, out of bounds, or points to the
A junction prop must be on a floor cell whose coordinate has exactly one underground carrier. That carrier is the regulated network. A junction prop must be on a floor cell whose coordinate has exactly one underground carrier. That carrier is the regulated network.
T-junction modes: The engine infers incoming and outgoing branch directions from valid network topology and enabled source paths. A valid junction has one incoming branch and either two or three outgoing branches. Ambiguous junction flow is invalid. Ratio numbers are balance-defined weights that divide carrier amount and pressure or voltage. A zero-weight branch receives no intentional outflow.
- `0/4` The gameplay UI exposes a single junction tool and cycles through balance-defined ratio presets for the inferred outgoing branch count.
- `1/3`
- `2/2`
- `3/1`
- `4/0`
Cross-junction modes:
- `0/3/3`
- `3/0/3`
- `3/3/0`
- `2/2/2`
The engine infers incoming and outgoing branch directions from valid network topology and enabled source paths. Ambiguous junction flow is invalid. Ratio numbers are weights that divide carrier amount and pressure or voltage by balance-defined math. A zero-weight branch receives no intentional outflow.
The gameplay UI exposes ratio modes.
### Doors ### Doors
@@ -284,33 +268,28 @@ Balance thresholds project numeric values into safe, caution, and critical bands
The pair table maps projected bands to deterministic effects: The pair table maps projected bands to deterministic effects:
- `Hold`: no direct change. - `Hold`: no direct change.
- `FuelFlow`: equalize leaked fuel. The pair table maps projected bands to parameterized verbs:
- `CoolFlow`: equalize leaked coolant.
- `ChargeFlow`: equalize leaked electricity. - `Hold`: no direct change.
- `HeatFlow`: transfer heat. - `Flow(amount)`: equalize a surface quantity by a balance-defined transfer amount.
- `HeatFlow2`: stronger heat transfer. - `Warm(amount)`: increase heat by a balance-defined amount.
- `Warm1`: small heat increase from fuel exposure. - `Quench(amount)`: reduce heat by a balance-defined amount.
- `Warm2`: larger heat increase from fuel exposure. - `Short(heat, discharge)`: add heat and discharge electricity by balance-defined amounts.
- `Quench1`: small heat reduction from coolant exposure. - `Ignite(heat, fuel)`: add heat and consume fuel by balance-defined amounts.
- `Quench2`: larger heat reduction from coolant exposure.
- `Short1`: electricity and coolant interaction causing heat and discharge.
- `Short2`: stronger short.
- `Ignite1`: fuel interaction with electricity or high heat.
- `Ignite2`: stronger ignition.
| Row\Col | FuelSafe | FuelCaution | FuelCritical | CoolantSafe | CoolantCaution | CoolantCritical | ElectricitySafe | ElectricityCaution | ElectricityCritical | HeatSafe | HeatCaution | HeatCritical | | Row\Col | FuelSafe | FuelCaution | FuelCritical | CoolantSafe | CoolantCaution | CoolantCritical | ElectricitySafe | ElectricityCaution | ElectricityCritical | HeatSafe | HeatCaution | HeatCritical |
| ------- | -------- | ----------- | ------------ | ----------- | -------------- | --------------- | --------------- | ------------------ | ------------------- | -------- | ----------- | ------------ | | ------- | -------- | ----------- | ------------ | ----------- | -------------- | --------------- | --------------- | ------------------ | ------------------- | -------- | ----------- | ------------ |
| FuelSafe | Hold | FuelFlow | FuelFlow | Hold | Hold | Hold | Hold | Warm1 | Warm2 | Hold | Warm1 | Warm2 | | FuelSafe | Hold | Flow | Flow | Hold | Hold | Hold | Hold | Warm | Ignite | Hold | Warm | Ignite |
| FuelCaution | | Hold | FuelFlow | Hold | Hold | Hold | Warm1 | Ignite1 | Ignite2 | Warm1 | Ignite1 | Ignite2 | | FuelCaution | | Hold | Flow | Hold | Hold | Hold | Warm | Ignite | Ignite | Warm | Ignite | Ignite |
| FuelCritical | | | Hold | Hold | Hold | Hold | Warm2 | Ignite2 | Ignite2 | Warm2 | Ignite2 | Ignite2 | | FuelCritical | | | Hold | Hold | Hold | Hold | Ignite | Ignite | Ignite | Ignite | Ignite | Ignite |
| CoolantSafe | | | | Hold | CoolFlow | CoolFlow | Hold | Short1 | Short2 | Hold | Quench1 | Quench1 | | CoolantSafe | | | | Hold | Flow | Flow | Hold | Short | Short | Hold | Quench | Quench |
| CoolantCaution | | | | | Hold | CoolFlow | Short1 | Short1 | Short2 | Hold | Quench1 | Quench2 | | CoolantCaution | | | | | Hold | Flow | Short | Short | Short | Hold | Quench | Quench |
| CoolantCritical | | | | | | Hold | Short2 | Short2 | Short2 | Hold | Quench2 | Quench2 | | CoolantCritical | | | | | | Hold | Short | Short | Short | Hold | Quench | Quench |
| ElectricitySafe | | | | | | | Hold | ChargeFlow | ChargeFlow | Hold | Hold | Hold | | ElectricitySafe | | | | | | | Hold | Flow | Flow | Hold | Hold | Hold |
| ElectricityCaution | | | | | | | | Hold | ChargeFlow | Hold | Hold | Hold | | ElectricityCaution | | | | | | | | Hold | Flow | Hold | Hold | Hold |
| ElectricityCritical | | | | | | | | | Hold | Hold | Hold | Hold | | ElectricityCritical | | | | | | | | | Hold | Hold | Hold | Hold |
| HeatSafe | | | | | | | | | | Hold | HeatFlow | HeatFlow2 | | HeatSafe | | | | | | | | | | Hold | Flow | Flow |
| HeatCaution | | | | | | | | | | | Hold | HeatFlow | | HeatCaution | | | | | | | | | | | Hold | Flow |
| HeatCritical | | | | | | | | | | | | Hold | | HeatCritical | | | | | | | | | | | | Hold |
Design rules: Design rules:
@@ -422,7 +401,7 @@ The editor authors:
- underground fuel, coolant, and electricity cells - underground fuel, coolant, and electricity cells
- flow props and consumer props - flow props and consumer props
- reactor controls and reactor consumer bindings - reactor controls and reactor consumer bindings
- junction props and ratio modes - junction props and balance-defined ratio mode index
- door props and door edges - door props and door edges
- all-seeing-eye terminals - all-seeing-eye terminals
- remedy supplies - remedy supplies

View File

@@ -1,4 +1,4 @@
using ReactorMaintenance.Simulation.Difficulties; using ReactorMaintenance.Simulation.Difficulties;
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation.Difficulties; namespace ReactorMaintenance.Simulation.Difficulties;
public class NormalBalancing : Balancing public class NormalBalancing : Balancing
{ {
@@ -30,6 +30,7 @@ public class NormalBalancing : Balancing
public override float SourceIntensity => 8; public override float SourceIntensity => 8;
public override float DistanceAmountFalloff => 0.5f; public override float DistanceAmountFalloff => 0.5f;
public override float DistanceIntensityFalloff => 0.4f; public override float DistanceIntensityFalloff => 0.4f;
public override IReadOnlyList<JunctionRatioPreset> TwoOutflowJunctionRatios { get; } = [ public override IReadOnlyList<JunctionRatioPreset> TwoOutflowJunctionRatios { get; } = [
new("0/4", [0, 1]), new("0/4", [0, 1]),
new("1/3", [0.25f, 0.75f]), new("1/3", [0.25f, 0.75f]),
@@ -37,12 +38,14 @@ public class NormalBalancing : Balancing
new("3/1", [0.75f, 0.25f]), new("3/1", [0.75f, 0.25f]),
new("4/0", [1, 0]) new("4/0", [1, 0])
]; ];
public override IReadOnlyList<JunctionRatioPreset> ThreeOutflowJunctionRatios { get; } = [ public override IReadOnlyList<JunctionRatioPreset> ThreeOutflowJunctionRatios { get; } = [
new("0/3/3", [0, 0.5f, 0.5f]), new("0/3/3", [0, 0.5f, 0.5f]),
new("3/0/3", [0.5f, 0, 0.5f]), new("3/0/3", [0.5f, 0, 0.5f]),
new("3/3/0", [0.5f, 0.5f, 0]), new("3/3/0", [0.5f, 0.5f, 0]),
new("2/2/2", [1f / 3f, 1f / 3f, 1f / 3f]) new("2/2/2", [1f / 3f, 1f / 3f, 1f / 3f])
]; ];
public override float ConsumerRequiredAmount => 2.5f; public override float ConsumerRequiredAmount => 2.5f;
public override float ConsumerRequiredIntensity => 2.5f; public override float ConsumerRequiredIntensity => 2.5f;
public override float LeakBaseAmount => 0.5f; public override float LeakBaseAmount => 0.5f;

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public static class GridPositionExtensions public static class GridPositionExtensions
{ {

View File

@@ -1,3 +1,3 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record JunctionRatioPreset(string Label, float[] Weights); public sealed record JunctionRatioPreset(string Label, float[] Weights);

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum EEditorTool public enum EEditorTool
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public static class LevelStateExtensions public static class LevelStateExtensions
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public static class LevelStateFactory public static class LevelStateFactory
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record DoorState public sealed record DoorState
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum EBand public enum EBand
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum ECarrierType public enum ECarrierType
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum ECellTerrain public enum ECellTerrain
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum EConsumerServiceState public enum EConsumerServiceState
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum EDoorState public enum EDoorState
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum EForecastKind public enum EForecastKind
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum ELevelState public enum ELevelState
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum ENetworkValueKind public enum ENetworkValueKind
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum EPropSwitchState public enum EPropSwitchState
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum EPropType public enum EPropType
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum ERemedyType public enum ERemedyType
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum ERuleEffectKind public enum ERuleEffectKind
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum ERuleEventPhase public enum ERuleEventPhase
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum ERulePredicateKind public enum ERulePredicateKind
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum ESurfaceInteractionVerb public enum ESurfaceInteractionVerb
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum ESurfaceQuantity public enum ESurfaceQuantity
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public enum EUndergroundState public enum EUndergroundState
{ {

View File

@@ -1,3 +1,3 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record Forecast(EForecastKind Kind, GridPosition? Position, int Turns, string Message); public sealed record Forecast(EForecastKind Kind, GridPosition? Position, int Turns, string Message);

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record GlobalState public sealed record GlobalState
{ {

View File

@@ -1,3 +1,3 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record GridPosition(int X, int Y); public sealed record GridPosition(int X, int Y);

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record LeakState public sealed record LeakState
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record LevelState public sealed record LevelState
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record PropState public sealed record PropState
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record ReactorBinding public sealed record ReactorBinding
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record RobotState public sealed record RobotState
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record RuleEffect public sealed record RuleEffect
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record RuleEventState public sealed record RuleEventState
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record RulePredicate public sealed record RulePredicate
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record SurfaceState public sealed record SurfaceState
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record UndergroundCell public sealed record UndergroundCell
{ {

View File

@@ -1,3 +1,3 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record ValidationIssue(string Message, GridPosition? Position = null); public sealed record ValidationIssue(string Message, GridPosition? Position = null);

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record ValidationReport public sealed record ValidationReport
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public static class RobotStateExtensions public static class RobotStateExtensions
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed class SimulationEngine public sealed class SimulationEngine
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public sealed record SurfaceInteractionEffect public sealed record SurfaceInteractionEffect
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
public static class SurfaceStateExtensions public static class SurfaceStateExtensions
{ {

View File

@@ -1,4 +1,4 @@
namespace ReactorMaintenance.Simulation; namespace ReactorMaintenance.Simulation;
internal sealed class SimulationCoreSystem internal sealed class SimulationCoreSystem
{ {
@@ -704,4 +704,3 @@ internal sealed class SimulationCoreSystem
private readonly LevelValidator m_Validator = new(); private readonly LevelValidator m_Validator = new();
} }

View File

@@ -1,4 +1,4 @@
using Microsoft.Graphics.Canvas; using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Text; using Microsoft.Graphics.Canvas.Text;
using Microsoft.Graphics.Canvas.UI.Xaml; using Microsoft.Graphics.Canvas.UI.Xaml;
using Microsoft.UI; using Microsoft.UI;