Exemplo n.º 1
0
Arquivo: NBS.cs Projeto: 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))
            {
            }
        }
Exemplo n.º 2
0
Arquivo: NBS.cs Projeto: 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);
        }