directors.h

libPathFinder / Docs / Headers / 

directors.h

Directors are objects that finds coordinates adjecent to one-another.

Three templates are defined with movements, so far:

  • grid_4_directions, allows movement in 4 directions: NORTH, SOUTH, EAST and WEST.

  • grid_8_directions, the standard director for astar::map. Adds NORTH_EAST, NORTH_WEST, SOUTH_EAST and SOUTH_WEST to the grid_4_directions.

  • chess_piece_horse, moves like a horse piece in a chess game.

All these templates takes as a parameter, the coordinate type used.

The cool thing about using a template typename to define how to find adjecent coordinates is that we should be able to use the same A-star algorithm with e.g.:

  • hex_6_directions, path-finding in a hexagon world.

  • chess_piece_?, path-finding for some other type of chess piece.

The template only needs to define one method:

std::vector < coordinate < coord_type > > adjecent ( coord_type x, coord_type y );

And a constructor that takes the map-borders as parameters:

grid_8_direction ( coord_type origin_x, coord_type origin_y, coord_type size_x, coord_type size_y );

A director can inherit from director_base < coord_type >, to be a bit easier to define.

See code and Directors for more details.