Files
zfxaction26_2/docs/design.md

15 KiB

Reactor Maintenance Design

Concept

The player controls a maintenance robot inside a failing reactor facility. The game is a deterministic, turn-based systems puzzle about reading a visible machine, forecasting failure, and choosing between local stabilization and longer-term network control.

The simulation core is built from:

  • static floor and wall terrain,
  • underground fuel, coolant, and electricity networks,
  • surface props for controls, terminals, supplies, doors, and reactor activation,
  • consumers that consume whichever underground services exist under their cell,
  • reachable leaks that project hazards onto floor cells,
  • transport network structural integrity,
  • deterministic fixed simulation rules and forecasts.

The game should feel logical, tactical, readable, and systemic. It should avoid randomness, action pressure, and hidden information once the player reaches an all-seeing-eye terminal.

Action Economy

There is no per-turn action budget. Player choices are either quick or lengthy.

Quick actions do not mutate the level state and do not advance the simulation:

  • robot movement,
  • selection and inspection,
  • all-seeing-eye viewing.

Lengthy actions mutate level state and immediately advance one simulation step:

  • enabling or disabling a prop,
  • opening or closing a door,
  • repairing a leak,
  • applying a remedy,
  • using a heat shield,
  • waiting or ending the current interaction beat.

Invalid actions report refusal and do not mutate gameplay state.

Goal And Failure

Each reactor starts offline. A reactor becomes ready when:

  • every underground network present beneath the reactor control cell has positive amount and intensity,
  • the level has the required number of enabled, fed, producing fuel consumers,
  • the level has the required number of enabled, fed, producing coolant consumers,
  • the level has the required number of enabled, fed, producing electricity consumers,
  • reactor heat is below the terminal condition.

The required consumer counts are level properties. The reactor is not explicitly bound to any consumer positions.

When a reactor is ready, the level shows REACTOR READY. The player wins by activating the ready reactor at the reactor control site.

The level is lost when:

  • reactor heat reaches the terminal threshold,
  • the robot occupies an unsafe final hazard state without applicable protection,
  • fixed simulation rules mark terminal failure.

Consumer starvation blocks readiness but does not directly cause loss.

Information

The player can always inspect:

  • surface terrain,
  • surface props and visible prop state,
  • visible leaks and repair faces,
  • visible surface hazards,
  • door state,
  • remedy inventory and supply props,
  • consumer state: disabled, starved, supplied, producing, or unknown,
  • level state,
  • forecasted warnings the simulation can prove.

Underground topology and numeric network values are available through all-seeing-eye viewing after the robot visits an all-seeing-eye terminal. There is no persistent lock or unlock state in the level data.

The editor always sees and authors every layer.

Safe, caution, and critical labels are display and forecast bands derived from balance thresholds. Numeric simulation values remain authoritative.

Grid And State

Each map coordinate contains:

  • one static surface terrain cell: Floor or Wall,
  • zero or one underground fuel cell,
  • zero or one underground coolant cell,
  • zero or one underground electricity cell,
  • zero or one surface prop,
  • visible hazard amounts on floor cells,
  • optionally the robot, only on a floor cell.

Terrain is authored and does not change during play. Wall cells are not walkable and do not store surface hazards.

Underground cells use one structural state:

  • Absent,
  • Intact,
  • Leaking.

Underground cells store carrier amount, pressure or voltage intensity, and structural integrity on a 0-10 scale. Max structural integrity supports the highest pressure. Non-max integrity under high pressure worsens proportionally to excess pressure. Low integrity with positive pressure creates a leak. Repairing a leak restores integrity to max.

Same-carrier underground cells connect by inferred cardinal adjacency.

Surface floor cells store:

  • leaked fuel,
  • leaked coolant,
  • leaked electricity,
  • heat,
  • active elemental remedy blocks.

Simulation values use C# float. Runtime values are clamped and retain full float precision. UI shows visible values rounded to one decimal plus the safe/caution/critical band.

Level State

The derived level states are:

  • Stable: no terminal path is near and required systems are not deteriorating.
  • Caution: required service is missing, a consumer is starved or disabled, a hazard is growing, or reactor heat is concerning.
  • Critical: forecast predicts loss without near-term intervention, or reactor heat is close to terminal.
  • Ready: a reactor can be activated.
  • Lost: terminal failure has occurred.
  • Won: a reactor has been activated successfully.

