The Battle for Wesnoth  1.19.7+dev
Classes | Typedefs | Enumerations | Functions
pathfind Namespace Reference

Classes

struct  cost_calculator
 
struct  paths
 Object which contains all the possible locations a unit can move to, with associated best routes to those locations. More...
 
struct  vision_path
 A refinement of paths for use when calculating vision. More...
 
struct  jamming_path
 A refinement of paths for use when calculating jamming. More...
 
struct  plain_route
 Structure which holds a single route between one location and another. More...
 
struct  marked_route
 Structure which holds a single route and marks for special events. More...
 
struct  shortest_path_calculator
 
struct  move_type_path_calculator
 
struct  emergency_path_calculator
 Function which only uses terrain, ignoring shroud, enemies, etc. More...
 
struct  dummy_path_calculator
 Function which doesn't take anything into account. More...
 
struct  full_cost_map
 Structure which uses find_routes() to build a cost map This maps each hex to a the movements a unit will need to reach this hex. More...
 
class  ignore_units_display_context
 
class  ignore_units_filter_context
 
class  teleport_group
 
class  teleport_map
 
class  manager
 

Typedefs

typedef std::pair< std::set< map_location >, std::set< map_location > > teleport_pair
 

Enumerations

enum  VACANT_TILE_TYPE { VACANT_CASTLE , VACANT_ANY }
 

Functions

plain_route a_star_search (const map_location &src, const map_location &dst, double stop_at, const cost_calculator &calc, const std::size_t width, const std::size_t height, const teleport_map *teleports, bool border)
 
map_location find_vacant_tile (const map_location &loc, VACANT_TILE_TYPE vacancy, const unit *pass_check, const team *shroud_check, const game_board *board)
 Function that will find a location on the board that is as near to loc as possible, but which is unoccupied by any units. More...
 
map_location find_vacant_castle (const unit &leader)
 Wrapper for find_vacant_tile() when looking for a vacant castle tile near a leader. More...
 
bool enemy_zoc (const team &current_team, const map_location &loc, const team &viewing_team, bool see_all)
 Determines if a given location is in an enemy zone of control. More...
 
static void find_routes (const map_location &origin, const movetype::terrain_costs &costs, bool slowed, int moves_left, int max_moves, int turns_left, paths::dest_vect &destinations, std::set< map_location > *edges, const unit *teleporter, const team *current_team, const unit *skirmisher, const team *viewing_team, const std::map< map_location, int > *jamming_map=nullptr, std::vector< std::pair< int, int >> *full_cost_map=nullptr, bool check_vision=false)
 Creates a list of routes that a unit can traverse from the provided location. More...
 
static bool step_compare (const paths::step &a, const map_location &b)
 
marked_route mark_route (const plain_route &rt, bool update_move_cost=false)
 Add marks on a route rt assuming that the unit located at the first hex of rt travels along it. More...
 
const teleport_map get_teleport_locations (const unit &u, const team &viewing_team, bool see_all, bool ignore_units, bool check_vision)
 

Typedef Documentation

◆ teleport_pair

typedef std::pair<std::set<map_location>, std::set<map_location> > pathfind::teleport_pair

Definition at line 32 of file teleport.hpp.

Enumeration Type Documentation

◆ VACANT_TILE_TYPE

Enumerator
VACANT_CASTLE 
VACANT_ANY 

Definition at line 39 of file pathfind.hpp.

Function Documentation

◆ a_star_search()

plain_route pathfind::a_star_search ( const map_location src,
const map_location dst,
double  stop_at,
const cost_calculator calc,
const std::size_t  width,
const std::size_t  height,
const teleport_map teleports,
bool  border 
)

◆ enemy_zoc()

bool pathfind::enemy_zoc ( const team current_team,
const map_location loc,
const team viewing_team,
bool  see_all 
)

Determines if a given location is in an enemy zone of control.

Parameters
current_teamThe moving team (only ZoC of enemies of this team are considered).
locThe location to check.
viewing_teamOnly units visible to this team are considered.
see_allIf true, all units are considered (and viewing_team is ignored).
Returns
true iff a visible enemy exerts zone of control over loc.

Definition at line 134 of file pathfind.cpp.

References unit::emits_zoc(), resources::gameboard, get_adjacent_tiles(), game_board::get_visible_unit(), team::is_enemy(), loc, and unit::side().

Referenced by pathfind::shortest_path_calculator::cost(), find_routes(), mark_route(), and wb::path_cost().

◆ find_routes()

static void pathfind::find_routes ( const map_location origin,
const movetype::terrain_costs costs,
bool  slowed,
int  moves_left,
int  max_moves,
int  turns_left,
paths::dest_vect destinations,
std::set< map_location > *  edges,
const unit teleporter,
const team current_team,
const unit skirmisher,
const team viewing_team,
const std::map< map_location, int > *  jamming_map = nullptr,
std::vector< std::pair< int, int >> *  full_cost_map = nullptr,
bool  check_vision = false 
)
static

