Package horizons :: Package ai :: Package aiplayer :: Module productionchain :: Class ProductionChain
[hide private]
[frames] | no frames]

Class ProductionChain

source code

A production chain handles the building of buildings required to produce a resource.

Production chains use the list of production lines and the available AbstractBuilding subclasses to figure out all ways of producing a certain resource and finding the right ratio of them to produce just enough of the resource. The result is a tree that can be used to produce the required resource.

Each subtree reserves a portion of the total capacity of the buildings of the relevant type. This is a logical classification and doesn't affect the actual buildings in any way. Some subtrees can import the required resource from other islands using a mechanism similar to the previous one but in that case it acts as if the resource was produced without any subtrees. The imported amounts are added up over time and saved as an owed resource in the exporting settlement's resource manager (these restrictions are again just logical without affecting the way the settlements work in any way). That storage is realized by organizing DomesticTrade missions that transfer the resources to the right settlements.

Instance Methods [hide private]
 
__init__(self, settlement_manager, resource_id, resource_producer) source code
 
_get_chain(self, resource_id, resource_producer, production_ratio)
Return a ProductionChainSubtreeChoice if it is possible to produce the resource, None otherwise.
source code
 
__str__(self) source code
 
build(self, amount)
Build a building that gets it closer to producing at least the given amount of resource per tick.
source code
 
reserve(self, amount, may_import)
Reserve currently available production capacity and import from other islands if allowed.
source code
 
need_to_build_more_buildings(self, amount)
Return a boolean showing whether more buildings need to be built in order to produce at least amount of resource per tick.
source code
 
get_final_production_level(self)
Return the production level per tick at the bottleneck.
source code
 
get_ratio(self, resource_id)
Return the ratio of the given resource needed given that 1 unit of the root resource is required.
source code
Class Methods [hide private]
 
create(cls, settlement_manager, resource_id)
Create a production chain that can produce the given resource.
source code
Class Variables [hide private]
  log = logging.getLogger("ai.aiplayer.productionchain")