Props

Surface prop categories:

  • flow prop,
  • consumer prop,
  • junction prop,
  • door prop,
  • all-seeing-eye terminal prop,
  • remedy supply prop,
  • reactor control prop.

Props exist on floor cells. Props do not directly participate in the surface hazard pair table.

Flow Props

A flow prop is bound to fuel, coolant, or electricity. It can be Enabled or Disabled.

During network flow, an enabled flow prop injects source carrier amount and pressure or voltage into its connected underground network cell. A disabled flow prop injects nothing.

Consumer Props

A consumer prop can be Enabled or Disabled.

An enabled consumer derives one service state per underground network present beneath it:

  • Supplied: enough carrier and pressure or voltage reaches the underground cell.
  • Starved: supply predicates fail.
  • Producing: the consumer was supplied this simulation step and emits service.

A disabled consumer consumes nothing, produces nothing, and cannot satisfy reactor readiness. A consumer on multiple underground layers consumes all present layers and can satisfy one requirement for each carrier that is producing.

Reactor Control Props

A reactor control prop is the activation site for one reactor. Reactor readiness is derived from level-level consumer count requirements and the networks beneath the reactor control cell.

Junction Props

A junction prop must be on a floor cell whose coordinate has exactly one underground carrier. That carrier is the regulated network.

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.

Doors

A door is a prop on one floor cell. Its orientation is derived from opposing wall cells:

  • north and south walls mean the door sits in an east-west corridor and blocks west/east propagation while closed,
  • west and east walls mean the door sits in a north-south corridor and blocks north/south propagation while closed.

A door must have exactly one valid opposing wall pair. Closed doors block fuel, coolant, electricity, and heat propagation across the corridor cell. They do not block robot movement, underground network flow, source feeding, consumer supply, or hazards already present on either side.

Terminals And Supplies

An all-seeing-eye terminal allows full underground inspection when visited.

Remedy supply props are single-use pickups:

  • FuelRemedySupply,
  • CoolantRemedySupply,
  • ElectricityRemedySupply,
  • HeatRemedySupply.

Each supply provides one matching inventory item and then becomes depleted.

Leaks And Remedies

Each leak stores carrier type, underground coordinate, accessible floor coordinate, and repair state.

Fuel and coolant leaks:

  • occur under floor cells,
  • use the same coordinate as their accessible floor coordinate,
  • can be repaired or remediated by the robot standing on that floor cell.

Electricity leaks:

  • occur in wall cells,
  • store exactly one adjacent floor cell as the emission face,
  • can be repaired or remediated from that floor cell,
  • emit only to that stored face.

All leaks must have valid floor access. Repair changes the underground cell from Leaking to Intact, restores structural integrity to max, and stops future injection. Repair does not clean existing surface hazards.

The robot carries remedial consumables with balance-defined inventory capacity:

  • FuelNeutralizer,
  • CoolantNeutralizer,
  • ElectricityNeutralizer,
  • HeatShield.

Element neutralizers remove the matching surface element from a target floor cell or reachable leak face, then apply a temporary same-element re-entry block. They do not remove other elements, reduce heat, or repair leaks.

Heat shield gives the robot heat immunity for a balance-defined number of movement steps. It does not remove heat, block heat propagation, or protect against fuel, coolant, or electricity hazards.

Network Flow

Network flow runs independently for fuel, coolant, and electricity.

For each carrier:

  1. Clear transient carrier amount and pressure or voltage.
  2. Start from every enabled flow prop connected to that carrier.
  3. Walk through connected intact and leaking underground cells.
  4. Stop at absent cells and disconnected topology.
  5. Apply distance falloff.
  6. Apply valid junction ratio weights.
  7. Assign each reached cell its best incoming carrier amount and best incoming pressure or voltage.
  8. Clamp final values.

Multiple non-ambiguous source paths may reach the same non-junction cell; the cell uses the best carrier amount and best pressure or voltage. Junction ambiguity is a validation error.

A consumer is supplied when carrier amount, pressure or voltage, and connectivity predicates pass.

Surface Hazards

Leaking underground cells remain part of network propagation.

During leak injection:

  • fuel leaks add leaked fuel to the accessible floor cell,
  • coolant leaks add leaked coolant to the accessible floor cell,
  • electricity leaks add leaked electricity to the stored floor emission face,
  • active matching remedy blocks prevent matching element entry.

