// 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)); }
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 }
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)) { } }
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); }
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); }
public override int GetHashCode() { return((GCost.GetHashCode() + HCost.GetHashCode() + FCost.GetHashCode() + Position.GetHashCode()) * 26); }
public int CompareTo(DijkstraNode other) { return(-GCost.CompareTo(other.GCost)); }