Merge eureka/aetheria-release-cultmath-0-3-pin: CultMath 0.3.0 (BoundedLeastSquares), the pin guard fires on Linux, fixtures stop depending on the re-rolled galaxy

Soul s1-s2 hold (aetheria-release:verdict:cut-cultmath-0-3-pin.s2). The generated galaxy re-rolls with the noise kernel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-09 16:24:28 +02:00
commit a04ab767b9
7 changed files with 92 additions and 24 deletions

View file

@ -6,8 +6,8 @@
<CultLibRevision>45c2f4006f5f7dab357426cabd3197e8d0a17f66</CultLibRevision>
<CultMathRoot Condition="'$(CultMathRoot)' == '' and '$(CULTMATH_ROOT)' != ''">$(CULTMATH_ROOT)</CultMathRoot>
<CultMathRoot Condition="'$(CultMathRoot)' == ''">$(CultLibRoot)</CultMathRoot>
<!-- CultMath: cultmath-unity-v0.2.4 in Packages/manifest.json. -->
<CultMathRevision>6d5e2096563a320933b64ddfd6ded8f2e846ac91</CultMathRevision>
<!-- CultMath: cultmath-unity-v0.3.0 in Packages/manifest.json. -->
<CultMathRevision>614fd445845f6251ee2986707beecea0bb211791</CultMathRevision>
<GitExecutable Condition="'$(GitExecutable)' == '' and Exists('C:\Program Files\Git\cmd\git.exe')">C:\Program Files\Git\cmd\git.exe</GitExecutable>
<GitExecutable Condition="'$(GitExecutable)' == ''">git</GitExecutable>
</PropertyGroup>

View file

@ -18,7 +18,7 @@
<Target Name="VerifyCultLibRevision"
BeforeTargets="ResolveProjectReferences"
Outputs="%(PinnedCultLib.Identity)"
Condition="'$(SkipCultLibRevisionCheck)' != 'true' and '@(ProjectReference->AnyHaveMetadataValue('Identity', '$(CultMathRoot)\packages\cultmath\src\CultMath\CultMath.csproj'))' == 'true'">
Condition="'$(SkipCultLibRevisionCheck)' != 'true' and '@(ProjectReference->WithMetadataValue('Filename','CultMath'))' != ''">
<Error Condition="!Exists('%(PinnedCultLib.Root)\%(PinnedCultLib.Project)')"
Text="%(PinnedCultLib.RootProperty) '%(PinnedCultLib.Root)' does not contain %(PinnedCultLib.Project)." />
<Exec Command="&quot;$(GitExecutable)&quot; -C &quot;%(PinnedCultLib.Root)&quot; rev-parse HEAD"

View file

@ -54,6 +54,6 @@
"com.unity.modules.xr": "1.0.0",
"org.gamecult.caching.unity": "https://github.com/GameCult/CultLib.git?path=/src/GameCult.Unity/Assets/Caching#caching-unity-v1.4.0",
"org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.60",
"org.gamecult.cultmath": "https://github.com/GameCult/CultLib.git?path=/packages/cultmath/unity/org.gamecult.cultmath#cultmath-unity-v0.2.4"
"org.gamecult.cultmath": "https://github.com/GameCult/CultLib.git?path=/packages/cultmath/unity/org.gamecult.cultmath#cultmath-unity-v0.3.0"
}
}

View file

