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, int > | get_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 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 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().
|
inlinevirtual |
Definition at line 285 of file pathfind.hpp.
Adds a units cost map to cost_map (increments the elements in cost_map)
u | a real existing unit on the map |
Definition at line 879 of file pathfind.cpp.
References allow_teleport_, cost_map, pathfind::find_routes(), force_ignore_zoc_, unit::get_location(), movetype::get_movement(), unit::get_state(), ignore_units_, int(), unit::movement_left(), unit::movement_type(), see_all_, unit::side(), unit::STATE_SLOWED, resources::teams, teams, 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().
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 907 of file pathfind.cpp.
References add_unit(), and unit::set_location().
Accessor for the costs.
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().
Accessor for the costs.
Definition at line 942 of file pathfind.cpp.
References get_pair_at().
Referenced by ai::default_recruitment::recruitment::update_important_hexes().
Accessor for the cost/reach-amount pairs.
Read comment in pathfind.hpp to cost_map.
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().
|
private |
Definition at line 300 of file pathfind.hpp.
Referenced by add_unit().
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().