Package horizons :: Package ai :: Package aiplayer :: Package building :: Class AbstractBuilding
[hide private]
[frames] | no frames]

Class AbstractBuilding

source code

An object of this class tells the AI how to build a specific type of building.

Instances of the subclasses are used by production chains to discover the set of buildings necessary to produce the right amount of resources.

Instance Methods [hide private]
 
__init__(self, building_id, name, settler_level) source code
 
__init_production_lines(self) source code
 
_get_producer_building(self) source code
 
get_expected_building_cost(self)
Return a value representing the utility cost of building the building.
source code
 
get_expected_cost(self, resource_id, production_needed, settlement_manager)
Return a value representing the utility cost of building enough buildings to produced the given amount of resource per tick.
source code
 
get_expected_production_level(self, resource_id)
Return the expected production capacity of a single building of this type producing the given resource.
source code
 
get_production_level(self, building, resource_id)
Return the actual production capacity of a single building of this type producing the given resource.
source code
 
have_resources(self, settlement_manager)
Return a boolean showing whether the given settlement has enough resources to build a building of this type.
source code
 
iter_potential_locations(self, settlement_manager)
Iterate over possible locations of the building in the given settlement in the form of (x, y, orientation).
source code
 
evaluator_class(self)
Return the relevant BuildingEvaluator subclass.
source code
 
directly_buildable(self)
Return a boolean showing whether the build function of this subclass can be used to build a building of this type.
source code
 
coverage_building(self)
Return a boolean showing whether buildings of this type may need to be built even when the production capacity has been reached.
source code
 
ignore_production(self)
Return a boolean showing whether instances of this building can be used to calculate the production capacity.
source code
 
producer_building(self)
Return a boolean showing whether this building is supposed to have usable production lines.
source code
 
get_evaluators(self, settlement_manager, resource_id)
Return a list of every BuildingEvaluator for this building type in the given settlement.
source code
 
build(self, settlement_manager, resource_id)
Try to build the best possible instance of this building in the given settlement.
source code
 
need_to_build_more_buildings(self, settlement_manager, resource_id)
Return a boolean showing whether another instance of the building should be built right now regardless of the production capacity.
source code
Class Methods [hide private]
 
load_all(cls, db)
Fill the cls.buildings dict so the registered buildings can be used.
source code
 
_load_name(cls, db, building_id) source code
 
_load_settler_level(cls, building_id) source code
 
load(cls, db, building_id) source code
 
_get_buildability_intersection(cls, settlement_manager, size, terrain_type, need_collector_connection) source code
Class Variables [hide private]
  log = logging.getLogger("ai.aiplayer.building")
  __loaded = False
  buildings = {}
  _available_buildings = {}
  monthly_gold_cost = 50
  resource_cost = {RES.GOLD: 1, RES.BOARDS: 20, RES.BRICKS: 45, ...
Method Details [hide private]

evaluator_class(self)

source code 

Return the relevant BuildingEvaluator subclass.

Decorators:
  • @property

directly_buildable(self)

source code 

Return a boolean showing whether the build function of this subclass can be used to build a building of this type.

Decorators:
  • @property

coverage_building(self)

source code 

Return a boolean showing whether buildings of this type may need to be built even when the production capacity has been reached.

Decorators:
  • @property

ignore_production(self)

source code 

Return a boolean showing whether instances of this building can be used to calculate the production capacity.

Decorators:
  • @property

producer_building(self)

source code 

Return a boolean showing whether this building is supposed to have usable production lines.

Decorators:
  • @property

build(self, settlement_manager, resource_id)

source code 

Try to build the best possible instance of this building in the given settlement. Returns (BUILD_RESULT constant, building instance).


Class Variable Details [hide private]

resource_cost

Value:
{RES.GOLD: 1, RES.BOARDS: 20, RES.BRICKS: 45, RES.TOOLS: 50}