PBeFS
Parallel Best-First Search
Loading...
Searching...
No Matches
GridMap Class Reference

a rectangular map of cells, each with a cost of traversal More...

#include <PBeFS/astar/Grid.h>

Public Member Functions

 GridMap (int width=0, int height=0)
 constructor of a map of width by height free cells of cost 1
int width (void) const noexcept
 the number of columns
int height (void) const noexcept
 the number of rows
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)
const std::vector< std::uint8_t > & costs (void) const noexcept
 the costs of the cells, row by row

Static Public Member 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
static GridMap read_movingai (std::istream &in)
 reads a map in the format of the benchmarks of Sturtevant (2012)

Detailed Description

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.

Constructor & Destructor Documentation

◆ GridMap()

GridMap ( int width = 0,
int height = 0 )

constructor of a map of width by height free cells of cost 1

Member Function Documentation

◆ cost()

int cost ( int x,
int y ) const
inlinenodiscardnoexcept

the cost of the cell ( x , y ), 0 if blocked or outside the map

◆ costs()

const std::vector< std::uint8_t > & costs ( void ) const
inlinenodiscardnoexcept

the costs of the cells, row by row

◆ height()

int height ( void ) const
inlinenodiscardnoexcept

the number of rows

◆ min_cost()

int min_cost ( void ) const
nodiscardnoexcept

the smallest cost of a free cell (1 if there is none)

◆ random()

GridMap random ( int width,
int height,
double p,
std::uint64_t seed,
int max_cost = 1 )
staticnodiscard

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 if max_cost is 1, as in those instances, and otherwise a cost drawn uniformly in \( \{ 1 , \ldots , c_{\max} \} \), \( c_{\max} \leq 255 \) being max_cost, the cells being drawn row by row.

◆ read_movingai()

GridMap read_movingai ( std::istream & in)
staticnodiscard

reads a map in the format of the benchmarks of Sturtevant (2012)

Reads from in a 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.

◆ set_cost()

void set_cost ( int x,
int y,
int c )

sets the cost of the cell ( x , y ) to c, in \( \{ 0 , \ldots , 255 \} \)

◆ width()

int width ( void ) const
inlinenodiscardnoexcept

the number of columns


The documentation for this class was generated from the following file: