AdventOfCode/AdventOfCode.Core/Shared/A-Star/AStarNode.cs
Rob 3846b42b7e Massive code base change
partial completion of day 3
2023-12-03 19:09:26 +01:00

41 lines
997 B
C#

namespace AdventOfCode.Core.Shared.A_Star
{
public class AStarNode : Node
{
/// <summary>
/// Distance from start node
/// </summary>
public int GCost { get; set; } = 0;
/// <summary>
/// Distance from end node
/// </summary>
public int HCost { get; set; }
/// <summary>
/// Total cost (G + F)
/// </summary>
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;
}
}
}