public int CompareTo(Node other)
 {
     _priorityCache = FCost.CompareTo(other.FCost);  // A* first comparison F Cost
     if (_priorityCache == 0)
     {
         _priorityCache = HCost.CompareTo(other.HCost);
     }
     return(-_priorityCache); // Negative since the 1 meaning that the cost has a higher integer value and we are trying to find the lower cost
 }
示例#2
0
    public int CompareTo(PathNode nodeToCompare)
    {
        int compare = FCost.CompareTo(nodeToCompare.FCost);

        if (compare == 0) // 2 fcost are equal.
        {
            compare = HCost.CompareTo(nodeToCompare.HCost);
        }
        return(-compare);
    }
示例#3
0
        public int CompareTo(AstarNode other)
        {
            var compare = FCost.CompareTo(other.FCost);

            if (compare == 0)
            {
                compare = HCost.CompareTo(other.HCost);
            }
            return(-compare);
        }
示例#4
0
        public int CompareTo(Node nodeToCompare)
        {
            int compare = FCost.CompareTo(nodeToCompare.FCost);

            if (compare == 0)
            {
                compare = HCost.CompareTo(nodeToCompare.HCost);
            }
            return(-compare);
        }
示例#5
0
    public override int CompareTo(Node other)
    {
        int compare = FCost.CompareTo(other.FCost);

        if (compare == 0)
        {
            compare = HCost.CompareTo(other.HCost);
        }

        return(-compare);
    }
示例#6
0
        public int CompareTo(INode other)
        {
            int fCostCompare = -FCost.CompareTo(other.FCost);

            if (fCostCompare == 0)
            {
                return(-HCost.CompareTo(other.HCost));
            }

            return(fCostCompare);
        }
示例#7
0
        public int CompareTo(GridNodeAStar other)
        {
            var compare = FCost.CompareTo(other.FCost);

            if (compare == 0)
            {
                compare = HCost.CompareTo(other.HCost);
            }

            return(-compare);
        }
示例#8
0
    public int CompareTo(GridTile other)
    {
        int compare = FCost.CompareTo(other.FCost);

        if (compare == 0)
        {
            compare = HCost.CompareTo(other.HCost);
        }

        return(-compare);
    }
    public int CompareTo(AbstractAStarNode other)
    {
        int compare = FCost.CompareTo(other.FCost);

        if (compare == 0)
        {
            compare = HCost.CompareTo(other.HCost);
        }

        return(compare);
    }
示例#10
0
    //odradi ovo preko delegata
    public int CompareTo(Field other)
    {
        int compare = FCost.CompareTo(other.FCost);

        if (compare == 0)
        {
            compare = HCost.CompareTo(other.HCost);
        }
        //1 curent item is lower priority
        return(-compare);
    }
示例#11
0
    public int CompareTo(PathNode other)
    {
        int compare = FCost.CompareTo(other.FCost);

        if (compare == 0)
        {
            compare = HCost.CompareTo(other.HCost); //remember, hCost is the tiebreaker
        }
        //CompareTo on integers treats higher as better. Because this is a pathing algorithm, our problem instead is minimization. So therefore, we return _negative_ compare.
        return(-compare);
    }
示例#12
0
    public int CompareTo(PathfindingNode other)
    {
        var compare = FCost.CompareTo(other.FCost);

        if (compare == 0)
        {
            compare = HCost.CompareTo(other.HCost);
        }

        return(-compare);
    }
示例#13
0
    public int CompareTo(Node other)
    {
        var comparison = FCost.CompareTo(other.FCost);

        if (comparison == 0)
        {
            comparison = HCost.CompareTo(other.HCost);
        }

        return(-comparison);
    }
示例#14
0
        public int CompareTo(PathfindingNode inNodeToCompare)
        {
            int compare = FCost.CompareTo(inNodeToCompare.FCost);

            if (compare == 0)
            {
                compare = HCost.CompareTo(inNodeToCompare.HCost);
            }

            // Flip the compare because we want to sort from lowest to highest.
            return(-compare);
        }
示例#15
0
        // --CURRENTLY UNUSED--
        public int CompareTo(Node n)
        {
            int compare = FCost.CompareTo(n.FCost);

            if (compare == 0)
            {
                compare = HCost.CompareTo(n.HCost);
            }

            // Need to flip the sign otherwise we get the wrong result!
            return(compare * -1);
        }
    public int CompareTo(Node toCompare)
    {
        int compare = FCost.CompareTo(toCompare.FCost);

        if (compare == 0)
        {
            compare = HCost.CompareTo(toCompare.HCost);
        }

        //less fcost - higher priority (for heap class)
        return(-compare);
    }
示例#17
0
        /// <summary>
        ///     The <c>CompareTo</c> method compares the <see cref="Node" />'s priority in a <see cref="Heap{T}" />.
        ///     This is based on the <see cref="Node.FCost" /> and <see cref="Node.HCost" />.
        /// </summary>
        /// <param name="other">The <see cref="Node" /> that it has to be compared to.</param>
        /// <returns>
        ///     Returns <c>1</c> if it has a higher priority, <c>0</c> if the priority is the same and <c>-1</c> if it has a
        ///     lower priority.
        /// </returns>
        public int CompareTo(Node other)
        {
            // First compare the FCost between the nodes.
            int compare = FCost.CompareTo(other.FCost);

            // If both nodes have the same F-cost, take the H-cost in consideration.
            if (compare == 0)
            {
                compare = HCost.CompareTo(other.HCost);
            }

            // Compare returns 1 if the value is higher, in this case we want to return 1 if the node has a higher priority and thus a lower compare value.
            // So we need to invert the compare value and return it.
            return(-compare);
        }
示例#18
0
        public int CompareTo(AStarNode other)
        {
            var dif = FCost.CompareTo(other.FCost);

            return(dif == 0 ? HCost.CompareTo(other.HCost) : dif);
        }