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 ¤t_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 std::pair<std::set<map_location>, std::set<map_location> > pathfind::teleport_pair |
Definition at line 28 of file teleport.hpp.
Enumerator | |
---|---|
VACANT_CASTLE | |
VACANT_ANY |
Definition at line 39 of file pathfind.hpp.
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 | ||
) |
Definition at line 144 of file astarsearch.cpp.
References pathfind::cost_calculator::cost(), DBG_PF, pathfind::teleport_map::empty(), gui2::event::find(), get_adjacent_tiles(), pathfind::teleport_map::get_adjacents(), pathfind::cost_calculator::getNoPathValue(), if(), int(), LOG_PF, pathfind::plain_route::move_cost, next, nodes, map_location::null_location(), pathfind::plain_route::steps, schema_validation::valid, and map_location::valid().
Referenced by ai::ai_default_rca::move_to_targets_phase::access_points(), wb::move::calculate_new_route(), game_state::can_recruit_on(), ai::ai_default_rca::move_to_targets_phase::choose_move(), default_map_generator_job::default_generate_map(), ai::ai_default_rca::goto_phase::evaluate(), ai::ai_default_rca::move_leader_to_goals_phase::evaluate(), ai::ai_default_rca::move_leader_to_keep_phase::evaluate(), events::mouse_handler::get_route(), intf_find_path(), game_lua_kernel::intf_find_path(), cave_map_generator::cave_map_generator_job::place_passage(), ai::formula_ai::shortest_path_calculator(), and ai::move_result::test_route().
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.
current_team | The moving team (only ZoC of enemies of this team are considered). |
loc | The location to check. |
viewing_team | Only units visible to this team are considered. |
see_all | If true, all units are considered (and viewing_team is ignored). |
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 |
Creates a list of routes that a unit can traverse from the provided location.
(This is called when creating pathfind::paths and descendant classes.)
[in] | origin | The location at which to begin the routes. |
[in] | costs | The costs to use for route finding. |
[in] | slowed | Whether or not to use the slowed costs. |
[in] | moves_left | The number of movement points left for the current turn. |
[in] | max_moves | The number of movement points in each future turn. |
[in] | turns_left | The number of future turns of movement to calculate. |
[out] | destinations | The traversable routes. |
[out] | edges | The hexes (possibly off-map) adjacent to those in destinations. (It is permissible for this to contain some hexes that are also in destinations.) |
[in] | teleporter | If not nullptr, teleportaion will be considered, using this unit's abilities. |
[in] | current_team | If 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] | skirmisher | If 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_team | If 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_map | The relevant "jamming" of the costs being used (currently only used with vision costs). |
[out] | full_cost_map | If 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 | ||
) |
Definition at line 233 of file teleport.cpp.
References pathfind::manager::get(), unit::get_abilities(), unit::get_ability_bool(), i, and resources::tunnels.
Referenced by ai::ai_default_rca::move_to_targets_phase::access_points(), ai::ai_default_rca::move_to_targets_phase::choose_move(), ai::ai_default_rca::goto_phase::evaluate(), ai::ai_default_rca::move_leader_to_keep_phase::evaluate(), find_routes(), ai::formula_ai::get_allowed_teleports(), events::mouse_handler::get_route(), game_lua_kernel::intf_find_path(), and ai::move_result::test_route().
|
static |
Definition at line 461 of file pathfind.cpp.
Referenced by pathfind::paths::dest_vect::find(), pathfind::paths::dest_vect::insert(), and metrics::record_sample().
marked_route pathfind::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.
Definition at line 632 of file pathfind.cpp.
References enemy_zoc(), unit_map::find(), team::fogged(), resources::gameboard, unit::get_ability_bool(), i, unit::invisible(), team::is_enemy(), gamemap::is_village(), game_board::map(), pathfind::marked_route::marks, unit::movement_cost(), unit::movement_left(), team::owns_village(), pathfind::marked_route::route, resources::screen, unit::side(), pathfind::plain_route::steps, unit::total_movement(), preferences::turns(), resources::units, and display::viewing_team().
Referenced by wb::move::calculate_new_route(), wb::move::check_validity(), and events::mouse_handler::get_route().