The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Public Attributes | Private Attributes | List of all members
pathfind::full_cost_map Struct Reference

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...

#include <pathfind.hpp>

Public Member Functions

 full_cost_map (const unit &u, bool force_ignore_zoc, bool allow_teleport, const team &viewing_team, bool see_all=true, bool ignore_units=true)
 Constructs a cost-map. More...
 
 full_cost_map (bool force_ignore_zoc, bool allow_teleport, const team &viewing_team, bool see_all=true, bool ignore_units=true)
 Same as other constructor but without unit. More...
 
void add_unit (const unit &u, bool use_max_moves=true)
 Adds a units cost map to cost_map (increments the elements in cost_map) More...
 
void add_unit (const map_location &origin, const unit_type *const unit_type, int side)
 Adds a units cost map to cost_map (increments the elements in cost_map) This function can be used to generate a cost_map with a non existing unit. More...
 
int get_cost_at (int x, int y) const
 Accessor for the costs. More...
 
std::pair< int, intget_pair_at (int x, int y) const
 Accessor for the cost/reach-amount pairs. More...
 
double get_average_cost_at (int x, int y) const
 Accessor for the costs. More...
 
virtual ~full_cost_map ()
 

Public Attributes

std::vector< std::pair< int,
int > > 
cost_map
 

Private Attributes

const bool force_ignore_zoc_
 
const bool allow_teleport_
 
const teamviewing_team_
 
const bool see_all_
 
const bool ignore_units_
 

Detailed Description

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.

Can be used commutative by calling add_unit() multiple times.

Definition at line 267 of file pathfind.hpp.

Constructor & Destructor Documentation

pathfind::full_cost_map::full_cost_map ( const unit u,
bool  force_ignore_zoc,
bool  allow_teleport,
const team viewing_team,
bool  see_all = true,
bool  ignore_units = true 
)

Constructs a cost-map.

For a unit each hex is mapped to the cost the unit will need to reach this hex. Considers movement-loss caused by turn changes. Can also used with multiple units to accumulate their costs efficiently. Will also count how many units could reach a hex for easy normalization.

Parameters
uthe unit
force_ignore_zocSet to true to completely ignore zones of control.
allow_teleportSet to true to consider teleportation abilities.
viewing_teamUsually the current team, except for "show enemy moves", etc.
see_allSet to true to remove unit visibility from consideration.
ignore_unitsSet to true if units should never obstruct paths (implies ignoring ZoC as well).

Definition at line 850 of file pathfind.cpp.

References add_unit(), cost_map, resources::gameboard, gamemap::h(), game_board::map(), and gamemap::w().

pathfind::full_cost_map::full_cost_map ( bool  force_ignore_zoc,
bool  allow_teleport,
const team viewing_team,
bool  see_all = true,
bool  ignore_units = true 
)

Same as other constructor but without unit.

Use this when working with add_unit().

Definition at line 865 of file pathfind.cpp.

References cost_map, resources::gameboard, gamemap::h(), game_board::map(), and gamemap::w().

virtual pathfind::full_cost_map::~full_cost_map ( )
inlinevirtual

Definition at line 285 of file pathfind.hpp.

Member Function Documentation

void pathfind::full_cost_map::add_unit ( const unit u,
bool  use_max_moves = true 
)
void pathfind::full_cost_map::add_unit ( const map_location origin,
const unit_type *const  ut,
int  side 
)

Adds a units cost map to cost_map (increments the elements in cost_map) This function can be used to generate a cost_map with a non existing unit.

Parameters
originthe location on the map from where the calculations shall start
utthe unit type we are interested in
sidethe side of the unit. Important for zocs.

Definition at line 907 of file pathfind.cpp.

References add_unit(), and unit::set_location().

double pathfind::full_cost_map::get_average_cost_at ( int  x,
int  y 
) const

Accessor for the costs.

Returns
The average cost of all added units for this hex or -1 if no unit can reach the hex.

Definition at line 953 of file pathfind.cpp.

References get_pair_at().

Referenced by ai::default_recruitment::recruitment::compare_cost_maps_and_update_important_hexes().

int pathfind::full_cost_map::get_cost_at ( int  x,
int  y 
) const

Accessor for the costs.

Returns
the value of the cost_map at (x, y) or -1 if value is not set or (x, y) is invalid.

Definition at line 942 of file pathfind.cpp.

References get_pair_at().

Referenced by ai::default_recruitment::recruitment::update_important_hexes().

std::pair< int, int > pathfind::full_cost_map::get_pair_at ( int  x,
int  y 
) const

Accessor for the cost/reach-amount pairs.

Read comment in pathfind.hpp to cost_map.

Returns
the entry of the cost_map at (x, y) or (-1, 0) if value is not set or (x, y) is invalid.

Definition at line 924 of file pathfind.cpp.

References cost_map, resources::gameboard, gamemap::h(), game_board::map(), and gamemap::w().

Referenced by get_average_cost_at(), get_cost_at(), and game_lua_kernel::intf_find_cost_map().

Member Data Documentation

const bool pathfind::full_cost_map::allow_teleport_
private

Definition at line 300 of file pathfind.hpp.

Referenced by add_unit().

std::vector<std::pair<int, int> > pathfind::full_cost_map::cost_map

Definition at line 296 of file pathfind.hpp.

Referenced by add_unit(), full_cost_map(), and get_pair_at().

const bool pathfind::full_cost_map::force_ignore_zoc_
private

Definition at line 299 of file pathfind.hpp.

Referenced by add_unit().

const bool pathfind::full_cost_map::ignore_units_
private

Definition at line 303 of file pathfind.hpp.

Referenced by add_unit().

const bool pathfind::full_cost_map::see_all_
private

Definition at line 302 of file pathfind.hpp.

Referenced by add_unit().

const team& pathfind::full_cost_map::viewing_team_
private

Definition at line 301 of file pathfind.hpp.

Referenced by add_unit().


The documentation for this struct was generated from the following files: