/// <summary> /// Gets the heuristic for a node in relation to this portal. This is only used for Shortcut portals, but is valid for all types. /// </summary> /// <param name="node">The node.</param> /// <param name="goal">The goal.</param> /// <param name="moveCostProvider">The move cost provider.</param> /// <returns>The heuristic</returns> public int GetHeuristic(IPathNode node, IPathNode goal, IMoveCost moveCostProvider) { //The logic here is that we want to shortest possible distance from the node to this portal cell, //combined with the shortest possible distance from our partner portal cell to the goal, again combined with the // cost of making the portal move using those two entry points. int mx = _matrixBounds.AdjustColumnToBounds(node.matrixPosX); int mz = _matrixBounds.AdjustRowToBounds(node.matrixPosZ); var closestCellToNode = this.parent.rawMatrix[mx, mz]; mx = _partner._matrixBounds.AdjustColumnToBounds(goal.matrixPosX); mz = _partner._matrixBounds.AdjustRowToBounds(goal.matrixPosZ); var closestCellToGoal = _partner.parent.rawMatrix[mx, mz]; return(moveCostProvider.GetHeuristic(node, closestCellToNode) + _action.GetActionCost(closestCellToNode, closestCellToGoal, moveCostProvider) + moveCostProvider.GetHeuristic(closestCellToGoal, goal)); }
/// <summary> /// Gets the heuristic from this portal to the goal. /// </summary> /// <param name="goal">The goal.</param> /// <param name="moveCostProvider">The move cost provider.</param> /// <returns>The heuristic</returns> //TODO: this si not used, so remove it public int GetHeuristic(IPathNode goal, IMoveCost moveCostProvider) { return(moveCostProvider.GetHeuristic(_partner, goal)); }
/// <summary> /// Gets the heuristic for a node in relation to this portal. /// </summary> /// <param name="node">The node.</param> /// <param name="goal">The goal.</param> /// <param name="moveCostProvider">The move cost provider.</param> /// <returns>The heuristic</returns> public int GetHeuristic(IPathNode node, IPathNode goal, IMoveCost moveCostProvider) { return moveCostProvider.GetHeuristic(node, this) + moveCostProvider.GetHeuristic(_partner, goal); }
/// <summary> /// Gets the heuristic for a node in relation to this portal. This is only used for Shortcut portals, but is valid for all types. /// </summary> /// <param name="node">The node.</param> /// <param name="goal">The goal.</param> /// <param name="moveCostProvider">The move cost provider.</param> /// <returns>The heuristic</returns> public int GetHeuristic(IPathNode node, IPathNode goal, IMoveCost moveCostProvider) { //The logic here is that we want to shortest possible distance from the node to this portal cell, //combined with the shortest possible distance from our partner portal cell to the goal, again combined with the // cost of making the portal move using those two entry points. int mx = _matrixBounds.AdjustColumnToBounds(node.matrixPosX); int mz = _matrixBounds.AdjustRowToBounds(node.matrixPosZ); var closestCellToNode = this.parent.rawMatrix[mx, mz]; mx = _partner._matrixBounds.AdjustColumnToBounds(goal.matrixPosX); mz = _partner._matrixBounds.AdjustRowToBounds(goal.matrixPosZ); var closestCellToGoal = _partner.parent.rawMatrix[mx, mz]; return moveCostProvider.GetHeuristic(node, closestCellToNode) + _action.GetActionCost(closestCellToNode, closestCellToGoal, moveCostProvider) + moveCostProvider.GetHeuristic(closestCellToGoal, goal); }
/// <summary> /// Gets the action cost. /// </summary> /// <param name="from">The node from which the action will start.</param> /// <param name="to">The node at which the action will end.</param> /// <param name="costProvider">The cost provider in use by the path finder.</param> /// <returns></returns> public int GetActionCost(IPositioned from, IPositioned to, IMoveCost costProvider) { return costProvider.GetHeuristic(from, to); }
/// <summary> /// Gets the action cost. /// </summary> /// <param name="from">The node from which the action will start.</param> /// <param name="to">The node at which the action will end.</param> /// <param name="costProvider">The cost provider in use by the path finder.</param> /// <returns></returns> public int GetActionCost(IPositioned from, IPositioned to, IMoveCost costProvider) { return(costProvider.GetHeuristic(from, to)); }