Minecraft-Console-Client/MinecraftClient/Pathing/Goals/GoalBlock.cs
BruceChen 1abab20f17 feat: add Phase 1 core pathfinding architecture
Implements the new Baritone-inspired A* pathfinding system:
- Core types: PathNode, PathResult, MoveResult, MoveType, ActionCosts
- BinaryHeapOpenSet min-heap for A* open set
- AStarPathFinder with timeout, cancellation, partial path support
- CalculationContext for thread-safe world state snapshots
- MoveHelper for block passability checks
- IGoal interface + GoalBlock, GoalXZ, GoalNear, GoalComposite
- IMove interface + MoveTraverse, MoveDiagonal, MoveAscend, MoveDescend, MoveClimb
- /pathfind command for testing the new pathfinder

Made-with: Cursor
2026-04-12 18:43:32 +00:00

42 lines
1.2 KiB
C#

using System;
namespace MinecraftClient.Pathing.Goals
{
public sealed class GoalBlock : IGoal
{
public int X { get; }
public int Y { get; }
public int Z { get; }
public GoalBlock(int x, int y, int z)
{
X = x;
Y = y;
Z = z;
}
public bool IsInGoal(int x, int y, int z)
=> x == X && y == Y && z == Z;
public double Heuristic(int x, int y, int z)
{
int dx = Math.Abs(x - X);
int dy = Math.Abs(y - Y);
int dz = Math.Abs(z - Z);
return DistanceHeuristic(dx, dy, dz);
}
internal static double DistanceHeuristic(int dx, int dy, int dz)
{
int horizontal = Math.Max(dx, dz);
int diagonal = Math.Min(dx, dz);
int straight = horizontal - diagonal;
double cost = diagonal * Core.ActionCosts.SprintOneBlock * Core.ActionCosts.DiagonalMultiplier
+ straight * Core.ActionCosts.SprintOneBlock
+ Math.Abs(dy) * Core.ActionCosts.SprintOneBlock;
return cost;
}
public override string ToString() => $"GoalBlock({X}, {Y}, {Z})";
}
}