Package horizons :: Package ai :: Package aiplayer :: Package building :: Module farm :: Class FarmEvaluator
[hide private]
[frames] | no frames]

Class FarmEvaluator

source code

buildingevaluator.BuildingEvaluator --+
                                      |
                                     FarmEvaluator

Instance Methods [hide private]
 
__init__(self, area_builder, builder, value, farm_plan, fields, field_purpose) source code
 
_register_changes(self, changes, just_roads) source code
 
execute(self)
Build the specified building complex.
source code
    Inherited from buildingevaluator.BuildingEvaluator
 
__str__(self) source code
 
_register_builder_position(self) 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
 
purpose(self)
Return the BUILDING_PURPOSE constant relevant to the builder.
source code
Class Methods [hide private]
 
init_field_offsets(cls) source code
 
_suitable_for_road(cls, production_builder, coords)
check coordinates
source code
 
create(cls, area_builder, farm_x, farm_y, road_dx, road_dy, min_fields, field_purpose, field_spots_set, road_spots_set, positive_alignment) source code
    Inherited from buildingevaluator.BuildingEvaluator
 
_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_alignment(cls, area_builder, coords_list)
Return an alignment value based on the outline of 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_outline_coords_list(cls, coords_list)
Return the list of coordinates that share sides the given coordinates list.
source code
 
_weighted_distance(cls, main_component, other_components, none_value)
Return the weights sum of the component distances with the specified weights.
source code
 
get_best_evaluator(cls, evaluators) source code
Class Variables [hide private]
  __field_pos_offsets = [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1),...
  __moves = [(-1, 0), (0,-1), (0, 1), (1, 0)]
  __field_offsets = None
hash(x)
    Inherited from buildingevaluator.BuildingEvaluator
  log = logging.getLogger("ai.aiplayer.buildingevaluator")
  need_collector_connection = True
  record_plan_change = True
Method Details [hide private]

__init__(self, area_builder, builder, value, farm_plan, fields, field_purpose)
(Constructor)

source code 
Parameters:
  • area_builder - the relevant AreaBuilder instance
  • builder - Builder instance
  • value - the value of the evaluator (bigger is better)
Overrides: buildingevaluator.BuildingEvaluator.__init__
(inherited documentation)

execute(self)

source code 

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

Overrides: buildingevaluator.BuildingEvaluator.execute
(inherited documentation)

Class Variable Details [hide private]

__field_pos_offsets

Value:
[(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2\
)]