Package horizons :: Package world :: Package buildability :: Module potentialroadconnectivitycache :: Class PotentialRoadConnectivityCache
[hide private]
[frames] | no frames]

Class PotentialRoadConnectivityCache

source code

Query whether a toad connection between two sets of coordinates is possible.

This class is used by the AI to figure out whether it might be possible to build a road between two sets of coordinates. Potentially because the area contains some part of the AI's plan and the land it has a plan for may be either owned by the AI or not yet owned by anyone.

Instance Methods [hide private]
 
__init__(self, area_builder) source code
 
modify_area(self, coords_list)
Refresh the usability of the coordinates in the given list.
source code
 
is_connection_possible(self, coords_set1, coords_set2)
Return True if and only if it is possible to connect the two coordinate sets.
source code
Method Details [hide private]

modify_area(self, coords_list)

source code 

Refresh the usability of the coordinates in the given list.

This function is called with a list of coordinates on which the possibility of building a road may have changed. It figures out whether it is possible to build a road on (x, y) and updates the underlying ConnectedAreaCache accordingly.

is_connection_possible(self, coords_set1, coords_set2)

source code 

Return True if and only if it is possible to connect the two coordinate sets.

More specifically, it returns True if and only if it is possible to build a toad from some (x1, y1) in coords_set1 to some (x2, y2) in coords_set2 entirely within the area. This is done cheaply using the underlying ConnectedAreaCache.