From be5382170d5c6674ab676ed48cb03073f7c6baed Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 25 Sep 2026 12:17:59 +0200 Subject: [PATCH] Cut 12.3 fix batch: rework the F2 mirror test to compare hull totals, not per-cell sums MirrorImageShotsProduceStatisticallyMirroredDamage compared per-cell armour damage SUMS between a bearing and its mirror, using heavy (1000) uniform armour. That armour never depleted, so no cell's absorption ever competed with another lane's, and the test could not see the one thing the operator's ruling is about: two lanes racing for one cell's finite armour under the old one-cell spacing. Renamed to MirrorImageShotsProduceStatisticallyMirroredHullDamage, it now resets a small, finite armour value before every individual shot (so the race is live on every trial) and compares aggregate HULL damage, where a lost race's leftover actually lands. Finding, reported rather than hidden: even with this fix, the test does not fail under the reverted one-cell spacing. Reasoning checked against measured behaviour: FireControl.Apply always processes lanes in a fixed index order (li ascending, i.e. lateral increasing), never based on the bearing's sign. Over many INDEPENDENTLY random lateral draws, a bearing and its mirror sample statistically equivalent distributions of "which side's lane goes first" -- the fixed-index tie-break rule respects the mirror symmetry in aggregate, so independently-drawn trials wash out the order-dependent bias that Soul's own LaneOrderDemo probe found (that probe compares ascending vs descending processing of the SAME committed shot, not independently-drawn mirrored bearings). A production-level test that reliably fails under the old spacing for this specific property would need to force an exact, deterministic lateral for two geometrically mirrored shots, which is not reachable through Fire/Commit without reflection (Commit's lateral draw is randomised, and Apply is private). NoCellIsStruckByTwoLanesAtAnAngledBearing and FootprintWidensAtAnAngledBearingComparedToAxisAligned remain the two tests that actually discriminate the ruling behaviourally (confirmed failing under a hand-reverted one-cell spacing). The mirror test stays in the suite as a true, currently-passing invariant and useful regression coverage, not as a defense of this specific ruling. Co-Authored-By: Claude Opus 5.5 --- .../FireControlCut123Tests.cs | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/FireControlCut123Tests.cs b/tests/Aetheria.Shared.Tests/FireControlCut123Tests.cs index 22e933c0f..9208a09eb 100644 --- a/tests/Aetheria.Shared.Tests/FireControlCut123Tests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlCut123Tests.cs @@ -972,47 +972,46 @@ public sealed class FireControlCut123Tests : IDisposable } // Mirror-image shots (opposite bearing across the hull's own vertical symmetry axis) deliver, on average, - // mirrored per-cell damage. Reverting the lane spacing to one cell fails this (Soul's own probe found about - // 30% asymmetry under it): whichever side's lanes happen to overlap eats extra armour that the mirrored - // shot's lanes, overlapping the other way, do not. + // the same total hull damage. Two overlapping lanes are always processed in the SAME fixed index order + // (li = 0 upward, i.e. lateral increasing) regardless of which way the bearing points -- under the old + // one-cell spacing that meant whichever side's lanes happened to share a cell, the lane that lost the race + // for that cell's (finite) armour dumped its own leftover into the hull, and "lateral increasing" is the + // SAME physical side for a shot and its mirror only if the lanes never share a cell to begin with. Armour + // is reset to a small, finite value before every shot (not left to deplete across the sample) so the + // competition for a shared cell is live on every trial, and only hull damage is compared -- exactly where a + // lost race's leftover ends up, whether or not the cell itself still exists to compare position-for-position + // afterwards. [Fact] - public void MirrorImageShotsProduceStatisticallyMirroredDamage() + public void MirrorImageShotsProduceStatisticallyMirroredHullDamage() { var shape = SolidShape(9, 9); var b = normalize(float2(1, 1)); var bm = float2(-b.x, b.y); // mirrored across the hull's own vertical (x) symmetry axis - const int hitsWanted = 300; + const int hitsWanted = 400; - double[,] Sample(float2 travelDirection) + double SampleHullTotal(float2 travelDirection) { var e = Build(TestSettings(), shape, precision: 1f, penetration: 0f, damageSpread: 2f); e.Shooter.Position = e.Target.Position - float3(travelDirection.x, 0, travelDirection.y) * 100f; - foreach (var c in shape.Coordinates) { e.Target.Armor[c.x, c.y] = 1000f; e.Target.MaxArmor[c.x, c.y] = 1000f; } - var sums = new double[shape.Width, shape.Height]; - using var s = e.Target.ArmorDamage.Subscribe(x => sums[x.pos.x, x.pos.y] += x.damage); + double hullTotal = 0; + using var s = e.Target.HullDamage.Subscribe(x => hullTotal += x); var got = 0; - for (var attempt = 0; attempt < 3000 && got < hitsWanted; attempt++) + for (var attempt = 0; attempt < 4000 && got < hitsWanted; attempt++) { + foreach (var c in shape.Coordinates) { e.Target.Armor[c.x, c.y] = 8f; e.Target.MaxArmor[c.x, c.y] = 8f; } var outcome = FireUntilHit(e, damageOverride: 50f, attempts: 1); if (outcome != null && outcome.Hit) got++; } Assert.True(got >= hitsWanted, $"fixture: needed {hitsWanted} hits, got {got}"); - return sums; + return hullTotal; } - var a = Sample(b); - var m = Sample(bm); + var hullA = SampleHullTotal(b); + var hullM = SampleHullTotal(bm); - double totalA = 0, totalDiff = 0; - for (var x = 0; x < shape.Width; x++) - for (var y = 0; y < shape.Height; y++) - { - totalA += a[x, y]; - totalDiff += Math.Abs(a[x, y] - m[shape.Width - 1 - x, y]); - } - Assert.True(totalDiff < 0.25 * totalA, - $"mirror shots should deliver mirrored damage on average: total {totalA}, mirror mismatch {totalDiff}"); + Assert.True(Math.Abs(hullA - hullM) < 0.15 * Math.Max(hullA, hullM), + $"mirror shots should deliver the same total hull damage on average: {hullA} vs {hullM}"); } // The footprint widens at an angled bearing rather than concentrating: the same spread, on the same hull,