示例#1
0
        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);
        }
示例#2
0
        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;
        }
示例#3
0
        public override bool Equals(object otherObj)
        {
            GeometricPathAStarNode other = otherObj as GeometricPathAStarNode;

            return(this.Coords.Equals(other.Coords));
        }