Package horizons :: Package ai :: Package aiplayer :: Module roadplanner :: Class RoadPlanner
[hide private]
[frames] | no frames]

Class RoadPlanner

source code

Finds the most reasonable road between two areas.

This class uses the A* algorithm to find a path that would look nice as a road. Penalties are give for the following: * not an existing road * close to an existing road * not straight * not close to boundaries (coast, mountains, etc.)

Instance Methods [hide private]
 
__call__(self, personality, source, destination, destination_beacon, path_nodes, blocked_coords=None)
Return the path from the source to the destination or None if it is impossible.
source code
Method Details [hide private]

__call__(self, personality, source, destination, destination_beacon, path_nodes, blocked_coords=None)
(Call operator)

source code 

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

Parameters:
  • personality - the personality class that contains the relevant personality bits
  • source - list of tuples [(x, y), ...]
  • destination - list of tuples [(x, y), ...]
  • destination_beacon - object with a defined distance_to_tuple function (must contain all of destination)
  • path_nodes - dict {(x, y): penalty}
  • blocked_coords - temporarily blocked coordinates set([(x, y), ...])