Seed zones from a stable name hash instead of string.GetHashCode (Cut 10)
Closes the 8a follow-up. string.GetHashCode is stable on Mono but randomized per process on .NET Core, so a headless sim that generates zones would get different zones on every run. - Extensions.StableHash folds a string's UTF-8 bytes through CultMath's pcg from the FNV-1a offset basis. No new CultMath API. - ZoneGenerator seeds from `Name.StableHash() ^ pcg3d(Position).x`. - Zone seeds from `Name.StableHash() ?? 1337u`. CultMath's Random maps seed 0 to its default, and the abs/Convert.ToUInt32 pair that threw on int.MinValue is gone. Old runs are discarded, so a different galaxy per seed costs nothing. Tests: StableHashIsNotProcessRandomized pins "Adrasteia" to 2427892944, the value an independent Add-Type transcription of CultMath's pcg produced. It fails with GetHashCode substituted back in. Builds: headless, 15 tests pass, Unity batchmode compile reports no error CS. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
00f62acc34
commit
65a007e509
4 changed files with 18 additions and 3 deletions
|
|
@ -51,7 +51,7 @@ public class Zone
|
|||
Pack = pack;
|
||||
_itemManager = itemManager;
|
||||
Settings = settings;
|
||||
_random = new Random(Convert.ToUInt32(abs(galaxyZone?.Name.GetHashCode() ?? 1337)));
|
||||
_random = new Random(galaxyZone?.Name.StableHash() ?? 1337u);
|
||||
var cache = itemManager.ItemData;
|
||||
|
||||
foreach (var orbit in pack.Orbits)
|
||||
|
|
|
|||
Loading…
Reference in a new issue