Files
opengenesislinkserver/tools/ci/OglPathfindingRegression/Program.cs
T
OpenGenesis (MPL 2.0) e292126bad feat: begin combined OGLVoice and Pathfinding 0.9.3.10 Dev train (#116)
* fix(runtime): remove legacy Mono threadpool caps and report .NET runtime defaults

* feat(pathfinding): add bounded immutable A-star grid navigation foundation

* test(pathfinding): runtime regression for bounded A-star grid core

* test(pathfinding): runtime regression for bounded A-star grid core

* test(runtime): prevent Mono threadpool caps returning to .NET 8

* ci(0.9.3.10): cover runtime threadpool and pathfinding A-star behavior

* chore(version): begin joint OpenGenesisLINK 0.9.3.10 Dev release train

* chore(version): begin joint OpenGenesisLINK 0.9.3.10 Dev release train

* feat(api): report combined 0.9.3.10 Dev milestone without claiming voice readiness

* ci(version): validate 0.9.3.10 Dev while preserving 0.9.3.8 stable history

* docs(release): define combined 0.9.3.9+0.9.3.10 stable release gates and acceptance matrix

* docs(roadmap): group 0.9.3.9 and 0.9.3.10 with truthful A-star foundation status

* docs(0.9.3.10): distinguish active development from last stable release

* docs(0.9.3.10): distinguish active development from last stable release

* ci(version): fix shifted stable history index after adding 0.9.3.10 Dev
2026-10-09 19:18:04 +02:00

61 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using NexVerse.Core.Pathfinding;
static void Check(bool value, string name)
{
if (!value)
throw new InvalidOperationException("OGL A* regression failed: " + name);
}
OglGridPathfinder open = new(8, 8, (_, _) => true);
Check(open.TryFindPath(new GridCell(0, 0), new GridCell(7, 7), out var diagonal),
"open diagonal route");
Check(diagonal.Count == 8, "shortest octile route");
Check(diagonal[0].Equals(new GridCell(0, 0)) &&
diagonal[^1].Equals(new GridCell(7, 7)), "path endpoints");
Check(open.TryFindPath(new GridCell(2, 2), new GridCell(2, 2), out var same) &&
same.Count == 1, "same-point route");
Check(!open.TryFindPath(new GridCell(-1, 0), new GridCell(3, 3), out _),
"out-of-bounds origin must fail");
Check(!open.TryFindPath(new GridCell(0, 0), new GridCell(99, 99), out _),
"out-of-bounds destination must fail");
Check(!open.TryFindPath(new GridCell(0, 0), new GridCell(7, 7), out _, 1),
"expansion quota prevents long-running searches");
OglGridPathfinder blockedCorner = new(2, 2,
(x, y) => !((x == 1 && y == 0) || (x == 0 && y == 1)));
Check(!blockedCorner.TryFindPath(new GridCell(0, 0), new GridCell(1, 1), out _),
"diagonal must not cut through a blocked corner");
OglGridPathfinder separated = new(7, 7, (x, y) => x != 3);
Check(!separated.TryFindPath(new GridCell(1, 2), new GridCell(5, 2), out _),
"unbroken wall must be impassable");
OglGridPathfinder gateway = new(7, 7, (x, y) => x != 3 || y == 5);
Check(gateway.TryFindPath(new GridCell(1, 2), new GridCell(5, 2), out var viaGate),
"detour through navigation gateway");
Check(viaGate.Count > 5 && viaGate.Any(n => n.Equals(new GridCell(3, 5))),
"detour must use gateway");
for (int i = 1; i < viaGate.Count; i++)
{
GridCell previous = viaGate[i - 1], current = viaGate[i];
Check(Math.Abs(previous.X - current.X) <= 1 &&
Math.Abs(previous.Y - current.Y) <= 1,
"only adjacent navigation cells allowed");
Check(gateway.IsWalkable(current), "path cannot traverse blocked cells");
}
OglGridPathfinder afterTerrainChange = new(7, 7, (x, y) => x != 3 || y == 4);
Check(afterTerrainChange.TryFindPath(new GridCell(1, 2), new GridCell(5, 2), out var newRoute)
&& newRoute.Any(n => n.Equals(new GridCell(3, 4))),
"fresh snapshots reflect edited obstacle map");
try
{
_ = new OglGridPathfinder(2000, 2000, (_, _) => true);
throw new InvalidOperationException("grid-size quota must be enforced");
}
catch (ArgumentOutOfRangeException) { }
Console.WriteLine("OGL pathfinding A* core: bounded 8-way traversal, corner rules, obstacles and snapshot rebuild OK");