Construction Sector

Purpose: The ConstructionSector is the primary engine of growth for the lunar base. It manages the entire construction pipeline, from producing basic structural components to assembling complex, functional modules. It acts as a “make-to-order” factory, responding to construction_request events from other sectors to expand their capabilities.

Core Components:

  • PrintingRobot: An autonomous agent that consumes raw regolith and power to 3D print structural “shells,” the basic building blocks for all modules.

  • AssemblyRobot: A more advanced agent that takes a pre-printed shell and combines it with a specific piece of equipment (e.g., a science instrument, a life support unit) to create a final, operational module.

  • ConstructionRequest: A data object that represents a single construction project, tracking its requirements (shells, equipment), its status (queued, in-progress), and the robot assigned to it.

  • Module-to-equipment mapping: Shared construction equipment requirements are defined centrally in world_system_defs.py through MODULE_TO_EQUIPMENT_MAP.


Operational Cycle & Key Algorithms

The sector operates a two-stage production line: first producing shells into a local inventory, then using those shells to fulfill construction orders.

        flowchart TD
    RequestingSector["Requesting Sector"] -->|construction_request| Intake["Construction Intake"]
    Intake --> Queue["Construction Queue"]

    Regolith["Regolith Supply"] --> Printing["Shell Production<br/>Printing Robots"]
    Printing --> ShellStock["Shell Stock<br/>limited by shell_storage_capacity"]

    Queue --> Planning["Project Planning<br/>limited by max_concurrent_projects"]
    Planning --> ResourceGate{"Shells and equipment<br/>available?"}

    ResourceGate -->|Missing equipment| EquipmentRequest["Equipment Request"]
    EquipmentRequest -->|equipment_request| EquipmentManufacturing["Equipment Manufacturing Sector"]
    EquipmentManufacturing -->|equipment_allocated| EquipmentStock["Construction Equipment Stock"]

    ShellStock --> ResourceGate
    EquipmentStock --> ResourceGate

    ResourceGate -->|Ready| Assembly["Module Assembly<br/>Assembly Robots"]
    Assembly --> CompletedModule["Completed Module"]
    CompletedModule -->|module_completed| RequestingSector

    Assembly --> Metrics["Construction Metrics<br/>queue, shells, robots, completions"]
    Printing --> Metrics
    

A. Shell Production (_manage_printing_operations) The sector employs a “make-to-stock” strategy for shells.

  • Proactive Printing: Idle PrintingRobots automatically start printing a new shell whenever the sector’s shell count (_state.shells) is below the configured shell_storage_capacity.

  • Resource Consumption: Each completed shell consumes a fixed amount of regolith (regolith_usage_kg) and takes a fixed number of simulation steps (processing_time_steps, derived from the configured processing_time_h and the model’s time_scale).

  • Power Gating: Robots are stepped in fleet order, each drawing from whatever power remains after earlier robots in the same step. A robot whose demand exceeds the power left over is throttled for that step (counted in robots_throttled_this_step) and makes no progress; it is not a partial/scaled-down step.

B. Request Intake (handle_construction_request)

  • Another sector publishes a construction_request for a new module (e.g., a new science rover for the ScienceSector), naming a module_id and the number of shells needed.

  • The equipment the module requires is looked up via get_equipment_type_for_module (backed by MODULE_TO_EQUIPMENT_MAP); modules with no mapped equipment type need none.

  • The ConstructionSector creates a ConstructionRequest and appends it to construction_queue in a QUEUED state.

C. Resource Check & Acquisition (_start_construction_project)

  • For a QUEUED request, the sector checks resources in this order:

    1. Equipment: Does it have the required specialized equipment (e.g., Science_Rover_EQ) in its local equipment_stock?

    2. Shells: Are there enough shells in local storage?

  • If equipment is missing: the sector publishes a one-time equipment_request to the equipment manufacturing sector (guarded by the request’s equipment_requested flag so it isn’t re-sent every step) and the request stays QUEUED.

  • If only shells are missing: the request stays QUEUED and the sector simply waits for PrintingRobots to produce more; no event is published.

  • If all resources are available: both are deducted from inventory and the project proceeds to assembly.

D. Assembly (_start_construction_project & _advance_construction_project)

  • An idle AssemblyRobot is assigned to the request, which transitions to IN_PROGRESS; the robot works for a fixed number of steps (assembly_time_steps, derived from the configured assembly_time_h).

  • _process_construction_queue advances all IN_PROGRESS requests before starting new ones, and only starts as many new projects as max_concurrent_projects allows and idle assembly robots permit.

  • Assembly robots are power-gated the same way as printing robots: a request’s assigned robot is throttled (no progress that step) if the remaining power after earlier robots can’t cover its demand.

  • If an assigned robot fails to start (start_assembly returns False), the reserved shells and equipment are returned to inventory and the request stays QUEUED.

E. Completion (_advance_construction_project)

  • Once the assembly timer reaches zero, the robot returns to IDLE and is unassigned from the request.

  • The request is marked COMPLETED (and removed from construction_queue on the next pass through _process_construction_queue).

  • The sector publishes a module_completed event carrying requesting_sphere and module_id, signaling to the original requesting sector that its new module is ready.


Configuration Options

The sector’s capabilities are defined in the world_system JSON file, specifying the number of robots and their operational parameters. Each robot entry’s tunables live under a nested config object; unset fields fall back to defaults in PrintingRobot/AssemblyRobot (e.g. max_power_usage_kWh: 65/50, processing_time_h: 80, assembly_time_h: 60, regolith_usage_kg: 200, efficiency: 0.9).

"construction": {
  "sector_name": "construction",
  "max_concurrent_projects": 3,
  "shell_storage_capacity": 10,
  "printing_robots": [
    {
      "quantity": 2,
      "config": {
        "max_power_usage_kWh": 65,
        "processing_time_h": 80,
        "regolith_usage_kg": 200
      }
    }
  ],
  "assembly_robots": [
    {
      "quantity": 2,
      "config": {
        "max_power_usage_kWh": 50,
        "assembly_time_h": 60
      }
    }
  ]
}

TODO: Potential Improvements

  • [ ] Implement Dynamic Fleet Growth: The sector should listen for module_completed events for Printing_Robot_EQ and Assembly_Robot_EQ to dynamically add new robots to its fleet as they are constructed, rather than only instantiating robots from the initial world_system config.