🧠 High-Level Architecture: Space Simulation System (7019)
🌌 Core Design Principles
| Principle | Description |
| 3D Continuous Space | Objects exist in real-valued (x, y, z) space, not discrete sectors. |
| Time-Driven Simulation | A tick engine runs every Δt, updating all object states. |
| Entity-Component System (ECS) | Each object (ship, planet, wormhole) is an entity composed of components (e.g., physics, sensors). |
| Event-Driven Communication | All meaningful changes generate outbound events published to Redis. |
| Deterministic Logic | Simulation should be replayable/debuggable given same input and seed. |
| Stochastic Interactions | Probability-driven events (e.g., detection rolls, jump gate anomalies). |
| Expandability | Designed for integration with AI (LLM NPCs), diplomacy, economy, etc. |
🔩 Core Components & Systems
| Component | Description |
| Object Manager | Tracks all entities: ID, type, position, velocity, status |
| Physics Engine | Applies Newtonian motion per tick (velocity, acceleration, trajectory) |
| Sensor System | Simulates active/passive scans, stealth, jamming, range attenuation |
| Event Queue | Emits JSON events (arrival, collision, scan result, combat hit) to Redis |
| Interaction Engine | Handles ship-to-ship combat, hailing, boarding, trade, docking |
| Topology Engine | Models wormholes, sector boundaries, restricted zones |
| AI Engine (optional) | For autonomous trade fleets, pirate behavior, NPC reactions |
| Time Manager | Controls tick rate, real-time scaling, and scheduled triggers |
| World Generator | Procedurally builds or loads systems (e.g., stars, planets, stations) |
| Persistence Layer | Saves current state to disk or MariaDB every N ticks |
🌐 Key Objects & Data Structures
- 🌍 Planet: gravity well, orbit path
- 🛰️ Station: docking ports, inventory
- 🔘 Wormhole: exit destination, stability
📏 Space Units & Scaling
| Feature | Value |
| Position | Floating-point meters (or km AU-scale) |
| Time step | 0.5s ticks (tuneable) |
| Detection | Line-of-sight + signal attenuation by distance + stealth rating |
| Range units | Fixed or logarithmic sensor falloff |
🔄 Simulation Loop (Tick Engine)
- For each tick (every 500ms):
- Update all object positions based on velocity and acceleration.
- Check for interactions (arrivals, proximity triggers, collisions).
- Run sensor detection and generate detection events.
- Process queued player commands (via Redis).
- Apply ship systems (cooldowns, recharge, passive systems).
- Emit events as needed (to
bridge:events).
📡 Sensor Model
| Sensor Type | Passive/Active | Notes |
| Visual | Passive | Limited by obstruction and light |
| Radar | Active | Reveals own position, high range |
| Etheric Scan | Active | Long-range; blocked by interference |
| LLM Analysis | Passive | AI-driven sensor interpretation |
| Signature | - | Each ship has a stealth/visibility score |
| ECM/ECCM | - | Electronic countermeasures affect rolls |
🧠 Command Flow (Player → Engine)
PennMUSH sends JSON command to bridge:commands:
{
"ship_id": "VSS-AURORA",
"command": "maneuver",
"heading": [90, 0],
"thrust": 0.4
}
Space engine consumes it, updates trajectory. Tick engine applies physics. Event generated:
{
"event": "arrived",
"ship_id": "VSS-AURORA",
"location": "Tau-Ceti Station",
"timestamp": 8292013.1
}
Event pushed to bridge:events.
🔮 Future Integration Points
- AI/NPCs: Autopilots, traders, pirates, diplomacy
- Docking / Economy: Buy/sell, construct, salvage
- Jump Mechanics: Wormhole decay, time-warp travel
- Environmental Hazards: Nebulae, gravitational wells, radiation zones
- Energy Management: Allocate power between shields, weapons, engines
🧰 Tech Stack
| Subsystem | Language/Lib |
| Space Engine | Rust |
| Serialization | serde_json, ron, or flatbuffers |
| Redis Queue | redis-rs |
| Vector Math | nalgebra, glam |
| Physics/Sim Loop | Custom or integrate with physics engine (e.g., Rapier if needed) |
| Persistence | MariaDB, PostgreSQL, or flat file JSON snapshotting |
| Testing & Debug | CLI harness + deterministic seeds for replayability |