The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Typedefs | Enumerations | Functions
pathfind Namespace Reference

Classes

struct  cost_calculator
 
struct  dummy_path_calculator
 Function which doesn't take anything into account. More...
 
struct  emergency_path_calculator
 Function which only uses terrain, ignoring shroud, enemies, etc. 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
 
struct  jamming_path
 A refinement of paths for use when calculating jamming. More...
 
class  manager
 
struct  marked_route
 Structure which holds a single route and marks for special events. More...
 
struct  move_type_path_calculator
 
struct  paths
 Object which contains all the possible locations a unit can move to, with associated best routes to those locations. More...
 
struct  plain_route
 Structure which holds a single route between one location and another. More...
 
struct  shortest_path_calculator
 
class  teleport_group
 
class  teleport_map
 
struct  vision_path
 A refinement of paths for use when calculating vision. More...
 

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 size_t width, const 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 (team const &current_team, map_location const &loc, team const &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)
 Creates a list of routes that a unit can traverse from the provided location. More...
 
static paths::dest_vect::iterator lower_bound (paths::dest_vect &v, const map_location &loc)
 
marked_route mark_route (const plain_route &rt)
 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)
 

Typedef Documentation

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

Definition at line 28 of file teleport.hpp.

Enumeration Type Documentation

Enumerator
VACANT_CASTLE 
VACANT_ANY 

Definition at line 39 of file pathfind.hpp.

Function Documentation

plain_route pathfind::a_star_search ( const map_location src,
const map_location dst,
double  stop_at,
const cost_calculator *  calc,
const size_t  width,
const size_t  height,
const teleport_map *  teleports,
bool  border 
)
bool pathfind::enemy_zoc ( team const &  current_team,
map_location const &  loc,
team const &  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 138 of file pathfind.cpp.

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

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

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 
)
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, teleportaion 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

Definition at line 267 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::h(), i, team::is_enemy(), game_board::map(), next, nodes, map_location::null_location(), unit::side(), resources::teams, gamemap::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().

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 121 of file pathfind.cpp.

References find_vacant_tile(), unit::get_location(), unit::side(), and VACANT_CASTLE.

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

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 56 of file pathfind.cpp.

References unit_map::end(), unit_map::find(), resources::gameboard, get_adjacent_tiles(), gamemap::is_castle(), game_board::map(), unit::movement_cost(), gamemap::on_board(), team::shrouded(), resources::units, 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().

const teleport_map pathfind::get_teleport_locations ( const unit u,
const team viewing_team,
bool  see_all,
bool  ignore_units 
)
static paths::dest_vect::iterator pathfind::lower_bound ( paths::dest_vect &  v,
const map_location loc 
)
static
marked_route pathfind::mark_route ( const plain_route &  rt)