M1: Headless parity verified between Tools and Godot
Proves Theriapolis.Core works untouched under Godot's csproj — the worldgen
pipeline produces byte-identical output whether invoked from the Tools CLI
or from inside the Godot process. This is the determinism contract surviving
the port.
Architecture test:
CoreNoDependencyTests now forbids Godot.* and GodotSharp in addition to
Microsoft.Xna and MonoGame. Both bans stay in force for the duration of
the port so neither engine can leak into Core.
Determinism oracle:
New worldgen-hash Tools command runs the full pipeline and prints FNV-1a
hashes for every channel (elevation, moisture, temperature, biomes,
settlements, polylines) plus per-stage hashes. Pairs with the Godot
smoke-test for cross-process verification.
Godot-side smoke test:
SmokeTest.cs runs WorldGenerator.RunAll inside the Godot process; Main.cs
fires it on --smoke-test <seed>. Resolves Content/Data via res:// walk-up.
M0 hello-world behaviour preserved when launched without the flag.
Verification (seed 12345):
- dotnet run -- worldgen-hash and Godot --headless --smoke-test agree on
all 6 channels and all 14 per-stage hashes (diff produces zero output)
- 10-run sweeps stable on both sides post-determinism-fix
- dotnet test: 708/708 pass
Closes M1 of theriapolis-rpg-implementation-plan-godot-port.md.
Next: M2 (world map render).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,27 @@ public partial class Main : Node
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
var args = OS.GetCmdlineUserArgs();
|
||||
ulong? smokeTestSeed = null;
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
{
|
||||
if (args[i] == "--smoke-test")
|
||||
{
|
||||
ulong seed = 12345UL;
|
||||
if (i + 1 < args.Length && ulong.TryParse(args[i + 1], out var parsed))
|
||||
seed = parsed;
|
||||
smokeTestSeed = seed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (smokeTestSeed.HasValue)
|
||||
{
|
||||
int code = SmokeTest.Run(smokeTestSeed.Value);
|
||||
GetTree().Quit(code);
|
||||
return;
|
||||
}
|
||||
|
||||
GD.Print("Theriapolis.Godot host ready (M0 hello-world).");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
using Godot;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Theriapolis.Core.World.Generation;
|
||||
|
||||
namespace Theriapolis.GodotHost;
|
||||
|
||||
/// <summary>
|
||||
/// M1 determinism oracle. Runs the full Core worldgen pipeline from inside
|
||||
/// the Godot process and prints FNV hashes. Output must match
|
||||
/// <c>dotnet run --project Theriapolis.Tools -- worldgen-hash --seed N</c>
|
||||
/// byte-for-byte. This proves Core works untouched under Godot's csproj.
|
||||
/// </summary>
|
||||
public static class SmokeTest
|
||||
{
|
||||
public static int Run(ulong seed)
|
||||
{
|
||||
string dataDir = ResolveDataDir();
|
||||
if (!Directory.Exists(dataDir))
|
||||
{
|
||||
GD.PrintErr($"[smoke-test] Data directory not found: {dataDir}");
|
||||
return 1;
|
||||
}
|
||||
|
||||
GD.Print($"[smoke-test] seed=0x{seed:X} data-dir={dataDir}");
|
||||
var ctx = new WorldGenContext(seed, dataDir);
|
||||
WorldGenerator.RunAll(ctx);
|
||||
var w = ctx.World;
|
||||
|
||||
GD.Print($"[smoke-test] === FNV hashes ===");
|
||||
GD.Print($"[smoke-test] elevation = 0x{w.HashElevation():X16}");
|
||||
GD.Print($"[smoke-test] moisture = 0x{w.HashMoisture():X16}");
|
||||
GD.Print($"[smoke-test] temperature = 0x{w.HashTemperature():X16}");
|
||||
GD.Print($"[smoke-test] biomes = 0x{w.HashBiomes():X16}");
|
||||
GD.Print($"[smoke-test] settlements = 0x{w.HashSettlements():X16}");
|
||||
GD.Print($"[smoke-test] polylines = 0x{w.HashPolylines():X16}");
|
||||
GD.Print($"[smoke-test] === Per-stage hashes ({w.StageHashes.Count}) ===");
|
||||
foreach (var kv in w.StageHashes.OrderBy(k => k.Key, System.StringComparer.Ordinal))
|
||||
GD.Print($"[smoke-test] {kv.Key,-32} = 0x{kv.Value:X16}");
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static string ResolveDataDir()
|
||||
{
|
||||
string fromRes = ProjectSettings.GlobalizePath("res://../Content/Data");
|
||||
if (Directory.Exists(fromRes)) return fromRes;
|
||||
|
||||
string? dir = ProjectSettings.GlobalizePath("res://").TrimEnd('/', '\\');
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (string.IsNullOrEmpty(dir)) break;
|
||||
string candidate = Path.Combine(dir, "Content", "Data");
|
||||
if (Directory.Exists(candidate)) return candidate;
|
||||
dir = Path.GetDirectoryName(dir);
|
||||
}
|
||||
|
||||
return fromRes;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user