Esempio n. 1
0
    // Porovná hodnoty uzlů, přednost má ten, u kterého je součet vzdálenosti od počátku a odhadovaná vzdálenost od konce menší
    public int CompareTo(PathfindingNode other)
    {
        if (FCost == other.FCost)
        {
            return(GCost.CompareTo(other.GCost));
        }

        return(FCost.CompareTo(other.FCost));
    }
Esempio n. 2
0
    public int CompareTo(Cell other)
    {
        int result = FCost.CompareTo(other.FCost);

        if (result == 0)
        {
            result = GCost.CompareTo(other.GCost);
        }
        return(-result); //we need to return -result because higher F or G cost means that Cell has lower priority
    }
Esempio n. 3
0
File: NBS.cs Progetto: Treff/NBS
        public void GetPath(TState from, TState to, GetStateHash <TState> getHash, GetSuccessors <TState> getSuccessors,
                            GCost <TState> gCost, HCost <TState> forward, HCost <TState> backward, List <TState> thePath)
        {
            if (InitializeSearch(from, to, getHash, getSuccessors, gCost, forward, backward, thePath) == false)
            {
                return;
            }

            while (!ExpandAPair(thePath))
            {
            }
        }
Esempio n. 4
0
        public int CompareTo(Node other)
        {
            int compare = FCost.CompareTo(other.FCost);

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

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

            return(-compare);
        }
Esempio n. 5
0
File: NBS.cs Progetto: Treff/NBS
        public bool InitializeSearch(TState from, TState to, GetStateHash <TState> getHash, GetSuccessors <TState> getSuccessors,
                                     GCost <TState> gCost, HCost <TState> forward, HCost <TState> backward, List <TState> thePath)
        {
            _getStateHash      = getHash;
            _gCost             = gCost;
            _getSuccessors     = getSuccessors;
            _forwardHeuristic  = forward;
            _backwardHeuristic = backward;
            _currentCost       = double.MaxValue;
            _queue.Reset();
            ResetNodeCount();
            thePath.Clear();
            _start = from;
            _goal  = to;

            if (_start.Equals(_goal))
            {
                return(false);
            }
            _queue.ForwardQueue.AddOpenNode(_start, _getStateHash(_start), 0, _forwardHeuristic(_start, _goal));
            _queue.BackwardQueue.AddOpenNode(_goal, _getStateHash(_goal), 0, _backwardHeuristic(_goal, _start));
            return(true);
        }
Esempio n. 6
0
 public override int GetHashCode()
 {
     return((GCost.GetHashCode() + HCost.GetHashCode() + FCost.GetHashCode() + Position.GetHashCode()) * 26);
 }
Esempio n. 7
0
 public int CompareTo(DijkstraNode other)
 {
     return(-GCost.CompareTo(other.GCost));
 }