fix(O-T7): actually delete SplitFormulaDivergenceTest (drop workaround)
The previous T7 commit (dc722e7) and the housekeeping commit (3e6f6ec) together left the file in the tree with a <Compile Remove> guard in the csproj. Per spec O-T7 and CLAUDE.md "no workarounds without approval" the file was supposed to be git-rm'd outright. This commit: - git rm tests/AcDream.Core.Tests/Terrain/SplitFormulaDivergenceTest.cs (the one-time N.5b data-collection sweep — job done at Phase N.5b ship) - Removes the now-unneeded <Compile Remove> guard from tests/AcDream.Core.Tests/AcDream.Core.Tests.csproj Build green; tests green (1146 + 8 pre-existing failures baseline maintained). Spec: docs/superpowers/specs/2026-05-21-phase-o-dat-path-unification-design.md Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3e6f6ec858
commit
57ee19968c
2 changed files with 0 additions and 176 deletions
|
|
@ -32,12 +32,4 @@
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<!-- Phase O (2026-05-21): N.5b data-collection test referenced WorldBuilder.Shared
|
|
||||||
types directly. After Phase O dropped the WorldBuilder.Shared project reference,
|
|
||||||
this one-time data-collection test no longer compiles. Excluding from build;
|
|
||||||
the sweep data it produced already informed the N.5b Path-C decision. -->
|
|
||||||
<Compile Remove="Terrain\SplitFormulaDivergenceTest.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -1,168 +0,0 @@
|
||||||
using AcDream.Core.Terrain;
|
|
||||||
using Xunit;
|
|
||||||
using Xunit.Abstractions;
|
|
||||||
using WbTerrainUtils = WorldBuilder.Shared.Modules.Landscape.Lib.TerrainUtils;
|
|
||||||
using WbCellSplitDirection = WorldBuilder.Shared.Modules.Landscape.Models.CellSplitDirection;
|
|
||||||
|
|
||||||
namespace AcDream.Core.Tests.Terrain;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Phase N.5b data-collection test: quantifies how often WB's
|
|
||||||
/// <c>TerrainUtils.CalculateSplitDirection</c> disagrees with acdream's
|
|
||||||
/// <c>TerrainBlending.CalculateSplitDirection</c> (which retail uses
|
|
||||||
/// per <c>CLandBlockStruct::ConstructPolygons</c> at retail address
|
|
||||||
/// <c>00531d10</c>; named-retail decomp lines 316042-316144 contain
|
|
||||||
/// the exact constants <c>0x0CCAC033 / 0x6C1AC587 / 0x421BE3BD /
|
|
||||||
/// 0x519B8F25</c>).
|
|
||||||
///
|
|
||||||
/// Sweeps every (lbX, lbY, cellX, cellY) tuple in the world map
|
|
||||||
/// (255 x 255 landblocks x 64 cells = ~4.16M cells) and reports the
|
|
||||||
/// disagreement rate, per-landblock worst case, and a few named
|
|
||||||
/// representative landblocks. The number drives the Path A/B/C
|
|
||||||
/// decision in the N.5b brainstorm:
|
|
||||||
/// - Low disagreement <5% : Path A's risk is bounded
|
|
||||||
/// - Medium 5-20% : Path B (fork-patch WB) preferred
|
|
||||||
/// - High >20% : Path B/C strongly preferred
|
|
||||||
/// </summary>
|
|
||||||
public class SplitFormulaDivergenceTest
|
|
||||||
{
|
|
||||||
private readonly ITestOutputHelper _out;
|
|
||||||
|
|
||||||
public SplitFormulaDivergenceTest(ITestOutputHelper output) => _out = output;
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void Quantify_RetailVsWb_DivergenceRate()
|
|
||||||
{
|
|
||||||
// Two divergence flavors are tracked simultaneously:
|
|
||||||
//
|
|
||||||
// rawDisagree : retail-enum != wb-enum (pure formula output)
|
|
||||||
// diagonalDisagree: retail-actually-paints-diagonal !=
|
|
||||||
// wb-actually-paints-diagonal (effective geometry)
|
|
||||||
//
|
|
||||||
// The two differ because the enums are SEMANTICALLY INVERTED:
|
|
||||||
// - acdream `CellSplitDirection.SWtoNE` -> renderer paints BL->TR
|
|
||||||
// (SW-NE diagonal). Matches retail per AC2D Landblocks.cpp:400-412
|
|
||||||
// where FSplitNESW=true wraps a TRIANGLE_FAN [BL, BR, TR, TL] =
|
|
||||||
// diagonal BL-TR.
|
|
||||||
// - WB `CellSplitDirection.SWtoNE` -> WB's TerrainGeometryGenerator
|
|
||||||
// emits triangles {BL,TL,BR}+{BR,TL,TR} which share the BR-TL
|
|
||||||
// diagonal (SE-NW direction). The enum name is misleading; what
|
|
||||||
// WB actually draws is the OTHER diagonal.
|
|
||||||
//
|
|
||||||
// So the question "would WB's pipeline produce the same diagonals as
|
|
||||||
// retail's pipeline?" is answered by `diagonalDisagree`, not
|
|
||||||
// `rawDisagree`. If diagonalDisagree is near 0%, WB's formula +
|
|
||||||
// renderer happen to compose into a correct pipeline (despite the
|
|
||||||
// confusing labels). If diagonalDisagree is ~50%, the two pipelines
|
|
||||||
// truly diverge and Path A would visibly break terrain on every
|
|
||||||
// landblock.
|
|
||||||
|
|
||||||
const int lbCount = 255;
|
|
||||||
const int cellsPerSide = 8;
|
|
||||||
long totalCells = 0;
|
|
||||||
long rawDisagree = 0;
|
|
||||||
long diagonalDisagree = 0;
|
|
||||||
|
|
||||||
int worstLbDiag = 0;
|
|
||||||
uint worstLbX = 0, worstLbY = 0;
|
|
||||||
int bestLbDiag = 64;
|
|
||||||
uint bestLbX = 0, bestLbY = 0;
|
|
||||||
|
|
||||||
for (uint lbX = 0; lbX < lbCount; lbX++)
|
|
||||||
for (uint lbY = 0; lbY < lbCount; lbY++)
|
|
||||||
{
|
|
||||||
int lbDiagDisagree = 0;
|
|
||||||
for (uint cx = 0; cx < cellsPerSide; cx++)
|
|
||||||
for (uint cy = 0; cy < cellsPerSide; cy++)
|
|
||||||
{
|
|
||||||
bool retailEnumSWtoNE =
|
|
||||||
TerrainBlending.CalculateSplitDirection(lbX, cx, lbY, cy)
|
|
||||||
== CellSplitDirection.SWtoNE;
|
|
||||||
bool wbEnumSWtoNE =
|
|
||||||
WbTerrainUtils.CalculateSplitDirection(lbX, cx, lbY, cy)
|
|
||||||
== WbCellSplitDirection.SWtoNE;
|
|
||||||
|
|
||||||
// What diagonal each pipeline actually paints.
|
|
||||||
bool retailPaintsBLtoTR = retailEnumSWtoNE; // direct mapping
|
|
||||||
bool wbPaintsBLtoTR = !wbEnumSWtoNE; // inverted mapping
|
|
||||||
|
|
||||||
totalCells++;
|
|
||||||
if (retailEnumSWtoNE != wbEnumSWtoNE) rawDisagree++;
|
|
||||||
if (retailPaintsBLtoTR != wbPaintsBLtoTR)
|
|
||||||
{
|
|
||||||
diagonalDisagree++;
|
|
||||||
lbDiagDisagree++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lbDiagDisagree > worstLbDiag)
|
|
||||||
{
|
|
||||||
worstLbDiag = lbDiagDisagree;
|
|
||||||
worstLbX = lbX;
|
|
||||||
worstLbY = lbY;
|
|
||||||
}
|
|
||||||
if (lbDiagDisagree < bestLbDiag)
|
|
||||||
{
|
|
||||||
bestLbDiag = lbDiagDisagree;
|
|
||||||
bestLbX = lbX;
|
|
||||||
bestLbY = lbY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double rawPct = 100.0 * rawDisagree / totalCells;
|
|
||||||
double diagPct = 100.0 * diagonalDisagree / totalCells;
|
|
||||||
|
|
||||||
_out.WriteLine($"=== Phase N.5b — terrain split formula divergence ===");
|
|
||||||
_out.WriteLine($"Sweep: {lbCount}x{lbCount} landblocks, {cellsPerSide*cellsPerSide} cells each");
|
|
||||||
_out.WriteLine($"Total cells: {totalCells:N0}");
|
|
||||||
_out.WriteLine("");
|
|
||||||
_out.WriteLine($"RAW enum-output disagreement : {rawDisagree,12:N0} ({rawPct:F2}%)");
|
|
||||||
_out.WriteLine($" (compares retail-enum vs wb-enum, NOT what each system actually draws)");
|
|
||||||
_out.WriteLine("");
|
|
||||||
_out.WriteLine($"DIAGONAL-actually-painted disagreement: {diagonalDisagree,12:N0} ({diagPct:F2}%)");
|
|
||||||
_out.WriteLine($" (compares retail-paints-BL->TR vs wb-paints-BL->TR; this is the");
|
|
||||||
_out.WriteLine($" number that determines whether Path A visibly works)");
|
|
||||||
_out.WriteLine("");
|
|
||||||
_out.WriteLine($"Worst landblock (diagonal): 0x{worstLbX:X2}{worstLbY:X2} disagrees on {worstLbDiag}/64 cells ({100.0*worstLbDiag/64:F1}%)");
|
|
||||||
_out.WriteLine($"Best landblock (diagonal): 0x{bestLbX:X2}{bestLbY:X2} disagrees on {bestLbDiag}/64 cells ({100.0*bestLbDiag/64:F1}%)");
|
|
||||||
|
|
||||||
// Specific landblocks of interest (per N.5b handoff representative set).
|
|
||||||
var representative = new (string name, uint lbX, uint lbY)[]
|
|
||||||
{
|
|
||||||
("Holtburg town", 0xA9, 0xB0),
|
|
||||||
("Holtburg LB 0xA9B1", 0xA9, 0xB1),
|
|
||||||
("Foundry-area", 0x80, 0x80),
|
|
||||||
("Cragstone", 0xCB, 0x99),
|
|
||||||
("Direlands sample", 0xC0, 0x40),
|
|
||||||
("MapOrigin 0x0000", 0x00, 0x00),
|
|
||||||
("MapCorner 0xFEFE", 0xFE, 0xFE),
|
|
||||||
("Mid-map 0x7F7F", 0x7F, 0x7F),
|
|
||||||
("Subway dungeon LB 0x0185 outdoor part", 0x01, 0x85),
|
|
||||||
};
|
|
||||||
|
|
||||||
_out.WriteLine("");
|
|
||||||
_out.WriteLine("Representative landblocks (diagonal-actually-painted disagreement):");
|
|
||||||
foreach (var (name, lbX, lbY) in representative)
|
|
||||||
{
|
|
||||||
int dis = 0;
|
|
||||||
for (uint cx = 0; cx < 8; cx++)
|
|
||||||
for (uint cy = 0; cy < 8; cy++)
|
|
||||||
{
|
|
||||||
bool retailEnum = TerrainBlending.CalculateSplitDirection(lbX, cx, lbY, cy) == CellSplitDirection.SWtoNE;
|
|
||||||
bool wbEnum = WbTerrainUtils.CalculateSplitDirection(lbX, cx, lbY, cy) == WbCellSplitDirection.SWtoNE;
|
|
||||||
bool retailPaintsBLtoTR = retailEnum;
|
|
||||||
bool wbPaintsBLtoTR = !wbEnum;
|
|
||||||
if (retailPaintsBLtoTR != wbPaintsBLtoTR) dis++;
|
|
||||||
}
|
|
||||||
_out.WriteLine($" 0x{lbX:X2}{lbY:X2} {dis,2}/64 cells disagree ({100.0*dis/64:F1}%) {name}");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Soft-floor on the DIAGONAL comparison: if diagPct is near 0% the
|
|
||||||
// formulas are equivalent post-inversion (Path A would just work
|
|
||||||
// visually; the only "bug" is enum naming). If diagPct is well
|
|
||||||
// above 0%, Path A truly breaks terrain.
|
|
||||||
// Soft-ceiling: an inversion of inversion shouldn't push past ~70%.
|
|
||||||
Assert.True(diagPct >= 0 && diagPct <= 100,
|
|
||||||
$"Sanity: diagonal disagreement out of range (rate={diagPct:F2}%)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue