Mr. Phil Games’ Blog

Posts for Tag: 4X Strategy

Stellar Throne Devlog #5 — All 21 Zig Simulation Phases Implemented + Parity Tester Online (52.7× Faster)

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 constants

  • load_resources() — economy definitions and production chains

  • load_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/tests

  • Wrote 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:

  1. Serialize state to JSON

  2. Run a turn in Zig

  3. 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

Ground Combat & Territory Borders Revamped

This week’s updates brought big strides in polish and clarity for Stellar Throne. Ground combat now displays strength bars above their respective forces, making planetary invasions easier to read. Ownership now correctly updates after successful invasions, and the final phase of an invasion plays out as intended.

On the combat side, the battlefield grid now renders fully, fleets start in centered positions, and you can left-click + drag to move the map. Support ships have distinct plus-shaped icons, colony ships use circles, and troop ships have been fully renamed for clarity. Fleets with no ships are automatically cleaned up after combat, reducing clutter.

Outside battle, draggable UI panels (shipyard, diplomacy, bombardment) were unified under a new DraggablePanel base class, making the interface smoother. Loading screens are more responsive, and territory borders now update dynamically after colonization. The border system itself has been revamped with shaders, opening the door for smoother, more striking visuals.

This update brings Stellar Throne one step closer to feeling like a finished 4X experience.

Stellar Throne Changelog Week of August 8–15, 2025

🌟 What’s New

This week brings major planetary warfare upgrades with the new Orbital Bombardment and Ground Invasion systems, a redesigned Ground Combat UI, smoother combat flow, and dozens of bug fixes and performance improvements. If you’ve been waiting to crush enemy worlds in style, now’s the time.


🆕 New Features

  • Orbital Bombardment System — Added comprehensive orbital bombardment mechanics with UI controls, allowing fleets to weaken planetary defenses before invasion.

  • Ground Invasion — Implemented ground invasion capability integrated with bombardment UI for a seamless planet conquest workflow.

  • Ground Combat UI Redesign — Enhanced battlefield visualization with army strength bars displayed above unit columns for better awareness.


⚔️ Combat Improvements

  • Damage Visualization — Incremental damage application synchronized with weapon effects for more engaging combat feedback.

  • Destroyed Ship Feedback — Clear visual indicators when ships are destroyed in combat.

  • Ship Detail Panel — Panel now closes automatically when combat begins.

  • Combat Flow — Smoother battle completion and input handling for consecutive battles.

  • Auto-Resolve — Fixed to jump directly to the final combat state.


🐞 Bug Fixes

  • Fixed multiple combat UI issues including scroll isolation, input handling, and grid cell highlighting.

  • Resolved ship targeting bug where destroyed ships could regenerate.

  • Fixed timing issues so destruction animations play at proper turn end.

  • Corrected ships having zero energy capacity in combat.

  • Fixed double damage and combat synchronization issues.

  • Resolved input handling problems when switching between combat and starmap views.

  • Fixed ground combat final screen to properly display complete phase results.


🎨 UI/UX Improvements

  • Enhanced scroll wheel isolation between UI panels and galaxy view.

  • Improved memory management in combat UI systems.

  • Better defender priority handling for grid cell movement conflicts.

  • Cleaner, modular architecture for combat UI components.


🛠 Technical Updates

  • Refactored project documentation into a modular structure for better maintainability.

  • Resolved SpatialGrid naming conflicts in CombatManager.

  • Reduced test suite orphan count and fixed various test failures.

  • Removed debug print statements and cleaned up temporary test files.


🚀 Performance & Stability

  • Improved combat animation system performance.

  • Enhanced memory management across UI systems.

  • Better error handling for bombardment operations involving Building resources.