@ -272,11 +272,11 @@
"hash": "45c2f4006f5f7dab357426cabd3197e8d0a17f66"
},
"org.gamecult.cultmath": {
"version": "https://github.com/GameCult/CultLib.git?path=/packages/cultmath/unity/org.gamecult.cultmath#cultmath-unity-v0.2.4",
"version": "https://github.com/GameCult/CultLib.git?path=/packages/cultmath/unity/org.gamecult.cultmath#cultmath-unity-v0.3.0",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "6d5e2096563a320933b64ddfd6ded8f2e846ac91"
"hash": "614fd445845f6251ee2986707beecea0bb211791"
},
"com.unity.modules.accessibility": {
"version": "1.0.0",

View file

@ -220,7 +220,7 @@ public sealed partial class RunStartTests
" | zones " + g.Zones.Length +
" | owners " + string.Join(",", g.Zones.Select(z => z.Owner == null ? "-" : z.Owner.ShortName));
// Measured on 228f241e, before the demo cut, at seed 1.
// Measured at seed 1 under CultMath 0.3.0 (cultmath-unity-v0.3.0); the noise kernel changed there, which re-rolled the galaxy.
private const string TutorialSeed1 =
"Miss Terri’s Sugariffic Snack Company,Zhestokost,Lucent Media,Adrasteia,Aeronautics Unlimited,Finch Cybernetics | homes 47,10,17,49,35,1 | entrance 25 | zones 64 | owners Zhestokost,Finch,Lucent,Zhestokost,Finch,Adrasteia,Zhestokost,Adrasteia,Zhestokost,Zhestokost,Zhestokost,Zhestokost,Finch,Lucent,Adrasteia,Adrasteia,Zhestokost,Lucent,Finch,Finch,Lucent,Lucent,Finch,AU,Adrasteia,-,-,Adrasteia,Lucent,-,AU,Lucent,Zhestokost,Lucent,Lucent,AU,Adrasteia,AU,Lucent,AU,Finch,Finch,-,Lucent,Zhestokost,Zhestokost,Miss Terri's,Miss Terri's,Miss Terri's,Adrasteia,Finch,-,-,Miss Terri's,Lucent,AU,Miss Terri's,Zhestokost,Lucent,Lucent,Lucent,Finch,-,-";
"Miss Terri’s Sugariffic Snack Company,Zhestokost,Lucent Media,Adrasteia,Aeronautics Unlimited,Finch Cybernetics | homes 3,44,40,19,0,30 | entrance 12 | zones 64 | owners AU,AU,Finch,Miss Terri's,Lucent,Zhestokost,-,Lucent,AU,AU,Lucent,Adrasteia,-,Finch,Zhestokost,-,Adrasteia,-,AU,Adrasteia,AU,Zhestokost,Miss Terri's,-,AU,Finch,Miss Terri's,-,Zhestokost,-,Finch,-,-,AU,-,-,-,-,Miss Terri's,AU,Lucent,-,Finch,-,Zhestokost,AU,-,Zhestokost,Adrasteia,Adrasteia,AU,Miss Terri's,Finch,AU,Finch,-,Lucent,Zhestokost,-,AU,Miss Terri's,Zhestokost,-,Lucent";
}

View file

