21#ifndef __PBeFS_ads_GridAdjacency
22 #define __PBeFS_ads_GridAdjacency
35#include "ADS/graph/GridGraph.h"
65 using cost_type = std::conditional_t< Moves == 4 , int , double >;
70 : f_w( map.width() ) ,
71 f_g( map.height() , map.width() , map.costs() ,
72 Moves == 4 ? ADS::GridMoves::FOUR : ADS::GridMoves::EIGHT ,
74 Moves == 4 ? std::optional<
cost_type >() :
76 ADS::MoveCost::LEFT ) {}
83 void for_each( std::uint32_t s ,
int x ,
int y , F && f )
const {
84 const int u = int( s ) , row = u - x;
85 f_g.forEachEdge( u , [ & ](
int v ,
cost_type c ) {
86 const int dy = v < row ? -1 : ( v >= row + f_w ? 1 : 0 );
87 f( std::uint32_t( v ) , v - u - dy * f_w + x , y + dy , c );
96 ADS::GridGraph< cost_type , std::uint8_t > f_g;
GridAdjacency(const GridMap &map)
constructor, copying the costs of the cells of the map
Definition GridAdjacency.h:69
std::conditional_t< Moves==4, int, double > cost_type
the cost of a move: an integer with 4 moves, a real with 8
Definition GridAdjacency.h:65
void for_each(std::uint32_t s, int x, int y, F &&f) const
calls f( t , x' , y' , c ) for each free cell t = ( x' , y' ) next to the free cell s = ( x ,...
Definition GridAdjacency.h:83
a rectangular map of cells, each with a cost of traversal
Definition Grid.h:73
namespace for the Parallel Best-First Search library
Definition AStar.h:83
constexpr double grid_sqrt2
, the cost of a diagonal move per unit of cost of a cell
Definition Grid.h:159