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 (map_location loc) const |
Accessor for the costs. More... | |
std::pair< int, int > | get_pair_at (map_location loc) const |
Accessor for the cost/reach-amount pairs. More... | |
double | get_average_cost_at (map_location loc) 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 team & | viewing_team_ |
const bool | see_all_ |
const bool | ignore_units_ |
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.
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.
u | the unit |
force_ignore_zoc | Set to true to completely ignore zones of control. |
allow_teleport | Set to true to consider teleportation abilities. |
viewing_team | Usually the current team, except for "show enemy moves", etc. |
see_all | Set to true to remove unit visibility from consideration. |
ignore_units | Set to true if units should never obstruct paths (implies ignoring ZoC as well). |
Definition at line 889 of file pathfind.cpp.
References add_unit(), cost_map, resources::gameboard, gamemap_base::h(), game_board::map(), and gamemap_base::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 904 of file pathfind.cpp.
References cost_map, resources::gameboard, gamemap_base::h(), game_board::map(), and gamemap_base::w().
|
inlinevirtual |
Definition at line 285 of file pathfind.hpp.
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.
origin | the location on the map from where the calculations shall start |
ut | the unit type we are interested in |
side | the side of the unit. Important for zocs. |
Definition at line 953 of file pathfind.cpp.
References add_unit(), and unit::create().
void pathfind::full_cost_map::add_unit | ( | const unit & | u, |
bool | use_max_moves = true |
||
) |
Adds a units cost map to cost_map (increments the elements in cost_map)
u | a real existing unit on the map |
use_max_moves | whether to use the unit's max movement or the unit's remaining movement |
Definition at line 919 of file pathfind.cpp.
References allow_teleport_, cost_map, dummy, pathfind::find_routes(), force_ignore_zoc_, resources::gameboard, unit::get_location(), movetype::get_movement(), unit::get_state(), game_board::get_team(), ignore_units_, unit::movement_left(), unit::movement_type(), see_all_, unit::STATE_SLOWED, unit::total_movement(), and viewing_team_.
Referenced by add_unit(), full_cost_map(), ai::default_recruitment::recruitment::get_cost_map_of_side(), and game_lua_kernel::intf_find_cost_map().
double pathfind::full_cost_map::get_average_cost_at | ( | map_location | loc | ) | const |
Accessor for the costs.
Definition at line 999 of file pathfind.cpp.
References get_pair_at(), and p.
Referenced by ai::default_recruitment::recruitment::compare_cost_maps_and_update_important_hexes().
int pathfind::full_cost_map::get_cost_at | ( | map_location | loc | ) | const |
Accessor for the costs.
Definition at line 988 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 | ( | map_location | loc | ) | const |
Accessor for the cost/reach-amount pairs.
Read comment in pathfind.hpp to cost_map.
Definition at line 970 of file pathfind.cpp.
References cost_map, resources::gameboard, gamemap_base::h(), game_board::map(), gamemap_base::on_board(), gamemap_base::w(), map_location::x, and map_location::y.
Referenced by get_average_cost_at(), get_cost_at(), and game_lua_kernel::intf_find_cost_map().
|
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().
|
private |
Definition at line 299 of file pathfind.hpp.
Referenced by add_unit().
|
private |
Definition at line 303 of file pathfind.hpp.
Referenced by add_unit().
|
private |
Definition at line 302 of file pathfind.hpp.
Referenced by add_unit().
|
private |
Definition at line 301 of file pathfind.hpp.
Referenced by add_unit().