@ -502,7 +502,7 @@ public sealed partial class RunStartTests
}
// Two shooters on opposite sides of the same target, 200 m away: one with a projectile gun and one with a laser
// (a beam's authored velocity is 0, a flight time of zero). The target is the generated Djinni, the catalog's one ship that strafes.
// (a beam's authored velocity is 0, a flight time of zero). The target is the fitted Djinni, the catalog's one ship that strafes.
private sealed class EvRange
{
public Zone Arena;
@ -510,6 +510,18 @@ public sealed partial class RunStartTests
public Weapon Gun, Laser, GunnerLaser;
}
// The target's fit, written out: the Djinni's own hardpoints filled with the Talaria it is generated with, its
// reactor, cockpit and radiators. What the evasion tests price is this ship's strafing, not whatever the generator
// rolls for it from the galaxy.
private static ScenarioFit EvDjinni(ScenarioStage stage) => stage.Fit("Djinni",
("Cockpit 2x2", int2(6, 3), ItemRotation.None), ("Core Power", int2(6, 11), ItemRotation.None),
("Talaria", int2(6, 0), ItemRotation.Reversed), ("Talaria", int2(5, 1), ItemRotation.Reversed), ("Talaria", int2(7, 1), ItemRotation.Reversed),
("Talaria", int2(4, 4), ItemRotation.CounterClockwise), ("Talaria", int2(4, 11), ItemRotation.CounterClockwise),
("Talaria", int2(9, 4), ItemRotation.Clockwise), ("Talaria", int2(9, 11), ItemRotation.Clockwise),
("Talaria", int2(6, 14), ItemRotation.None),
("Iapyx", int2(1, 4), ItemRotation.Reversed), ("Iapyx", int2(3, 1), ItemRotation.Reversed),
("Iapyx", int2(9, 1), ItemRotation.Reversed), ("Iapyx", int2(11, 4), ItemRotation.Reversed));
private EvRange EvRangeLaunch()
{
Ship gunner = null, lasing = null, target = null;
@ -517,7 +529,7 @@ public sealed partial class RunStartTests
{
stage.Player(stage.Bare("Djinni"), float2(-50000, -50000));
gunner = stage.Place(EvLonginus(stage, "FastBlast+-", "ColdFire"), float2(0, 0), facing: float2(0, 1)) as Ship;
target = stage.Place(stage.Generated("Djinni"), float2(0, 200), facing: float2(0, 1)) as Ship;
target = stage.Place(EvDjinni(stage), float2(0, 200), facing: float2(0, 1)) as Ship;
lasing = stage.Place(EvLonginus(stage, "ColdFire"), float2(0, 400), facing: float2(0, -1)) as Ship;
});
var (_, arena, _, failures) = Launch(scenario, Inputs(() => GalaxySeed));
@ -572,6 +584,10 @@ public sealed partial class RunStartTests
return (hits, price);
}
// The two volleys' hit counts are rolls, so their gap is the price gap plus noise. At the price gap this fixture
// has (about .06 on .44) 200 shots flip the comparison one seed in eight; this many keeps it near four standard deviations.
private const int EvVolleySize = 2000;
// The evasion term is in the live price, the HUD's forecast and the roll: a ship crossing at 150 m/s that has been
// jinking is harder to hit than the same ship coasting, for a projectile gun.
[Fact]
@ -585,7 +601,7 @@ public sealed partial class RunStartTests
EvCross(range, jinking: false);
var coastingDiagnostic = FireControl.Inspect(gun, shooter, target);
var coastingPrice = FireControl.HitProbability(gun, shooter, target);
var coasting = EvVolley(range, gun, shooter, 200);
var coasting = EvVolley(range, gun, shooter, EvVolleySize);
Assert.Equal(0f, coastingDiagnostic.Evasion);
Assert.Equal(1f, coastingDiagnostic.PEvasion);
Assert.True(coastingPrice > .2f, $"fixture: a coasting target is hittable ({coastingPrice})");
@ -593,10 +609,10 @@ public sealed partial class RunStartTests
EvCross(range, jinking: true);
var jinkingDiagnostic = FireControl.Inspect(gun, shooter, target);
var jinkingPrice = FireControl.HitProbability(gun, shooter, target);
var jinking = EvVolley(range, gun, shooter, 200);
Console.WriteLine($"EVASION price: coasting {coastingPrice:F3} hits {coasting.hits}/200 committed {coasting.price:F3}; " +
var jinking = EvVolley(range, gun, shooter, EvVolleySize);
Console.WriteLine($"EVASION price: coasting {coastingPrice:F3} hits {coasting.hits}/{EvVolleySize} committed {coasting.price:F3}; " +
$"jinking {jinkingPrice:F3} (evasion {jinkingDiagnostic.Evasion:F2} m, tracking {jinkingDiagnostic.Tracking:F1}, PEvasion {jinkingDiagnostic.PEvasion:F3}) " +
$"hits {jinking.hits}/200 committed {jinking.price:F3}");
$"hits {jinking.hits}/{EvVolleySize} committed {jinking.price:F3}");
Assert.True(jinkingDiagnostic.Evasion > 0f);
Assert.True(jinkingDiagnostic.PEvasion < 1f);

View file

