namespace AdventOfCode.Core.Shared.A_Star
{
public class AStarNode : Node
{
///
/// Distance from start node
///
public int GCost { get; set; } = 0;
///
/// Distance from end node
///
public int HCost { get; set; }
///
/// Total cost (G + F)
///
public int FCost => GCost + HCost;
public bool? IsClosed { get; private set; } = null;
public AStarNode? ParentNode { get; set; }
public AStarNode(Node 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 bool CanMoveTo(AStarNode target)
{
int diff = target.Integer - Integer; ;
return diff == 0 || diff == 1;
}
}
}