pathfind.hpp File Reference

#include "array.hpp"
#include "map.hpp"
#include "pathutils.hpp"
#include "team.hpp"
#include <map>
#include <list>
#include <set>
#include <vector>
#include <functional>

Include dependency graph for pathfind.hpp:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  xy_pred
struct  cost_calculator
struct  paths
 Object which contains all the possible locations a unit can move to, with associated best routes to those locations. More...
struct  paths::route
 Structure which holds a single route between one location and another. More...
struct  paths::route::waypoint
struct  shortest_path_calculator
struct  emergency_path_calculator
 Function which only uses terrain, ignoring shroud, enemies, etc. More...

Typedefs

typedef util::array
< gamemap::location, 6 > 
adjacent_tiles_array
 A convenient type for storing a list of tiles adjacent to a certain tile.

Enumerations

enum  VACANT_TILE_TYPE { VACANT_CASTLE, VACANT_ANY }

Functions

void get_tiles_radius (const gamemap::location &a, size_t radius, std::set< gamemap::location > &res)
 Function which, given a location, will find all tiles within 'radius' of that tile.
void get_tiles_radius (const gamemap &map, const std::vector< gamemap::location > &locs, size_t radius, std::set< gamemap::location > &res, xy_pred *pred=NULL)
 Function which, given a set of locations, will find all tiles within 'radius' of those tiles.
gamemap::location find_vacant_tile (const gamemap &map, const unit_map &un, const gamemap::location &loc, VACANT_TILE_TYPE vacancy=VACANT_ANY)
 Function which will find a location on the board that is as near to loc as possible, but which is unoccupied by any units.
bool enemy_zoc (gamemap const &map, unit_map const &units, std::vector< team > const &teams, gamemap::location const &loc, team const &viewing_team, unsigned int side, bool see_all=false)
 Function which determines if a given location is in an enemy zone of control.
paths::route a_star_search (gamemap::location const &src, gamemap::location const &dst, double stop_at, cost_calculator const *costCalculator, const size_t parWidth, const size_t parHeight, std::set< gamemap::location > const *teleports=NULL)
int route_turns_to_complete (const unit &u, paths::route &rt, const team &viewing_team, const unit_map &units, const std::vector< team > &teams, const gamemap &map)
 Function which, given a unit and a route the unit can move on, will return the number of turns it will take the unit to traverse the route.


Detailed Description

Definition in file pathfind.hpp.


Typedef Documentation

A convenient type for storing a list of tiles adjacent to a certain tile.

Definition at line 23 of file pathfind.hpp.


Enumeration Type Documentation

Enumerator:
VACANT_CASTLE 
VACANT_ANY 

Definition at line 57 of file pathfind.hpp.


Function Documentation

paths::route a_star_search ( gamemap::location const &  src,
gamemap::location const &  dst,
double  stop_at,
cost_calculator const *  costCalculator,
const size_t  parWidth,
const size_t  parHeight,
std::set< gamemap::location > const *  teleports = NULL 
)

bool enemy_zoc ( gamemap const &  map,
unit_map const &  units,
std::vector< team > const &  teams,
gamemap::location const &  loc,
team const &  viewing_team,
unsigned int  side,
bool  see_all = false 
)

Function which determines if a given location is in an enemy zone of control.

Definition at line 84 of file pathfind.cpp.

References unit_map::end(), find_visible_unit(), get_adjacent_tiles(), and team::is_enemy().

Referenced by shortest_path_calculator::cost(), find_routes(), move_unit(), and route_turns_to_complete().

gamemap::location find_vacant_tile ( const gamemap map,
const unit_map un,
const gamemap::location loc,
VACANT_TILE_TYPE  vacancy = VACANT_ANY 
)

Function which will find a location on the board that is as near to loc as possible, but which is unoccupied by any units.

If terrain is not 0, then the location found must be of the given terrain type, and must have a path of that terrain type to loc. If no valid location can be found, it will return a null location.

Definition at line 69 of file pathfind.cpp.

References find_vacant(), and gamemap::on_board().

Referenced by recruit_unit().

void get_tiles_radius ( const gamemap map,
const std::vector< gamemap::location > &  locs,
size_t  radius,
std::set< gamemap::location > &  res,
xy_pred pred = NULL 
)

Function which, given a set of locations, will find all tiles within 'radius' of those tiles.

Definition at line 245 of file astarsearch.cpp.

References get_adjacent_tiles(), loc, and gamemap::on_board().

void get_tiles_radius ( const gamemap::location a,
size_t  radius,
std::set< gamemap::location > &  res 
)

Function which, given a location, will find all tiles within 'radius' of that tile.

Definition at line 238 of file astarsearch.cpp.

References get_tiles_radius_internal().

Referenced by terrain_filter::get_locations(), terrain_filter::match(), and place_village().

int route_turns_to_complete ( const unit u,
paths::route rt,
const team viewing_team,
const unit_map units,
const std::vector< team > &  teams,
const gamemap map 
)

Function which, given a unit and a route the unit can move on, will return the number of turns it will take the unit to traverse the route.

adds "turn waypoints" to rt.turn_waypoints. Note that "end of path" is also added.

Definition at line 228 of file pathfind.cpp.

References enemy_zoc(), team::fogged(), unit::get_ability_bool(), unit::invisible(), team::is_enemy(), gamemap::is_village(), unit::movement_cost(), unit::movement_left(), gamemap::on_board(), team::owns_village(), unit::side(), paths::route::steps, unit::total_movement(), preferences::turns(), and paths::route::waypoints.

Referenced by events::mouse_handler::get_route().


Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs