Minecraft-Console-Client/MinecraftClient/Pathing/Goals/GoalComposite.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

45 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
namespace MinecraftClient.Pathing.Goals
{
public sealed class GoalComposite : IGoal
{
private readonly IGoal[] _goals;
public GoalComposite(params IGoal[] goals)
{
ArgumentNullException.ThrowIfNull(goals);
_goals = goals;
}
public GoalComposite(IEnumerable<IGoal> goals)
{
ArgumentNullException.ThrowIfNull(goals);
_goals = goals is IGoal[] arr ? arr : [.. goals];
}
public bool IsInGoal(int x, int y, int z)
{
foreach (var g in _goals)
{
if (g.IsInGoal(x, y, z))
return true;
}
return false;
}
public double Heuristic(int x, int y, int z)
{
double min = double.MaxValue;
foreach (var g in _goals)
{
double h = g.Heuristic(x, y, z);
if (h < min) min = h;
}
return min;
}
public override string ToString() => $"GoalComposite({_goals.Length} goals)";
}
}