pyhexlib.hexagons module

class pyhexlib.hexagons.HexagonalGrid(hexagons)[source]

Bases: object

Parameters:

hexagons (List[Hexagon])

property axial_coordinates
property bounds: Bounds
static get_direction(start, end)[source]

Returns the direction from start to end as one of the constants NORTH, NORTHEAST, etc. If end is not a direct neighbor of start, returns None.

Parameters:
Return type:

Direction

get_direction_(rc1, rc2)[source]

Returns the direction from rc1 to rc2 as one of the constants NORTH, NORTHEAST, etc. If rc2 is not a direct neighbor of rc1, return the approximate direction (closest of the six). If rc1 == rc2, returns None.

Parameters:
Return type:

Direction

get_distance(rc1, rc2)[source]
Parameters:
Return type:

int

get_neighborhood(rc, max_cost, cost_fn=None, dist=1)[source]
Parameters:
  • rc (Hexagon)

  • max_cost (int)

  • dist (int)

Return type:

Neighborhood

neighbors(rc, dist=1, max_cost=None, cost_fn=None)[source]
Parameters:
  • rc (Hexagon)

  • dist (int)

  • max_cost (int | None)

Return type:

List[Hexagon]

path(rc, goal, cost_fn=None)[source]
Parameters:
Return type:

List[Hexagon]

property size: tuple[int, int]
pyhexlib.hexagons.rectangle_map(rows, cols)[source]
Parameters:
  • rows (int)

  • cols (int)

Return type:

List[Hexagon]