Hey everyone — MrPhil here with a major development update for Stellar Throne, my sci-fi 4X strategy game.
This week I finished implementing all 21 simulation phases in Zig and brought the parity testing framework online to compare Zig vs. Godot turn-by-turn. The Zig engine is feature-complete at the phase level, but there are still parity differences to resolve before it becomes the default runtime.
🧠 Dual-Engine Architecture (Why Two Engines?)
Godot handles the UI, visualization, and input.
Zig runs the high-performance simulation of empires, colonies, economies, and galactic systems.
The goal is to keep Godot flexible while Zig delivers raw simulation speed — both verified through automated parity testing.
⚙️ Track Two Wrap-Up: 21 Phases Implemented
At the start of the week, only a few phases were functional. By the end, all 21 simulation phases were implemented and validated at the unit level.
Highlights:
Population growth, colony development, infrastructure maintenance
Resource extraction and production chains
Fleet movement and logistics
Natural disasters and random events
Quest system and narrative progression
Diplomacy drift, relationship updates, and victory conditions
Military combat resolution and research progression
Final integration phase that ties everything together
Each phase includes validation tests to ensure predictable behavior.
🧩 Real Data via TOML (No More Magic Numbers)
I ported the TOML configuration system so the simulation now loads real game data:
load_gameplay()— balance parameters and constantsload_resources()— economy definitions and production chainsload_content()— events, quests, and narrative triggers
This added 800 + lines of Zig, replacing thousands of hard-coded values.
On the Godot side, the Research Manager migrated from JSON to TOML for consistency.
🧪 Test Suite Rehab + Fixes
The Zig test suite had bit-rotted (wrong layout, 91 compile errors).
I:
Reorganized tests under
src/testsWrote a test health monitor script
Fixed 11 failing tests (RNG distribution, TOML table arrays, event weighting, colony growth, diplomacy drift)
✅ All Zig tests now pass.
🌉 Godot ↔ Zig Bridge + Parity Harness
Built the Turn Simulation Service in Godot:
Serialize state to JSON
Run a turn in Zig
Deserialize results back into Godot
Added:
Runtime engine toggle (Godot ↔ Zig A/B testing)
Parity testing framework that runs identical turns in both engines and compares every field across 10–100 empires and 10–250 systems
🔎 What Parity Testing Found (Work in Progress)
Godot and Zig diverge slightly on population growth and stability formulas.
Some mismatches come from floating-point drift and minor logic differences.
So, while Zig has feature parity at the phase level, behavioral parity is not yet complete.
⚡ Performance Snapshot
In large galaxy tests, the Zig simulation ran ≈ 52.7× faster than Godot.
📈 Commits at a Glance
| Area | Lines Added | Notes |
|---|---|---|
| Zig Simulation | ~5 000 | Turn simulator, data structures, config loader |
| Tests | ~2 000 | 9 new test files |
| Godot Integration | 376 | Turn Simulation Service |
| Debug Toggle | 139 | Runtime engine swap |
| Parity Framework | 864 | Cross-engine verification |
| Docs | Extensive | Phase summaries + testing guides |
✅ Current Status
✅ All 21 phases implemented in Zig
✅ All Zig tests passing
✅ TOML data loader integrated
✅ Parity testing framework online
🚧 Parity differences remain to be resolved
🚧 Zig engine not default yet
🔭 Next Steps
Fix remaining parity gaps (population, stability, diplomacy)
Reduce floating-point variance
Once identical outputs are confirmed, switch to Zig as default for full performance gain
That’s this week’s devlog — thanks for reading!
Follow progress and upcoming milestones at mrphilgames.com.
— MrPhil