Cut 12.2 Soul fix batch: half-open clamp, split assembly, real rolls

F1 (correctness): LateralDraw clamped the drawn lateral to the closed
[Lo, Hi], not the spec's half-open [Lo, Hi). Soul enumerated all 2^24
NextFloat outputs against TurningArmourIntoTheShotTakesItOnTheArmour's own
geometry and found 3 that draw exactly Hi, which Lane's own half-open filter
then admits no cell for -- a hit that passed its roll landing nowhere (R3).
Fixed the clamp; Lane's silent int2.zero fallback on an empty lane is now a
thrown InvalidOperationException, since an empty lane is provably impossible
after the fix. Committed Soul's edge probe as
LateralDrawIsHalfOpenAtTheShadowsTopEdge.

F6/F8: HitProbability, Inspect and Fire each assembled bearing -> Silhouette
-> PSpread (or recomputed range) in their own copy; a shooter-frame bearing
bug in HitProbability's copy survived while the identical bug in Inspect's
copy was caught. Collapsed into one Forecast function and one PFire(out range)
overload; both callers, and Fire, read the one computation.

F2: FireControlCut12Tests' zone names carried a Guid, breaking every other
cut's fixed-seed convention (FireControlCut6Tests.cs:62-63) and reseeding the
die every run -- the actual source of the flake in
TurningArmourIntoTheShotTakesItOnTheArmour. Fixed to a fixed zone name.

F3/F4/F5/F7: added a two-prong hull fixture (LateralDraw's walk past the first
interval, and a wrong-sigma placement, were unreachable when every fixture
projects to one interval), a real-roll empirical test for CommitProbability
(the old one called the pure function twice and compared it to itself),
enough Penetration in TurningAfterCommitChangesNothing for ApplyHit to
actually read the bearing, and a 2x2 item fixture for ResolveAimPoint's
average (every "Marker" elsewhere is 1x1, so sum/length and sum*length agree).

F9: Lane's own comment claimed no allocation while its sort used
Comparer<T>.Create over a closure; LaneCell now carries its own precomputed
projection and Lane sorts with a stateless singleton comparer. Corrected an
overclaiming comment in FireAuthorityTests (SigmaFloor makes the aimed-lane
draw ~68% per shot, not deterministic; the fixture's fixed zone name is what
actually makes it reproduce).

Cost: Silhouette takes an optional caller-rented Interval[] buffer; the
forecast path (HitProbability/Inspect, via Forecast) rents from
ArrayPool<Interval>.Shared and returns it before returning, since neither
reads sil.Intervals after the call. Commit/CommitProbability still get an
owned array, since LateralDraw needs it alive past the call. Measured on
LonginusX (66 cells, Release): unaimed 672 B -> 184 B/call (1512-1637ns before,
1482-1560ns after); aimed 1160 B -> 672 B/call (2123-2140ns before,
2094-2162ns after) -- the remaining ~488B/call gap between aimed and unaimed
is ResolveAimPoint's own CellsOf allocation (a List<int2>+ToArray per call),
not in this batch's scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-24 23:08:19 +02:00
commit 8bd25f6faa
4 changed files with 426 additions and 63 deletions

View file

@ -409,10 +409,19 @@ public sealed class FireControlCut9Tests : IDisposable
var settings = TestSettings();
var checkedConfigurations = 0;
var sawPartialSpread = false;
// F6 (Soul's fix batch, 2026-09-24): a shooter at float3.zero with both entities at Direction's
// default (0,1) let a mutant that reads the SHOOTER's facing instead of the target's (Bearing(source,
// ...) instead of Bearing(target, ...)) survive -- the two facings coincided, so the substitution was
// invisible. An off-origin shooter and a target facing with |fx| > |fy|, distinct from the shooter's
// own (unused) default facing, make that substitution produce a different, wrong bearing.
var origin = float3(37, 0, -11);
foreach (var precision in new[] { .3f, 1.19f, 5f })
{
// 6 cells wide at cell size 1 subtends ~3.4 degrees at 100 units, inside an 8-degree cone.
var e = BuildKernelEngagement(settings, SolidShape(6, 12), precision, spread: 8);
e.Shooter.Position = origin;
e.Target.Position = origin + float3(0, 0, 100);
e.Target.Direction = normalize(float2(.8f, .6f));
foreach (var info in new[] { .2f, .5f, 1f })
{
@ -435,9 +444,9 @@ public sealed class FireControlCut9Tests : IDisposable
checkedConfigurations++;
}
e.Target.Position = float3(0, 0, 5000);
e.Target.Position = origin + float3(0, 0, 5000);
Closed("out of range", d => d.InRange);
e.Target.Position = float3(0, 0, -100);
e.Target.Position = origin + float3(0, 0, -100);
Closed("behind the mount", d => d.InArc);
// A shooter far from the origin: at float3.zero `target - source` and `target + source` are the
@ -448,8 +457,8 @@ public sealed class FireControlCut9Tests : IDisposable
Assert.Equal(500f, far.Range, 3);
Assert.True(far.InRange && FireControl.HitProbability(e.Weapon, e.Shooter, e.Target) > 0f, "shooter far from the origin");
checkedConfigurations++;
e.Shooter.Position = float3.zero;
e.Target.Position = float3(0, 0, 100);
e.Shooter.Position = origin;
e.Target.Position = origin + float3(0, 0, 100);
e.Shooter.VisibleEntities.Remove(e.Target);
Closed("not visible", d => d.Visible);