Creates a list of routes that a unit can traverse from the provided location.

(This is called when creating pathfind::paths and descendant classes.)

Parameters
[in]originThe location at which to begin the routes.
[in]costsThe costs to use for route finding.
[in]slowedWhether or not to use the slowed costs.
[in]moves_leftThe number of movement points left for the current turn.
[in]max_movesThe number of movement points in each future turn.
[in]turns_leftThe number of future turns of movement to calculate.
[out]destinationsThe traversable routes.
[out]edgesThe hexes (possibly off-map) adjacent to those in destinations. (It is permissible for this to contain some hexes that are also in destinations.)
[in]teleporterIf not nullptr, teleportation will be considered, using this unit's abilities.
[in]current_teamIf not nullptr, enemies of this team can obstruct routes both by occupying hexes and by exerting zones of control. In addition, the presence of units can affect teleportation options.
[in]skirmisherIf not nullptr, use this to determine where ZoC can and cannot be ignored (due to this unit having or not having the skirmisher ability). If nullptr, then ignore all zones of control. (No effect if current_team is nullptr).
[in]viewing_teamIf not nullptr, use this team's vision when detecting enemy units and teleport destinations. If nullptr, then "see all". (No effect if teleporter and current_team are both nullptr.)
[in]jamming_mapThe relevant "jamming" of the costs being used (currently only used with vision costs).
[out]full_cost_mapIf not nullptr, build a cost_map instead of destinations. Destinations is ignored. full_cost_map is a vector of pairs. The first entry is the cost itself, the second how many units already visited this hex
[in]check_visionIf true, use vision check for teleports, that is, ignore units potentially blocking the teleport exit

Definition at line 270 of file pathfind.cpp.

References movetype::terrain_costs::cost(), enemy_zoc(), resources::gameboard, unit::get_ability_bool(), get_adjacent_tiles(), pathfind::teleport_map::get_adjacents(), get_teleport_locations(), game_board::get_visible_unit(), gamemap_base::h(), i, utf8::index(), team::is_enemy(), loc, game_board::map(), moves_left, n, nodes, map_location::null_location(), s, team::shrouded(), unit::side(), game_config::sounds::status::slowed, game_board::teams(), turns_left, gamemap_base::w(), map_location::x, and map_location::y.

Referenced by pathfind::full_cost_map::add_unit(), pathfind::jamming_path::jamming_path(), pathfind::paths::paths(), and pathfind::vision_path::vision_path().

◆ find_vacant_castle()

map_location pathfind::find_vacant_castle ( const unit leader)

Wrapper for find_vacant_tile() when looking for a vacant castle tile near a leader.

If no valid location can be found, it will return a null location.

Definition at line 117 of file pathfind.cpp.

References find_vacant_tile(), resources::gameboard, unit::get_location(), game_board::get_team(), unit::side(), and VACANT_CASTLE.

Referenced by ai::default_recruitment::recruitment::evaluate(), ai::ai_default_rca::leader_shares_keep_phase::execute(), and ai::default_recruitment::recruitment::execute().

◆ find_vacant_tile()

map_location pathfind::find_vacant_tile ( const map_location loc,
VACANT_TILE_TYPE  vacancy,
const unit pass_check,
const team shroud_check,
const game_board board 
)

Function that will find a location on the board that is as near to loc as possible, but which is unoccupied by any units.

If no valid location can be found, it will return a null location. If pass_check is provided, the found location must have a terrain that this unit can enter. If shroud_check is provided, only locations not covered by this team's shroud will be considered.

Definition at line 54 of file pathfind.cpp.

References unit_map::end(), unit_map::find(), resources::gameboard, get_adjacent_tiles(), gamemap::is_castle(), loc, game_board::map(), unit::movement_cost(), gamemap_base::on_board(), team::shrouded(), game_board::units(), movetype::UNREACHABLE, team::uses_shroud(), and VACANT_CASTLE.

Referenced by game_state::can_recruit_from(), unit_creator::find_location(), find_vacant_castle(), game_lua_kernel::intf_find_vacant_tile(), game_lua_kernel::intf_teleport(), and game_events::WML_HANDLER_FUNCTION().

◆ get_teleport_locations()

const teleport_map pathfind::get_teleport_locations ( const unit u,
const team viewing_team,
bool  see_all,
bool  ignore_units,
bool  check_vision 
)

◆ mark_route()

marked_route pathfind::mark_route ( const plain_route rt,
bool  update_move_cost 
)

◆ step_compare()

static bool pathfind::step_compare ( const paths::step a,
const map_location b 
)
static