@
CI / build-test (push) Failing after 1m8s

Add MrGameEng.AI utility-AI module; format codebase with CSharpier

New MrGameEng.AI module (ResponseCurve, Consideration, UtilityAction,
UtilityAi selector, Blackboard) plus CSharpier formatting applied across
the whole engine. Documents the CSharpier convention in CLAUDE.md.
@
This commit is contained in:
Leonid Pershin
2026-06-12 07:19:10 +03:00
parent 4ae730cafa
commit fd6343bd09
96 changed files with 2066 additions and 589 deletions
@@ -5,9 +5,13 @@ namespace MrGameEng.Pathfinding.Tests;
public class GridPathfinderTests
{
private static List<Point> Path(IPathGrid grid, Point start, Point goal,
private static List<Point> Path(
IPathGrid grid,
Point start,
Point goal,
PathAlgorithm algorithm = PathAlgorithm.AStar,
GridConnectivity connectivity = GridConnectivity.Eight)
GridConnectivity connectivity = GridConnectivity.Eight
)
{
var pathfinder = new GridPathfinder(grid, connectivity);
var path = new List<Point>();
@@ -26,7 +30,10 @@ public class GridPathfinderTests
{
var dx = Math.Abs(path[i].X - path[i - 1].X);
var dy = Math.Abs(path[i].Y - path[i - 1].Y);
Assert.True(dx <= 1 && dy <= 1 && dx + dy > 0, $"non-adjacent step {path[i - 1]} -> {path[i]}");
Assert.True(
dx <= 1 && dy <= 1 && dx + dy > 0,
$"non-adjacent step {path[i - 1]} -> {path[i]}"
);
}
}
}
@@ -37,10 +44,7 @@ public class GridPathfinderTests
[InlineData(PathAlgorithm.BreadthFirst)]
public void FindPath_OpenField_StraightLine(PathAlgorithm algorithm)
{
var grid = new TestGrid(
".....",
".....",
".....");
var grid = new TestGrid(".....", ".....", ".....");
var path = Path(grid, new Point(0, 1), new Point(4, 1), algorithm);
@@ -54,10 +58,7 @@ public class GridPathfinderTests
[InlineData(PathAlgorithm.BreadthFirst)]
public void FindPath_WallsForceDetour(PathAlgorithm algorithm)
{
var grid = new TestGrid(
".....",
"####.",
".....");
var grid = new TestGrid(".....", "####.", ".....");
var path = Path(grid, new Point(0, 0), new Point(0, 2), algorithm);
@@ -68,10 +69,7 @@ public class GridPathfinderTests
[Fact]
public void FindPath_NoRoute_ReturnsFalse()
{
var grid = new TestGrid(
".#.",
".#.",
".#.");
var grid = new TestGrid(".#.", ".#.", ".#.");
var pathfinder = new GridPathfinder(grid);
var path = new List<Point>();
@@ -92,9 +90,7 @@ public class GridPathfinderTests
[Fact]
public void FindPath_DiagonalNeverCutsCorners()
{
var grid = new TestGrid(
".#",
"#.");
var grid = new TestGrid(".#", "#.");
var pathfinder = new GridPathfinder(grid, GridConnectivity.Eight);
var path = new List<Point>();
@@ -105,12 +101,14 @@ public class GridPathfinderTests
[Fact]
public void FindPath_FourConnectivity_NoDiagonalSteps()
{
var grid = new TestGrid(
"...",
"...",
"...");
var grid = new TestGrid("...", "...", "...");
var path = Path(grid, new Point(0, 0), new Point(2, 2), connectivity: GridConnectivity.Four);
var path = Path(
grid,
new Point(0, 0),
new Point(2, 2),
connectivity: GridConnectivity.Four
);
Assert.Equal(5, path.Count); // манхэттен: 4 шага
for (var i = 1; i < path.Count; i++)
@@ -127,10 +125,7 @@ public class GridPathfinderTests
public void FindPath_CostAware_AvoidsExpensiveTerrain(PathAlgorithm algorithm)
{
// Прямой путь через болото (цена 9) дороже обхода по краю.
var grid = new TestGrid(
".....",
".999.",
".....");
var grid = new TestGrid(".....", ".999.", ".....");
var path = Path(grid, new Point(0, 1), new Point(4, 1), algorithm);
@@ -140,10 +135,7 @@ public class GridPathfinderTests
[Fact]
public void FindPath_BreadthFirst_IgnoresCosts()
{
var grid = new TestGrid(
".....",
".999.",
".....");
var grid = new TestGrid(".....", ".999.", ".....");
var path = Path(grid, new Point(0, 1), new Point(4, 1), PathAlgorithm.BreadthFirst);
@@ -153,10 +145,7 @@ public class GridPathfinderTests
[Fact]
public void FindPath_ReusedInstance_GivesCleanResults()
{
var grid = new TestGrid(
".....",
".###.",
".....");
var grid = new TestGrid(".....", ".###.", ".....");
var pathfinder = new GridPathfinder(grid);
var path = new List<Point>();
@@ -170,12 +159,7 @@ public class GridPathfinderTests
[Fact]
public void FindPath_AStarMatchesDijkstraCost()
{
var grid = new TestGrid(
"..3..",
".#3#.",
"..3..",
".###.",
".....");
var grid = new TestGrid("..3..", ".#3#.", "..3..", ".###.", ".....");
var start = new Point(0, 0);
var goal = new Point(4, 4);