Package horizons :: Package ai :: Package aiplayer :: Module landmanager :: Class LandManager
[hide private]
[frames] | no frames]

Class LandManager

source code

util.changelistener.ChangeListener --+    
                                     |    
          util.worldobject.WorldObject --+
                                         |
                                        LandManager

Divides and manages the division of the land of one island.

The idea is that the LandManager object divides the land of the island between different purposes (currently the production area and on non-feeder islands the village area) and from that point on the different area managers are limited to that land unless they decide to give some of it up (currently happens with the village area).

Nested Classes [hide private]
  purpose
Instance Methods [hide private]
 
__init__(self, island, owner, feeder_island) source code
 
__init(self, island, owner, feeder_island) source code
 
save(self, db) source code
 
_load(self, db, owner, worldid) source code
 
_get_coastline(self) source code
 
refresh_resource_deposits(self) source code
 
_divide_island(self)
Divide the whole island between the purposes.
source code
 
coords_usable(self, coords, use_coast=False)
Return a boolean showing whether the land on the given coordinate is usable for a normal building.
source code
 
legal_for_production(self, rect)
Return a boolean showing whether every tile in the Rect is either in the production area or on the coast.
source code
 
_get_usability_map(self, extra_space)
Return a tuple describing the usability of the island.
source code
 
_divide(self, side1, side2)
Divide the total land area between different purposes trying to achieve a side1 x side2 rectangle for the village.
source code
 
_prepare_feeder_island(self)
Assign all the usable land of the island to the production area.
source code
 
add_to_production(self, coords)
Assign a current village tile to the production area.
source code
 
handle_lost_area(self, coords_list)
Handle losing the potential land in the given coordinates list.
source code
 
display(self)
Show the plan on the map unless it is disabled in the settings.
source code
 
__str__(self) source code
    Inherited from util.worldobject.WorldObject
 
__lt__(self, other) source code
 
remove(self) source code
    Inherited from util.changelistener.ChangeListener
 
_changed(self)
Calls every listener when an object changed
source code
 
add_change_listener(self, listener, call_listener_now=False, no_duplicates=False) source code
 
add_remove_listener(self, listener, no_duplicates=False)
A listener that listens for removal of the object
source code
 
clear_change_listeners(self)
Removes all change listeners
source code
 
discard_change_listener(self, listener)
Remove listener if it's there
source code
 
discard_remove_listener(self, listener) source code
 
end(self) source code
 
has_change_listener(self, listener) source code
 
has_remove_listener(self, listener) source code
 
remove_change_listener(self, listener) source code
 
remove_remove_listener(self, listener) source code
Class Methods [hide private]
 
load(cls, db, owner, worldid) source code
    Inherited from util.worldobject.WorldObject
 
get_object_by_id(cls, id)
Returns the worldobject with id id Throws WorldObjectNotFound with the worldid as arg.
source code
 
get_objs(cls) source code
 
reset(cls) source code
Class Variables [hide private]
  log = logging.getLogger("ai.aiplayer.land_manager")
Method Details [hide private]

__init__(self, island, owner, feeder_island)
(Constructor)

source code 
Parameters:
  • island - Island instance
  • owner - AIPlayer instance
  • feeder_island - boolean showing whether this is a feeder island (no village area)
Overrides: util.changelistener.ChangeListener.__init__

save(self, db)

source code 
Overrides: util.worldobject.WorldObject.save

load(cls, db, owner, worldid)
Class Method

source code 
Overrides: util.changelistener.ChangeListener.load

_divide_island(self)

source code 

Divide the whole island between the purposes. The proportions depend on the personality.

_get_usability_map(self, extra_space)

source code 

Return a tuple describing the usability of the island.

The return format is ({x, y): usable, ..}, min_x - extra_space, max_x, min_y - extra_space, max_y) where the dict contains ever key for x in [min_x, max_x] and y in [min_y, max_y] and the usability value says whether we can use that part of the land for normal buildings.