Package horizons :: Package ai :: Package aiplayer :: Module buildingevaluator :: Class BuildingEvaluator
[hide private]
[frames] | no frames]

Class BuildingEvaluator

source code

Class representing a set of instructions for building a building complex along with its value.

Instance Methods [hide private]
 
__init__(self, area_builder, builder, value) source code
 
purpose(self)
Return the BUILDING_PURPOSE constant relevant to the builder.
source code
 
have_resources(self)
Return None if the builder is unreachable by road, False if there are not enough resources, and True otherwise.
source code
 
_register_builder_position(self) source code
 
execute(self)
Build the specified building complex.
source code
 
__str__(self) source code
Class Methods [hide private]
 
_weighted_distance(cls, main_component, other_components, none_value)
Return the weights sum of the component distances with the specified weights.
source code
 
_distance_to_nearest_building(cls, area_builder, builder, building_id)
Return the shortest distance to a building of type building_id that is in range of the builder.
source code
 
_distance_to_nearest_collector(cls, production_builder, builder, must_be_in_range=True)
Return the shortest distance to a collector that (usually) has to be in range of the builder.
source code
 
_get_outline_coords_list(cls, coords_list)
Return the list of coordinates that share sides the given coordinates list.
source code
 
_get_alignment_from_outline(cls, area_builder, outline_coords_list)
Return an alignment value given the list of coordinates that form the outline of a shape.
source code
 
_get_alignment(cls, area_builder, coords_list)
Return an alignment value based on the outline of the given coordinates list.
source code
 
get_best_evaluator(cls, evaluators) source code
Class Variables [hide private]
  log = logging.getLogger("ai.aiplayer.buildingevaluator")
  need_collector_connection = True
  record_plan_change = True
Method Details [hide private]

__init__(self, area_builder, builder, value)
(Constructor)

source code 
Parameters:
  • area_builder - the relevant AreaBuilder instance
  • builder - Builder instance
  • value - the value of the evaluator (bigger is better)

_weighted_distance(cls, main_component, other_components, none_value)
Class Method

source code 

Return the weights sum of the component distances with the specified weights.

Parameters:
  • main_component - value of the main component
  • other_components - list[(weight, value), ...] where weight is a float and value is either None or a float
  • none_value - the penalty for None in place of a component value

_distance_to_nearest_building(cls, area_builder, builder, building_id)
Class Method

source code 

Return the shortest distance to a building of type building_id that is in range of the builder.

Parameters:
  • area_builder - AreaBuilder instance
  • builder - Builder instance
  • building_id - the building type id of the building to which the distance should be measured

_distance_to_nearest_collector(cls, production_builder, builder, must_be_in_range=True)
Class Method

source code 

Return the shortest distance to a collector that (usually) has to be in range of the builder.

Parameters:
  • production_builder - ProductionBuilder instance
  • builder - Builder instance
  • must_be_in_range - whether the building has to be in range of the builder

purpose(self)

source code 

Return the BUILDING_PURPOSE constant relevant to the builder.

Decorators:
  • @property

execute(self)

source code 

Build the specified building complex. Return (BUILD_RESULT constant, building object).