refactor: clean up debug logging in pathfinder and pathfind command

Remove verbose per-node insertion tracking from A*. Keep essential
logging: start, goal reached, partial/failed results. Clean up
pathfind command with exception handling and cleaner output.

Made-with: Cursor
This commit is contained in:
BruceChen 2026-04-11 02:13:48 +08:00
parent e9b19d3cbb
commit deb1bc47cc
2 changed files with 23 additions and 59 deletions

View file

@ -96,9 +96,6 @@ namespace MinecraftClient.Pathing.Core
current.IsClosed = true;
nodesExplored++;
if (nodesExplored <= 10)
DebugLog?.Invoke($"[A*] Expand #{nodesExplored}: ({current.X},{current.Y},{current.Z}) F={current.FCost:F2} G={current.GCost:F2} H={current.HCost:F2}, openSet={openSet.Count}");
if (goal.IsInGoal(current.X, current.Y, current.Z))
{
DebugLog?.Invoke($"[A*] Goal reached! {nodesExplored} nodes, {sw.ElapsedMilliseconds}ms");
@ -111,15 +108,6 @@ namespace MinecraftClient.Pathing.Core
moveResult.Cost = 0;
move.Calculate(ctx, current.X, current.Y, current.Z, ref moveResult);
if (nodesExplored <= 2)
{
if (moveResult.IsImpossible)
DebugLog?.Invoke($"[A*] move {move.Type}({move.XOffset},{move.ZOffset}) from ({current.X},{current.Y},{current.Z}): IMPOSSIBLE");
else
DebugLog?.Invoke($"[A*] move {move.Type}({move.XOffset},{move.ZOffset}) from ({current.X},{current.Y},{current.Z}): " +
$"-> ({moveResult.DestX},{moveResult.DestY},{moveResult.DestZ}) cost={moveResult.Cost:F2}");
}
if (moveResult.IsImpossible)
continue;
@ -139,8 +127,6 @@ namespace MinecraftClient.Pathing.Core
if (nodeMap.TryGetValue(packed, out var neighbor))
{
if (nodesExplored <= 2)
DebugLog?.Invoke($"[A*] EXISTS ({nx},{ny},{nz}) pack={packed} actual=({neighbor.X},{neighbor.Y},{neighbor.Z}) closed={neighbor.IsClosed} tentG={tentativeG:F2} existG={neighbor.GCost:F2}");
if (neighbor.IsClosed)
continue;
if (tentativeG >= neighbor.GCost)
@ -154,8 +140,6 @@ namespace MinecraftClient.Pathing.Core
}
else
{
if (nodesExplored <= 2)
DebugLog?.Invoke($"[A*] NEW ({nx},{ny},{nz}) pack={packed} G={tentativeG:F2} H={goal.Heuristic(nx, ny, nz):F2}");
neighbor = new PathNode(nx, ny, nz)
{
GCost = tentativeG,
@ -171,8 +155,6 @@ namespace MinecraftClient.Pathing.Core
double partialScore = neighbor.HCost + neighbor.GCost * 0.5;
if (partialScore < bestPartialScore)
{
if (nodesExplored <= 3)
DebugLog?.Invoke($"[A*] partial improved: ({neighbor.X},{neighbor.Y},{neighbor.Z}) score={partialScore:F2} < {bestPartialScore:F2}");
bestPartialScore = partialScore;
bestPartialNode = neighbor;
}