63 std::multimap<const tile *, std::unique_ptr<detail::vertex>>;
87 std::priority_queue<detail::vertex, std::vector<detail::vertex>,
118 void set_constraint(std::unique_ptr<step_constraint> &&constraint);
129 std::unique_ptr<path_finder_private>
m_d;
137 m_d = std::move(other.m_d);
164 virtual path_finder::storage_type::const_iterator
166 std::size_t num_waypoints)
const;
191 path_finder::storage_type::const_iterator
193 std::size_t num_waypoints)
const override;
A path finding destination that accepts any allied city.
bool reached(const detail::vertex &vertex) const override
Checks if a vertex should be considered as being at the destination.
~allied_city_destination()
Destructor.
allied_city_destination(const player *allied_with)
Constructor.
Abstraction for path finding destinations.
virtual path_finder::storage_type::const_iterator find_best(const path_finder::storage_type &map, std::size_t num_waypoints) const
Returns an iterator to the best vertex that is a destination vertex.
virtual ~destination()
Destructor.
virtual bool reached(const detail::vertex &vertex) const =0
Checks if a vertex should be considered as being at the destination.
void reset()
Resets the state of the path finder.
bool run_search(const destination &destination, bool full=false)
Runs the path finding seach until the stopping condition is met (the destination tile is reached).
void attempt_action_move(detail::vertex &source)
Opens vertices corresponding to attempts to do ORDER_ACTION_MOVE from the source vertex.
void insert_initial_vertex()
Inserts the initial vertex, from which the search will be started.
storage_type best_vertices
std::unique_ptr< step_constraint > constraint
void attempt_load(detail::vertex &source)
Opens vertices corresponding to attempts to load into a transport from the source vertex.
void attempt_move(detail::vertex &source)
Opens vertices corresponding to attempts to do ORDER_MOVE from the source vertex.
void attempt_paradrop(detail::vertex &source)
Opens vertices corresponding to attempts to unload from a transport at the source vertex.
std::priority_queue< detail::vertex, std::vector< detail::vertex >, std::greater<> > queue
bool is_reached(const destination &destination, const detail::vertex &v) const
Checks if a vertex is at the destination, taking waypoints into account.
void attempt_unload(detail::vertex &source)
Opens vertices corresponding to attempts to unload from a transport at the source vertex.
const detail::vertex initial_vertex
The starting point in the search graph.
const ::unit unit
A unit used to probe whether moves are valid.
~path_finder_private()=default
std::vector< const tile * > waypoints
path_finder_private(const unit *unit, const detail::vertex &init)
Constructor.
void maybe_insert_vertex(const detail::vertex &v)
Saves a new vertex for further processing if it is better than the current vertex at the same locatio...
void attempt_full_mp(detail::vertex &source)
Opens vertices corresponding to attempts to do ORDER_FULL_MP from the source vertex.
A path is a succession of moves and actions to go from one location to another.
bool pop_waypoint()
Removes the last added waypoint.
void set_constraint(std::unique_ptr< step_constraint > &&constraint)
Sets a constraint to limit the number of steps considered when trying to find a path.
virtual ~path_finder()
Destructor.
path_finder & operator=(path_finder &&other)
Move-assignment operator.
std::vector< path > find_all(const destination &destination)
Runs the path finding algorithm, searching for all paths leading to the destination.
void unit_changed(const unit &unit)
Notifies the path finder that some unit died or changed state.
std::unique_ptr< path_finder_private > m_d
std::multimap< const tile *, std::unique_ptr< detail::vertex > > storage_type
The type of the underlying storage, exposed through destination.
void push_waypoint(const tile *location)
Adds a waypoint to the path finding.
path_finder(const unit *unit)
Constructs a path_finder for the given unit.
std::optional< path > find_path(const destination &destination)
Runs the path finding algorithm.
A path finding destination that accepts any tile where one can refuel or, for units with HP loss,...
refuel_destination(const unit &unit)
Constructor.
bool reached(const detail::vertex &vertex) const override
Checks if a vertex should be considered as being at the destination.
~refuel_destination()
Destructor.
Allows one to limit the scope a path finding search.
virtual bool is_allowed(const path::step &step) const =0
Whether a step should be used in the search.
virtual ~step_constraint()=default
Destructor.
A path finding destination that accepts any path leading to a specific tile.
tile_destination(const tile *destination)
Constructor.
const tile * m_destination
~tile_destination()
Destructor.
bool reached(const detail::vertex &vertex) const override
Checks if a vertex should be considered as being at the destination.
path_finder::storage_type::const_iterator find_best(const path_finder::storage_type &map, std::size_t num_waypoints) const override
Returns an iterator to the best vertex that is a destination vertex.
A constraint that restricts the search to tiles known by the player.
bool is_allowed(const path::step &step) const override
Whether a step should be used in the search.
tile_known_constraint(const player *player)
Constructor.
~tile_known_constraint()=default
Destructor.
#define fc_assert(condition)
A vertex in the path-finding graph.
vertex child_for_action(action_id action, const unit &probe, tile *target)
Creates a vertex starting from this one and executing an action.
void fill_probe(unit &probe) const
Ensures that probe reflects the properties of this vertex.
bool operator>(const vertex &other) const
Defines an ordering for the priority queue.
bool comparable(const vertex &other) const
Checks whether two vertices are comparable, which is the case when one of them is unambiguously "bett...
vertex * parent
The previous vertex, if any.
static vertex from_unit(const unit &unit)
Creates a vertex representing the state of a unit.
bool operator==(const vertex &other) const
Equality comparator.