Freeciv21
Develop your civilization from humble roots to a global empire
freeciv::detail::vertex Struct Reference

A vertex in the path-finding graph. More...

#include <path_finder.h>

+ Inheritance diagram for freeciv::detail::vertex:
+ Collaboration diagram for freeciv::detail::vertex:

Public Member Functions

vertex child_for_action (action_id action, const unit &probe, tile *target)
 Creates a vertex starting from this one and executing an action. More...
 
bool comparable (const vertex &other) const
 Checks whether two vertices are comparable, which is the case when one of them is unambiguously "better" than the other. More...
 
void fill_probe (unit &probe) const
 Ensures that probe reflects the properties of this vertex. More...
 
bool operator== (const vertex &other) const
 Equality comparator. More...
 
bool operator> (const vertex &other) const
 Defines an ordering for the priority queue. More...
 

Static Public Member Functions

static vertex from_unit (const unit &unit)
 Creates a vertex representing the state of a unit. More...
 

Public Attributes

vertexparent
 The previous vertex, if any. More...
 
- Public Attributes inherited from freeciv::path::step
tilelocation
 Where we are. More...
 
unitloaded
 The unit we are loaded in. More...
 
bool moved
 Whether we moved this turn (for HP recovery) More...
 
bool paradropped
 Whether we paradropped this turn. More...
 
bool is_final
 Whether this vertex can have children. More...
 
int waypoints
 How many waypoints we have visited so far. More...
 
int turns
 How many turns it takes to get there. More...
 
int moves_left
 How many move fragments the unit has left. More...
 
int health
 How many HP the unit has left. More...
 
int fuel_left
 How much fuel the unit has left. More...
 
unit_order order
 The order to come here. More...
 

Detailed Description

A vertex in the path-finding graph.

It primarily corresponds to a tile, but sometimes a tile has several vertices (for instance, a unit may want to wait in a city to avoid ending its turn in the open).

Additional information about the path finding is also stored.

Definition at line 31 of file path_finder.h.

Member Function Documentation

◆ child_for_action()

vertex freeciv::detail::vertex::child_for_action ( action_id  action,
const unit probe,
tile target 
)

Creates a vertex starting from this one and executing an action.

The vertex state is initialized as a copy of this one except that the action move cost is subtracted.

Definition at line 43 of file path_finder.cpp.

Referenced by freeciv::path_finder::path_finder_private::attempt_load(), freeciv::path_finder::path_finder_private::attempt_paradrop(), and freeciv::path_finder::path_finder_private::attempt_unload().

◆ comparable()

bool freeciv::detail::vertex::comparable ( const vertex other) const

Checks whether two vertices are comparable, which is the case when one of them is unambiguously "better" than the other.

Vertices that are not comparable should be considered distinct: this is the case, for instance, of vertices at different locations. Comparability is not a transitive property.

Definition at line 77 of file path_finder.cpp.

◆ fill_probe()

◆ from_unit()

vertex freeciv::detail::vertex::from_unit ( const unit unit)
static

Creates a vertex representing the state of a unit.

Definition at line 27 of file path_finder.cpp.

◆ operator==()

bool freeciv::detail::vertex::operator== ( const vertex other) const

Equality comparator.

Definition at line 119 of file path_finder.cpp.

◆ operator>()

bool freeciv::detail::vertex::operator> ( const vertex other) const

Defines an ordering for the priority queue.

Definition at line 132 of file path_finder.cpp.

Member Data Documentation

◆ parent

vertex* freeciv::detail::vertex::parent

The previous vertex, if any.

Definition at line 34 of file path_finder.h.

Referenced by child_for_action().