Freeciv21
Develop your civilization from humble roots to a global empire
freeciv::path_finder::path_finder_private Class Reference
+ Collaboration diagram for freeciv::path_finder::path_finder_private:

Public Member Functions

 path_finder_private (const unit *unit, const detail::vertex &init)
 Constructor. More...
 
 ~path_finder_private ()=default
 
void insert_initial_vertex ()
 Inserts the initial vertex, from which the search will be started. More...
 
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 location. More...
 
bool is_reached (const destination &destination, const detail::vertex &v) const
 Checks if a vertex is at the destination, taking waypoints into account. More...
 
void attempt_move (detail::vertex &source)
 Opens vertices corresponding to attempts to do ORDER_MOVE from the source vertex. More...
 
void attempt_full_mp (detail::vertex &source)
 Opens vertices corresponding to attempts to do ORDER_FULL_MP from the source vertex. More...
 
void attempt_load (detail::vertex &source)
 Opens vertices corresponding to attempts to load into a transport from the source vertex. More...
 
void attempt_unload (detail::vertex &source)
 Opens vertices corresponding to attempts to unload from a transport at the source vertex. More...
 
void attempt_paradrop (detail::vertex &source)
 Opens vertices corresponding to attempts to unload from a transport at the source vertex. More...
 
void attempt_action_move (detail::vertex &source)
 Opens vertices corresponding to attempts to do ORDER_ACTION_MOVE from the source vertex. More...
 
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). More...
 
void reset ()
 Resets the state of the path finder. More...
 

Public Attributes

const ::unit unit
 A unit used to probe whether moves are valid. More...
 
const detail::vertex initial_vertex
 The starting point in the search graph. More...
 
std::unique_ptr< step_constraintconstraint = nullptr
 
storage_type best_vertices
 
std::priority_queue< detail::vertex, std::vector< detail::vertex >, std::greater<> > queue
 
std::vector< const tile * > waypoints
 

Detailed Description

Definition at line 66 of file path_finder.h.

Constructor & Destructor Documentation

◆ path_finder_private()

freeciv::path_finder::path_finder_private::path_finder_private ( const unit unit,
const detail::vertex init 
)
explicit

Constructor.

Definition at line 145 of file path_finder.cpp.

◆ ~path_finder_private()

freeciv::path_finder::path_finder_private::~path_finder_private ( )
default

Member Function Documentation

◆ attempt_action_move()

void freeciv::path_finder::path_finder_private::attempt_action_move ( detail::vertex source)

Opens vertices corresponding to attempts to do ORDER_ACTION_MOVE from the source vertex.

The generated vertices are always final because ORDER_ACTION_MOVE cannot be used in the middle of a path.

Definition at line 514 of file path_finder.cpp.

◆ attempt_full_mp()

void freeciv::path_finder::path_finder_private::attempt_full_mp ( detail::vertex source)

Opens vertices corresponding to attempts to do ORDER_FULL_MP from the source vertex.

This is a last resort vertex that may give the unit more HP or fuel that will be useful to continue its journey.

Definition at line 323 of file path_finder.cpp.

◆ attempt_load()

void freeciv::path_finder::path_finder_private::attempt_load ( detail::vertex source)

Opens vertices corresponding to attempts to load into a transport from the source vertex.

Definition at line 337 of file path_finder.cpp.

◆ attempt_move()

void freeciv::path_finder::path_finder_private::attempt_move ( detail::vertex source)

Opens vertices corresponding to attempts to do ORDER_MOVE from the source vertex.

Definition at line 276 of file path_finder.cpp.

◆ attempt_paradrop()

void freeciv::path_finder::path_finder_private::attempt_paradrop ( detail::vertex source)

Opens vertices corresponding to attempts to unload from a transport at the source vertex.

Definition at line 433 of file path_finder.cpp.

◆ attempt_unload()

void freeciv::path_finder::path_finder_private::attempt_unload ( detail::vertex source)

Opens vertices corresponding to attempts to unload from a transport at the source vertex.

Definition at line 382 of file path_finder.cpp.

◆ insert_initial_vertex()

void freeciv::path_finder::path_finder_private::insert_initial_vertex ( )

Inserts the initial vertex, from which the search will be started.

Definition at line 155 of file path_finder.cpp.

Referenced by path_finder_private().

◆ is_reached()

bool freeciv::path_finder::path_finder_private::is_reached ( const destination destination,
const detail::vertex v 
) const

Checks if a vertex is at the destination, taking waypoints into account.

Definition at line 256 of file path_finder.cpp.

◆ maybe_insert_vertex()

void freeciv::path_finder::path_finder_private::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 location.

Definition at line 164 of file path_finder.cpp.

◆ reset()

void freeciv::path_finder::path_finder_private::reset ( )

Resets the state of the path finder.

The search will be resumed from the beginning.

Definition at line 631 of file path_finder.cpp.

◆ run_search()

bool freeciv::path_finder::path_finder_private::run_search ( const destination destination,
bool  full = false 
)

Runs the path finding seach until the stopping condition is met (the destination tile is reached).

Checks if the tile has already been reached before proceeding.

If full is true, the algorithm is only stopped once all possibilities have been found.

Returns
true if a path was found.

Definition at line 574 of file path_finder.cpp.

Member Data Documentation

◆ best_vertices

storage_type freeciv::path_finder::path_finder_private::best_vertices

Definition at line 86 of file path_finder.h.

◆ constraint

std::unique_ptr<step_constraint> freeciv::path_finder::path_finder_private::constraint = nullptr

Definition at line 76 of file path_finder.h.

◆ initial_vertex

const detail::vertex freeciv::path_finder::path_finder_private::initial_vertex

The starting point in the search graph.

Definition at line 74 of file path_finder.h.

◆ queue

std::priority_queue<detail::vertex, std::vector<detail::vertex>, std::greater<> > freeciv::path_finder::path_finder_private::queue

Definition at line 89 of file path_finder.h.

◆ unit

const ::unit freeciv::path_finder::path_finder_private::unit

A unit used to probe whether moves are valid.

Definition at line 72 of file path_finder.h.

◆ waypoints

std::vector<const tile *> freeciv::path_finder::path_finder_private::waypoints

Definition at line 92 of file path_finder.h.