Package horizons :: Package util :: Package pathfinding :: Module pathfinder
[hide private]
[frames] | no frames]

Module pathfinder

source code

Functions [hide private]
 
is_preferred_turn(previous_coords, current_coords, next_coords, clockwise)
Returns True if and only if the turn is in the preferred direction.
source code
 
a_star_find_path(source, destination, nodes, clockwise=True)
Finds the shortest path that should be most preferred by human players.
source code
Variables [hide private]
  COUNTERCLOCKWISE_TURNS = [((0, 0), (0, 1)), ((0, 1), (1, 1)), ...
  __package__ = 'horizons.util.pathfinding'
Function Details [hide private]

a_star_find_path(source, destination, nodes, clockwise=True)

source code 

Finds the shortest path that should be most preferred by human players.

Return the path from the source to the destination or None if it is impossible.

Parameters:
  • source - (x, y)
  • destination - (x, y)
  • nodes - object that provides __contains__ (dict, list) with items (x, y)
  • clockwise - bool; whether to try finding the path clockwise or counterclockwise

Variables Details [hide private]

COUNTERCLOCKWISE_TURNS

Value:
[((0, 0), (0, 1)),
 ((0, 1), (1, 1)),
 ((1, 0), (0, 0)),
 ((1, 1), (1, 0))]