@ -116,6 +116,56 @@ public sealed class RestoredHullsTests
return planetOrbits.Count(o => o.Parent.IsSet() && o.Parent.Key.Equals(orbit.Parent.Key) && abs(o.Distance - orbit.Distance) < .1f) > 1;
}
// The zone a test needs is chosen by the property its claim is about, from the galaxy the generator rolled, because
// which zone has that property follows the noise kernel (CultMath 0.3.0 re-rolled "EAC-7089" and "EAC-2733" away).
// A planet orbit is a genuine Lagrange candidate when it is the only planet at its distance under its parent --
// exactly what ZoneGenerator's potentialLagrangePoints filter keeps.
private static OrbitData[] ParentedPlanetOrbits(CultCache cache, ZonePack pack) =>
pack.Planets.Select(p => cache.Get(cache.Get(p).Orbit)).Where(o => o.Parent.IsSet()).ToArray();
private static bool HasGenuineLagrangeCandidate(OrbitData[] planetOrbits) =>
planetOrbits.Any(o => planetOrbits.Count(c => c.Parent.Key.Equals(o.Parent.Key) && abs(c.Distance - o.Distance) < .1f) == 1);
// The first seed, and in its tutorial galaxy the first non-entrance zone, that has planets every one of which is a
// rosette member: no genuine Lagrange candidate, so only the entrance's widened candidate set can seat a station
// there. Such a zone is rare, so seeds are tried in order until one has it.
// The scan is the cost (tens of seconds), and it depends only on the generator, so both tests share one result
// through a lazy computed under its own scratch run store.
private static readonly Lazy<(uint seed, string zoneName)> NoLagrangeCandidateZoneScan = new(ScanForNoLagrangeCandidateZone);
private static (uint seed, string zoneName) NoLagrangeCandidateZone() => NoLagrangeCandidateZoneScan.Value;
private static (uint seed, string zoneName) ScanForNoLagrangeCandidateZone()
{
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-nolagrange-scan-{Guid.NewGuid():N}.cc");
try
{
using var cache = OpenReadOnlyRealCatalogWithScratchRun(Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc"), scratchRun);
return ScanForNoLagrangeCandidateZone(cache);
}
finally
{
if (File.Exists(scratchRun)) File.Delete(scratchRun);
}
}
private static (uint seed, string zoneName) ScanForNoLagrangeCandidateZone(CultCache cache)
{
var items = new ItemManager(cache, new ProvenanceLedger(), Settings(), _ => { });
for (var seed = 1u; seed <= 64u; seed++)
{
var galaxy = new Galaxy(TutorialGalaxySettings(), TutorialBackgroundSettings(), TutorialNameSettings(),
cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed);
foreach (var zone in galaxy.Zones.Where(z => !ReferenceEquals(z, galaxy.Entrance)))
{
var orbits = ParentedPlanetOrbits(cache, ZoneGenerator.GenerateZone(items, TutorialZoneSettings(), galaxy, zone, isTutorial: false, ambient: false));
if (orbits.Length > 0 && !HasGenuineLagrangeCandidate(orbits)) return (seed, zone.Name);
}
}
Assert.Fail("fixture: no tutorial galaxy at seeds 1-64 has a zone whose planets are all rosette members.");
return default;
}
// ZoneGenerator.GenerateZone writes OrbitData/BodyData (run-store types, AetheriaStores.RunTypes), so a
// catalog-only cache has no home for them. A scratch run file, deleted after the seed that used it.
private static CultCache OpenReadOnlyRealCatalogWithScratchRun(string catalogPath, string runPath)
@ -652,8 +702,8 @@ public sealed class RestoredHullsTests
return new Galaxy(cache, game, _ => { });
}
// Cut 1 fix batch 2 (Soul's finding #2): the tutorial entrance's widened candidate set. Seed 3's real tutorial
// galaxy has a zone, "EAC-7089", whose planets are entirely one rosette with no captured satellites at all: 4
// Cut 1 fix batch 2 (Soul's finding #2): the tutorial entrance's widened candidate set. A real tutorial
// galaxy has a zone (NoLagrangeCandidateZone finds one; under CultMath 0.2.x it was seed 3's "EAC-7089"), whose planets are entirely one rosette with no captured satellites at all: 4
// planets sharing one Distance under one Parent, and nothing else -- potentialLagrangePoints is empty for it
// (verified directly against this exact fixture, not carried over from Soul's own forced-fallback probe, whose
// own candidate check undercounted planet orbits by using pack.Planets.Count -- which excludes Empty rosette
@ -678,7 +728,8 @@ public sealed class RestoredHullsTests
try
{
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
var galaxy = BuildGalaxyWithForcedEntrance(cache, seed: 3u, "EAC-7089");
var (seed, zoneName) = NoLagrangeCandidateZone();
var galaxy = BuildGalaxyWithForcedEntrance(cache, seed, zoneName);
var items = new ItemManager(cache, new ProvenanceLedger(), Settings(), _ => { });
var pack = ZoneGenerator.GenerateZone(items, TutorialZoneSettings(), galaxy, galaxy.Entrance, isTutorial: true);
@ -716,7 +767,7 @@ public sealed class RestoredHullsTests
// Cut 1 fix batch 2 (Soul's finding #2, leak check): the entrance override must not leak to (a) other
// tutorial zones or (b) a non-tutorial game's own entrance zone. Both are pinned against a seed-1 galaxy --
// the widened-candidate test above uses a different fixture, seed 3's "EAC-7089" -- so this test and the one
// the widened-candidate test above uses a different fixture, NoLagrangeCandidateZone's -- so this test and the one
// below it stand or fall on this one known fixture, not that one.
[Fact]
public void EntranceOverrideDoesNotLeakToOtherTutorialZonesOrNonTutorialGames()
@ -737,7 +788,8 @@ public sealed class RestoredHullsTests
// (a) A non-entrance tutorial zone that naturally rolls zero stations keeps that roll under
// isTutorial: true -- the floor must not leak past the galaxy.Entrance reference check.
var otherZone = galaxy.Zones.Single(z => z.Name == "EAC-2733");
// The zone is chosen by its natural roll: zero stations without the tutorial floor (isTutorial: false).
var otherZone = galaxy.Zones.First(z => !ReferenceEquals(z, galaxy.Entrance) && StationCount(z, isTutorial: false) == 0);
Assert.NotSame(galaxy.Entrance, otherZone);
Assert.Equal(0, StationCount(otherZone, isTutorial: true));
@ -792,7 +844,7 @@ public sealed class RestoredHullsTests
}
// Cut 1 fix batch 3 (F6, N2): the entrance-only widening must not leak to a non-entrance zone that would
// otherwise get zero stations. Seed 3's "EAC-7089" (the same no-Lagrange fixture the widened-candidate test
// otherwise get zero stations. NoLagrangeCandidateZone's zone (the same no-Lagrange fixture the widened-candidate test
// above uses, this time NOT retargeted as Entrance) rolls a real, nonzero station count on its own -- forced
// here by boosting one faction's presence there (HomeZone distance 0, InfluenceDistance 50, so the roll's
// floor(rand * (factionPresence+1)) is overwhelmingly likely nonzero) via the same public SavedGame round
@ -848,8 +900,9 @@ public sealed class RestoredHullsTests
try
{
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
var galaxy = BuildGalaxyWithBoostedPresence(cache, seed: 3u, "EAC-7089");
var zone = galaxy.Zones.Single(z => z.Name == "EAC-7089");
var (seed, zoneName) = NoLagrangeCandidateZone();
var galaxy = BuildGalaxyWithBoostedPresence(cache, seed, zoneName);
var zone = galaxy.Zones.Single(z => z.Name == zoneName);
Assert.NotSame(galaxy.Entrance, zone);
var items = new ItemManager(cache, new ProvenanceLedger(), Settings(), _ => { });
@ -857,8 +910,7 @@ public sealed class RestoredHullsTests
// Confirms this fixture still has no genuine (non-rosette) Lagrange candidate -- a regression here
// would mean the fixture no longer probes what this test claims to probe.
var planetOrbits = pack.Planets.Select(p => cache.Get(cache.Get(p).Orbit)).Where(o => o.Parent.IsSet()).ToArray();
var hasGenuineCandidate = planetOrbits.Any(o => planetOrbits.Count(c => c.Parent.Key.Equals(o.Parent.Key) && abs(c.Distance - o.Distance) < .1f) == 1);
var hasGenuineCandidate = HasGenuineLagrangeCandidate(ParentedPlanetOrbits(cache, pack));
Assert.False(hasGenuineCandidate, "the entrance-adjacent fixture zone now has a genuine Lagrange candidate; it no longer tests the no-Lagrange leak path.");
var stationCount = pack.Entities.OfType<OrbitalEntityPack>().Count(e => (cache.Get(e.Hull.Data) as HullData)?.HullType == HullType.Station);