Cut 12.3 fix batch: F2 lane spacing by shadow width, F3 penetration boundary fixture
Operator ruling (2026-09-25): overlapping spread lanes should diffuse sideways rather than double up. FireControl.Apply now spaces lanes by the shadow width a cell casts at the committed bearing (Extent's own h, doubled) instead of by one cell -- 1 at axis-aligned bearings (unchanged), up to sqrt(2) at 45 degrees. Reuses Extent, the one function that already owns h for Silhouette and Lane, rather than re-deriving it a second way. F3: PenetrationExcludesACellExactlyAtItsOwnBoundary's 1e6-durability marker absorbed the whole shot before the walk could reach the boundary cell, so the test could not fail under the `>=`-to-`>` mutant. The marker now carries 10 durability, leaving a remainder that would visibly damage the boundary cell if the walk incorrectly included it. Adds PenetrationExcludesCellsBeyondANonIntegerDepth, pinning the ordinary "< penetration" comparison at a depth (1.5) that isn't an exact-integer boundary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f2c94c29be
commit
b82b7eab21
2 changed files with 54 additions and 10 deletions
|
|
@ -589,13 +589,22 @@ public static class FireControl
|
|||
// once per Unity effect).
|
||||
// Cut 12.3 (docs/fire-control-cut.md, "How a direct hit travels"): replaces Entity.ApplyHit's 0.5-step
|
||||
// march and Entity.DamageSchematic's even split over the whole hit shape. Spread is width (Q12-2 = A):
|
||||
// 2n+1 parallel lanes, one cell apart along the committed bearing's own lateral axis, sharing the shot's
|
||||
// damage evenly over whichever lanes actually meet metal -- the centre lane, at the committed Lateral,
|
||||
// always does (Commit already proved it, R3). Each lane is Lane's own contiguous cell run from its own
|
||||
// facing cell, clipped to the penetration depth (a cell is reached when entry - impact.entry < penetration;
|
||||
// the impact cell is always reached, replacing the deleted `> .5f` threshold at zero cost). Whatever a
|
||||
// lane does not spend -- penetration exhausted, a gap, or the far side -- goes to the hull where the lane
|
||||
// ends (Q12-3 = A), summed across every lane into one DamageHull call.
|
||||
// 2n+1 parallel lanes, sharing the shot's damage evenly over whichever lanes actually meet metal -- the
|
||||
// centre lane, at the committed Lateral, always does (Commit already proved it, R3). Each lane is Lane's
|
||||
// own contiguous cell run from its own facing cell, clipped to the penetration depth (a cell is reached
|
||||
// when entry - impact.entry < penetration; the impact cell is always reached, replacing the deleted
|
||||
// `> .5f` threshold at zero cost). Whatever a lane does not spend -- penetration exhausted, a gap, or the
|
||||
// far side -- goes to the hull where the lane ends (Q12-3 = A), summed across every lane into one
|
||||
// DamageHull call.
|
||||
// F2 fix batch (Soul, 2026-09-25; operator: "I would prefer if the overlapping damage cells were diffused
|
||||
// sideways to thicken the line rather than doubling up"): lanes are spaced by the shadow width a cell
|
||||
// casts at this bearing -- Extent's own h, doubled -- not by one cell. At axis-aligned bearings that width
|
||||
// is exactly 1 (today's spacing, unchanged); at 45 degrees it is sqrt(2). Reusing Extent (the one function
|
||||
// that owns h, Silhouette's shadow and Lane's own admission test) instead of re-deriving |bx|+|by| a
|
||||
// second way is the same discipline Cut 12.2's own fix batch already applied to Lane -- two derivations of
|
||||
// one geometric quantity is exactly how that cut's crash happened. Because each cell's admitted lateral
|
||||
// interval is exactly this width wide and half-open, lanes this far apart can never both admit the same
|
||||
// cell: no cell is struck twice, and the footprint widens at angles instead of doubling up.
|
||||
private static void Apply(PendingShot shot)
|
||||
{
|
||||
if (!shot.Outcome.Hit) return;
|
||||
|
|
@ -622,6 +631,9 @@ public static class FireControl
|
|||
var bearing = shot.Outcome.Bearing;
|
||||
var n = (int) floor(shot.DamageSpread + .5f); // today's rounding, Entity.cs:389 before this cut
|
||||
var laneCount = 2 * n + 1;
|
||||
// F2: the shadow width at this bearing, from Extent's own h (the cell argument does not affect h).
|
||||
var shadowExtent = Extent(float2.zero, Lateral(bearing));
|
||||
var laneSpacing = shadowExtent.Hi - shadowExtent.Lo;
|
||||
|
||||
var buffers = new LaneCell[laneCount][];
|
||||
var walked = new int[laneCount];
|
||||
|
|
@ -629,7 +641,7 @@ public static class FireControl
|
|||
for (var li = 0; li < laneCount; li++)
|
||||
{
|
||||
buffers[li] = ArrayPool<LaneCell>.Shared.Rent(hullData.Shape.Coordinates.Length);
|
||||
walked[li] = Lane(hullData, bearing, shot.Outcome.Lateral + (li - n), buffers[li]);
|
||||
walked[li] = Lane(hullData, bearing, shot.Outcome.Lateral + (li - n) * laneSpacing, buffers[li]);
|
||||
if (walked[li] > 0) metalLanes++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -560,13 +560,18 @@ public sealed class FireControlCut123Tests : IDisposable
|
|||
// exactly on a cell's own entry difference. Penetration 2 exactly against a 3-cell column (entries ~0,1,2):
|
||||
// the third cell sits exactly AT the boundary and must be excluded ("< penetration" is reached; the mutant
|
||||
// would let it through).
|
||||
// F3 fix batch (Soul, 2026-09-25): the marker at (1,1) used to carry 1e6 durability, so it alone absorbed
|
||||
// the whole 30 damage before the walk could ever reach (1,2) -- the boundary cell took 0 whether the `>`
|
||||
// mutant let it through or not, so the test could not fail. The marker now carries only 10, leaving a
|
||||
// remainder large enough that (1,2) would visibly lose armour if the walk reached it.
|
||||
[Fact]
|
||||
public void PenetrationExcludesACellExactlyAtItsOwnBoundary()
|
||||
{
|
||||
var e = Build(TestSettings(), SolidShape(3, 3), precision: 1f, penetration: 2f,
|
||||
markers: new[] { (new int2(1, 1), 1000000f) });
|
||||
markers: new[] { (new int2(1, 1), 10f) });
|
||||
foreach (var c in e.HullData.Shape.Coordinates) { e.Target.Armor[c.x, c.y] = 0f; e.Target.MaxArmor[c.x, c.y] = 0f; }
|
||||
e.Target.Armor[1, 2] = 50f; e.Target.MaxArmor[1, 2] = 50f; // exactly at entry-diff 2 == penetration
|
||||
var marker = e.Markers[0];
|
||||
|
||||
ShotOutcome outcome = null;
|
||||
for (var attempt = 0; attempt < 200 && (outcome == null || !outcome.Hit || outcome.Cell.x != 1); attempt++)
|
||||
|
|
@ -575,6 +580,33 @@ public sealed class FireControlCut123Tests : IDisposable
|
|||
Assert.True(outcome.Hit && outcome.Cell.x == 1, "fixture: needed a hit on the centre column within the attempt budget");
|
||||
Assert.Equal(new int2(1, 0), outcome.Cell);
|
||||
|
||||
Assert.Equal(50f, e.Target.Armor[1, 2]); // exactly at entry-diff 2 -- excluded, not "< penetration"
|
||||
Assert.Equal(0f, marker.EquippableItem.Durability); // fixture: the marker's own 10 is fully spent, 20 left over
|
||||
Assert.Equal(50f, e.Target.Armor[1, 2]); // exactly at entry-diff 2 -- excluded, not "< penetration" -- the
|
||||
// remaining 20 would otherwise have visibly damaged it
|
||||
}
|
||||
|
||||
// F3: a non-integer penetration depth. Entries down an axis-aligned column are exact integers, so a
|
||||
// fractional penetration is never itself a boundary -- this pins the ordinary "< penetration" comparison at
|
||||
// a depth that isn't a round number, independent of the exact-integer boundary case above.
|
||||
[Fact]
|
||||
public void PenetrationExcludesCellsBeyondANonIntegerDepth()
|
||||
{
|
||||
var e = Build(TestSettings(), SolidShape(1, 4), precision: 1f, penetration: 1.5f);
|
||||
e.Target.Armor[0, 0] = 5f; e.Target.MaxArmor[0, 0] = 5f; // entry-diff 0: always reached
|
||||
e.Target.Armor[0, 1] = 5f; e.Target.MaxArmor[0, 1] = 5f; // entry-diff 1: within 1.5, reached
|
||||
e.Target.Armor[0, 2] = 50f; e.Target.MaxArmor[0, 2] = 50f; // entry-diff 2: beyond 1.5, excluded
|
||||
e.Target.Armor[0, 3] = 50f; e.Target.MaxArmor[0, 3] = 50f; // entry-diff 3: beyond 1.5, excluded
|
||||
e.Target.GearOccupancy[0, 0].EquippableItem.Durability = 0f; // remove the bystander Gun's own 1 durability
|
||||
|
||||
var hullBefore = e.Target.Hull.Durability;
|
||||
var outcome = FireUntilHit(e, damageOverride: 30f);
|
||||
Assert.NotNull(outcome);
|
||||
Assert.True(outcome.Hit);
|
||||
|
||||
Assert.Equal(0f, e.Target.Armor[0, 0]); // 5 consumed
|
||||
Assert.Equal(0f, e.Target.Armor[0, 1]); // 5 consumed
|
||||
Assert.Equal(50f, e.Target.Armor[0, 2]); // untouched -- beyond the 1.5 depth
|
||||
Assert.Equal(50f, e.Target.Armor[0, 3]); // untouched -- beyond the 1.5 depth
|
||||
Assert.Equal(hullBefore - 20f, e.Target.Hull.Durability, 2); // 30 - 5 - 5 left over for the hull
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue