Module astar_offset

Module astar_offset 

Source
Expand description

A-Star pathfinding algorithm for an Offset grid alignment.

§Hexagon Layout/Orientation

Each node has a label defining its position, known as (column, row). The A-Star calculation requires an orientation parameter which specifies what type of Offset layout you are using, these are found in the enum HexOrientation.

§Flat Topped - odd columns shifted up HexOrientation::FlatTopOddUp

             _______
            /       \
    _______/  (1,1)  \_______
   /       \         /       \
  /  (0,1)  \_______/  (2,1)  \
  \         /       \         /
   \_______/  (1,0)  \_______/
   /       \         /       \
  /  (0,0)  \_______/  (2,0)  \
  \         /       \         /
   \_______/         \_______/

§Flat Topped - odd columns shifted down HexOrientation::FlatTopOddDown

    _______           _______
   /       \         /       \
  /  (0,1)  \_______/  (2,1)  \
  \         /       \         /
   \_______/  (1,1)  \_______/
   /       \         /       \
  /  (0,0)  \_______/  (2,0)  \
  \         /       \         /
   \_______/  (1,0)  \_______/
           \         /
            \_______/

Functions§

astar_path
From a starting node calculate the most efficient path to the end node