Back to Blog

Stellar Throne Devlog #6 — Zig Parity and Production Deployment

by MrPhil
stellar-thronedevloggame-developmentziggodotparity-testing

Today marks a critical production deployment milestone for Stellar Throne. The Zig simulation engine isn't just fast — it's production-ready.

The Zig Engine Hits 52.7x Performance

After two weeks of development, the Zig simulation engine is complete — delivering a verified 52.7x speedup over the original Godot implementation. Every one of the 1,069 tests passes cleanly.

The question was no longer "Does it work?" but "Can I ship it?"

Parity Testing and Stress Scenarios

A comprehensive parity testing system was built — a harness that runs the exact same turn through both the Godot and Zig engines, then compares every field in the game state to ensure they produce identical results.

Test scenarios ranged from 10 empires with 10 systems each up to 100 empires with 250 star systems.

Three Critical Bugs

1. Negative Resource Spirals

Zig's resource validation could create negative feedback loops if a colony's food production went below zero.

Fix: Added strict validation to prevent negative resource values during calculations.

2. Fleet Upkeep Mismatch

The Godot version used a flat-rate upkeep (10 Energy + 5 Minerals per fleet), but Zig calculated per-ship upkeep.

Fix: Standardized both engines to use the flat-rate formula for base upkeep while keeping per-ship maintenance for hull and weapon costs.

3. Maintenance Persistence Loss

Maintenance costs were being overwritten during stat recalculation, resetting values to zero.

Fix: Preserved maintenance data during the recalculation phase.

After fixing these, stress tests were expanded — pushing edge cases like 200+ fleets per empire, negative production chains, and zero-population planets. That led to 11 parity fixes across both engines.

Deployment Roadblocks and Race Conditions

Two blockers emerged:

  1. Initialization Timing — The Zig backend tried to serialize game state before empires existed. Fixed by correcting property references and restructuring initialization order.

  2. Async Signal Race Condition — The system awaited a signal after it was emitted. Fixed by storing the signal reference before starting the turn.

Deployment Decision: Disabled by Default

After reviewing everything, the cautious decision was made to keep the Zig backend disabled by default for now. Manual enablement is available for testers. The performance boost is real, and parity is 100% confirmed.

Final Stats

  • 20 commits in one day
  • 4,243 new lines of parity infrastructure across 13 files
  • 343-line deployment guide completed
  • 11 parity bugs fixed
  • All 1,069 tests passing
  • 52.7x performance improvement validated

The Zig simulation backend is production-ready, complete with fallback to Godot if anything fails.

Next Steps

  1. Verify signal-timing fixes in live game sessions
  2. Test deployment in extended campaign scenarios
  3. Decide whether to enable Zig automatically or keep manual control