本文整理匯總了Python中horizons.ai.aiplayer.resourcemanager.ResourceManager.manager_buysell方法的典型用法代碼示例。如果您正苦於以下問題:Python ResourceManager.manager_buysell方法的具體用法?Python ResourceManager.manager_buysell怎麽用?Python ResourceManager.manager_buysell使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類horizons.ai.aiplayer.resourcemanager.ResourceManager
的用法示例。
在下文中一共展示了ResourceManager.manager_buysell方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: SettlementManager
# 需要導入模塊: from horizons.ai.aiplayer.resourcemanager import ResourceManager [as 別名]
# 或者: from horizons.ai.aiplayer.resourcemanager.ResourceManager import manager_buysell [as 別名]
#.........這裏部分代碼省略.........
def get_ideal_production_level(self, resource_id):
"""
Return the amount of resource per tick the settlement should produce.
This is the amount that should be produced to satisfy the people in this settlement,
keep up the current export rate, and fix the player's global deficit. This means
that different (feeder) islands will have different ideal production levels.
"""
total = 0.0
for settlement_manager in self.owner.settlement_managers:
usage = settlement_manager.get_resource_production_requirement(resource_id) * self.personality.production_level_multiplier
production = settlement_manager.get_resource_production(resource_id)
resource_import = settlement_manager.trade_manager.get_total_import(resource_id)
resource_export = settlement_manager.resource_manager.get_total_export(resource_id)
total += usage
if settlement_manager is not self:
total -= production + resource_export - resource_import
return max(0.0, total)
def _start_feeder_tick(self):
self.log.info('%s food requirement %.5f', self, self.get_ideal_production_level(RES.FOOD))
self.log.info('%s textile requirement %.5f', self, self.get_ideal_production_level(RES.TEXTILE))
self.log.info('%s liquor requirement %.5f', self, self.get_ideal_production_level(RES.LIQUOR))
self.log.info('%s salt requirement %.5f', self, self.get_ideal_production_level(RES.SALT))
self.log.info('%s tobacco products requirement %.5f', self, self.get_ideal_production_level(RES.TOBACCO_PRODUCTS))
self.production_builder.manage_production()
self.resource_manager.refresh()
def _end_feeder_tick(self):
self.resource_manager.replay_deep_low_priority_requests()
self.resource_manager.record_expected_exportable_production(self.owner.tick_interval)
self.resource_manager.manager_buysell()
self.resource_manager.finish_tick()
def _start_general_tick(self):
self.log.info('%s food production %.5f / %.5f', self, self.get_resource_production(RES.FOOD),
self.get_resource_production_requirement(RES.FOOD))
self.log.info('%s textile production %.5f / %.5f', self, self.get_resource_production(RES.TEXTILE),
self.get_resource_production_requirement(RES.TEXTILE))
self.log.info('%s get-together production %.5f / %.5f', self, self.get_resource_production(RES.GET_TOGETHER),
self.get_resource_production_requirement(RES.GET_TOGETHER))
self.log.info('%s salt production %.5f / %.5f', self, self.get_resource_production(RES.SALT),
self.get_resource_production_requirement(RES.SALT))
self.log.info('%s tobacco products production %.5f / %.5f', self, self.get_resource_production(RES.TOBACCO_PRODUCTS),
self.get_resource_production_requirement(RES.TOBACCO_PRODUCTS))
self.production_builder.manage_production()
self.trade_manager.refresh()
self.resource_manager.refresh()
self.need_materials = False
def refresh_taxes_and_upgrade_permissions(self):
# TODO: use a better system for managing settler upgrades and taxes
if self.land_manager.owner.settler_level == 0:
# if we are on level 0 and there is a house that can be upgraded then do it.
if self._manual_upgrade(0, 1):
self._set_taxes_and_permissions_prefix('early')
elif self.get_resource_production(RES.BRICKS) > 1e-9 and not self.settlement.count_buildings(BUILDINGS.VILLAGE_SCHOOL):
# if we just need the school then upgrade sailors manually
free_boards = self.settlement.get_component(StorageComponent).inventory[RES.BOARDS]
free_boards -= Entities.buildings[BUILDINGS.VILLAGE_SCHOOL].costs[RES.BOARDS]
free_boards /= 2 # TODO: load this from upgrade resources
if free_boards > 0:
self._manual_upgrade(0, free_boards)
self._set_taxes_and_permissions_prefix('no_school')