GridMap
Declared in astar/Grid.h; the same class on the site of Doxygen.
-
class GridMap
a rectangular map of cells, each with a cost of traversal
The cell \( ( x , y ) \), with \( 0 \leq x < W \) and \( 0 \leq y < H \) for the width \( W \) and the height \( H \) of the map, has the index \( y W + x \) and the cost cost( x , y ) in \( \{ 1 , \ldots , 255 \} \), or 0 if it is blocked.
Public Functions
-
GridMap(int width = 0, int height = 0)
constructor of a map of width by height free cells of cost 1
-
inline int width(void) const noexcept
the number of columns
-
inline int height(void) const noexcept
the number of rows
-
inline int cost(int x, int y) const noexcept
the cost of the cell ( x , y ), 0 if blocked or outside the map
-
void set_cost(int x, int y, int c)
sets the cost of the cell ( x , y ) to c, in \( \{ 0 , \ldots , 255 \} \)
-
int min_cost(void) const noexcept
the smallest cost of a free cell (1 if there is none)
-
inline const std::vector<std::uint8_t> &costs(void) const noexcept
the costs of the cells, row by row
Public Static Functions
-
static GridMap random(int width, int height, double p, std::uint64_t seed, int max_cost = 1)
a random map with blocked cells of probability p
Returns a map of \( \mathrm{width} \times \mathrm{height} \) cells in which each cell is blocked with probability
p, except the bottom-left and the bottom-right corners, which are the start and the goal of the pathfinding instances of Burns et al. (JAIR 2010) and cost 1. A free cell costs 1 ifmax_costis 1, as in those instances, and otherwise a cost drawn uniformly in \( \{ 1 , \ldots , c_{\max} \} \), \( c_{\max} \leq 255 \) beingmax_cost, the cells being drawn row by row.
-
static GridMap read_movingai(std::istream &in)
reads a map in the format of the benchmarks of Sturtevant (2012)
Reads from
ina map of the Moving AI Lab benchmarks: the header “type octile”, “height H”, “width W”, “map”, then H lines of W characters, ‘.’, ‘G’ and ‘S’ being free cells of cost 1, any other one being blocked. Throws std::invalid_argument if the map is malformed.
-
GridMap(int width = 0, int height = 0)