Beispiel #1
0
  /**
   * Obtain the value of this node (accumulated distance to this node)
   * Returns 0 on failure to find the node.
   */
  gcc_pure
  AStarPriorityValue GetNodeValue(const Node &node) const {
    node_value_const_iterator it = node_values.find(node);
    if (cur->first == node)
      return cur->second;

    if (it == node_values.end())
      return AStarPriorityValue(0);

    return it->second;
  }
Beispiel #2
0
 gcc_pure
 AStarPriorityValue Adjust(const bool is_min) const {
   return is_min ? *this : AStarPriorityValue(ASTAR_MINMAX_OFFSET - g,
                                              ASTAR_MINMAX_OFFSET - h);
 }
Beispiel #3
0
 /**
  * Resets as if constructed afresh
  *
  * @param n Node to start
  */
 void Restart(const Node &node) {
   Clear();
   Push(node, node, AStarPriorityValue(0));
 }
Beispiel #4
0
 /**
  * Constructor
  *
  * @param n Node to start
  * @param is_min Whether this algorithm will search for min or max distance
  */
 AStar(const Node &node, unsigned reserve_default = ASTAR_QUEUE_SIZE)
 {
   Reserve(reserve_default);
   Push(node, node, AStarPriorityValue(0));
 }
Beispiel #5
0
 constexpr
 AStarPriorityValue operator+(const AStarPriorityValue& other) const {
   return AStarPriorityValue(g + other.g, other.h);
 }
Beispiel #6
0
 constexpr
 AStarPriorityValue Adjust() const {
   return is_min ? *this : AStarPriorityValue(MINMAX_OFFSET - g,
                                              MINMAX_OFFSET - h);
 }