internal GeometricPathAStarNode MakeNeighbor(int row, int col) { GeometricPathAStarNode neighbor = new GeometricPathAStarNode(TestCase); neighbor.PreviousNode = this; neighbor.Coords = new Coords(row, col); neighbor.TestCase = this.TestCase; neighbor.ComputeDistances(); return(neighbor); }
private void ComputeDistances() { GeometricPathAStarNode prev = PreviousNode as GeometricPathAStarNode; bool isLateralMovement = this.Coords.Column == prev?.Coords.Column || this.Coords.Row == prev?.Coords.Row; if (prev == null) { DistFromPrevious = 0; DistFromStart = 0; } else { DistFromPrevious = isLateralMovement ? 1 : Math.Sqrt(2); DistFromStart = prev.DistFromStart + DistFromPrevious; } ComputeDistanceToGoal(); TotalDist = DistFromStart + DistToGoal; }
public override bool Equals(object otherObj) { GeometricPathAStarNode other = otherObj as GeometricPathAStarNode; return(this.Coords.Equals(other.Coords)); }