AdventOfCode/AdventOfCode.Core/Shared/A-Star/AStarNode.cs

45 lines
1.1 KiB
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>
/// Distance from 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 bool CanMoveTo(AStarNode target)
{
return false;
// TODO FIX
//int diff = target.Integer - Integer;
//return diff == 0 || diff == 1;
}
}
}