Injection magnitude is balance data and may depend on local carrier amount, pressure, or voltage.

After injection, the engine evaluates local interactions between leaked fuel, leaked coolant, leaked electricity, and heat on the same floor cell and across unblocked adjacent floor cells.

Fixed Rule Systems

Data-driven rule predicates and effects are not part of level data. Effects happen through fixed systems:

  • player-issued lengthy interactions toggle props, use inventory, open or close doors, repair leaks, and activate reactors,
  • automatic simulation systems propagate networks, resolve consumers, weaken structural integrity, create leaks, spread and react hazards, resolve robot safety, derive reactor state, and refresh forecasts.

Warnings are generated by fixed forecast and status systems when conditions can be proven.

Simulation Order

One lengthy interaction resolves in this order:

  1. Apply the accepted player mutation.
  2. Validate runtime state.
  3. Propagate underground networks.
  4. Resolve consumers and service production.
  5. Resolve structural integrity and automatic leak creation.
  6. Inject leaks.
  7. Evaluate same-cell surface interactions.
  8. Evaluate adjacent floor interactions across unblocked door cells.
  9. Accumulate and apply deltas in deterministic priority order.
  10. Clamp values.
  11. Resolve robot safety.
  12. Derive reactor readiness and level state.
  13. Advance remedy blocks and heat immunity.
  14. Refresh forecasts.

Forecasts

Forecasts are deterministic simulations over copied state. Forecasting does not mutate the actual level.

Forecast output includes:

  • terminal loss forecasts,
  • reactor ready forecasts,
  • starved required consumer warnings,
  • growing hazard warnings when values cross caution or critical bands,
  • structural integrity leak warnings when weakened cells are expected to leak.

The forecast horizon is balance data.

Validation

The editor blocks run and save when validation errors exist. Warnings are visible and non-blocking.

Validation errors:

  • invalid dimensions or cell counts,
  • robot out of bounds or not on floor,
  • wall cell with surface hazards,
  • prop on invalid terrain,
  • invalid required consumer counts,
  • invalid door cell,
  • invalid leak access,
  • junction without exactly one underground carrier,
  • ambiguous junction flow,
  • network loop or equal-source ambiguity at a junction,
  • malformed required data.

Validation warnings:

  • unreachable non-required consumer,
  • underground cell with no source path,
  • initially starved required consumer,
  • initially unready reactor,
  • unused remedy supply,
  • visible hazard with no detectable nearby remedy or route.

Editor And Schema

The editor authors:

  • surface terrain,
  • underground fuel, coolant, and electricity cells,
  • flow props,
  • multi-service consumer props,
  • required fuel, coolant, and electricity consumer counts,
  • junction props and balance-defined ratio mode index,
  • door props,
  • all-seeing-eye terminals,
  • remedy supplies,
  • floor leaks and electricity wall leaks with authored access faces,
  • initial surface hazards and heat,
  • robot start position.

The editor includes layer selection for Surface, Electricity, Fuel, and Coolant:

  • Surface active: surface is full opacity, all underground layers are 25% opacity.
  • Underground active: surface is 50% opacity, inactive underground layers are 25% opacity, active underground layer is full opacity.
  • Coolant renders blue, fuel red, electricity yellow.
  • Networks render as thick lines connecting adjacent cell centers; sources render as large centered dots.
  • Tools are layer-aware. Cursor is always available. Surface terrain, props, consumers, hazards, doors, and heat tools are available only on Surface. Network painting and sources are available only on their matching underground layer.

The serialized level schema stores level metadata, dimensions, terrain, underground layers including structural integrity, props and prop state, required reactor consumer counts, leaks, robot state, inventory, forecasts, and dynamic state when saving active play.

The loader accepts only schema-valid level data and returns clear errors for malformed data.

Balancing And Tests

Balancing defines source strengths, falloff, ratio math, consumer predicates, leak magnitudes, structural integrity thresholds and damage scale, interaction magnitudes, display thresholds, robot safety thresholds, terminal heat thresholds, inventory capacity, remedy duration, heat immunity duration, and forecast horizon.

Tests assert behavior against configured balance values and bands. Coverage includes validation, inferred connectivity, junction effects, multi-service consumer states, reactor readiness and activation, terminal loss, robot hazard loss, heat immunity, structural integrity degradation and leak creation, leak access, remedies, door blocking, forecasts, and serialization round trips.