37 lines
936 B
C#
37 lines
936 B
C#
using AdventOfCode.Core.Shared.Grid;
|
|
|
|
namespace AdventOfCode.Core.Shared.A_Star
|
|
{
|
|
public class AStarNode : Point
|
|
{
|
|
/// <summary>
|
|
/// Distance from start node
|
|
/// </summary>
|
|
public long GCost { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Estaimated distance to end node
|
|
/// </summary>
|
|
public long HCost { get; set; }
|
|
|
|
/// <summary>
|
|
/// Total cost (G + F)
|
|
/// </summary>
|
|
public long FCost => GCost + HCost;
|
|
|
|
public bool? IsClosed { get; private set; } = null;
|
|
|
|
public AStarNode? ParentNode { get; set; }
|
|
|
|
public AStarNode(Point position) : base(position) { }
|
|
|
|
public AStarNode(int x, int y, char value) : base(x, y, value) { }
|
|
|
|
public void OpenNode() => IsClosed = false;
|
|
|
|
public void CloseNode() => IsClosed = true;
|
|
|
|
public virtual bool CanMoveTo(AStarNode target) => true;
|
|
}
|
|
}
|