Package horizons :: Package ai :: Package aiplayer :: Package personality :: Module default
[hide private]
[frames] | no frames]

Source Code for Module horizons.ai.aiplayer.personality.default

  1  # ################################################### 
  2  # Copyright (C) 2008-2017 The Unknown Horizons Team 
  3  # team@unknown-horizons.org 
  4  # This file is part of Unknown Horizons. 
  5  # 
  6  # Unknown Horizons is free software; you can redistribute it and/or modify 
  7  # it under the terms of the GNU General Public License as published by 
  8  # the Free Software Foundation; either version 2 of the License, or 
  9  # (at your option) any later version. 
 10  # 
 11  # This program is distributed in the hope that it will be useful, 
 12  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 14  # GNU General Public License for more details. 
 15  # 
 16  # You should have received a copy of the GNU General Public License 
 17  # along with this program; if not, write to the 
 18  # Free Software Foundation, Inc., 
 19  # 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
 20  # ################################################### 
 21   
 22  from horizons.constants import TIER 
 23   
 24   
25 -class DefaultPersonality:
26 - class SettlementFounder:
27 min_feeder_island_area = 400 # minimum amount of usable free land on an island to consider turning it into a feeder island 28 29 # found a settlement on a random island that is at least as large as the first element; if it is impossible then try the next size 30 island_size_sequence = [500, 300, 150] 31 32 enemy_settlement_penalty = 200 # penalty for every enemy settlement on the island 33 compact_empire_importance = 100 # importance of keeping our islands close together 34 extra_warehouse_distance = 1 # extra distance to add to the usual warehouse to island distance when choosing an island 35 nearby_enemy_penalty = 100 # importance of keeping our islands away from other players' islands 36 extra_enemy_island_distance = 1 # extra distance to add to the usual island to other player's island distance when choosing an island 37 38 min_raw_clay = 100 # if the island has less than this much then apply the penalty 39 max_raw_clay = 300 # no more than this much will count for the bonus value 40 raw_clay_importance = 0.3 # how important is the available resource amount 41 no_raw_clay_penalty = 100 # penalty for having less than this much of the resource on the island 42 43 min_stone_deposit = 100 # if the island has less than this much then apply the penalty 44 max_stone_deposit = 300 # no more than this much will count for the bonus value 45 stone_deposit_importance = 0.3 # how important is the available resource amount 46 no_stone_deposit_penalty = 100 # penalty for having less than this much of the resource on the island 47 48 min_raw_iron = 100 # if the island has less than this much then apply the penalty 49 max_raw_iron = 300 # no more than this much will count for the bonus value 50 raw_iron_importance = 0.05 # how important is the available resource amount 51 no_raw_iron_penalty = 30 # penalty for having less than this much of the resource on the island 52 53 # minimum amount of a resource required to found a new settlement 54 min_new_island_gold = 8000 55 min_new_island_tools = 5 56 min_new_island_boards = 17 57 min_new_island_food = 10 58 59 # maximum amount of a resource loaded on a ship to found a new settlement 60 max_new_island_tools = 30 61 max_new_island_boards = 30 62 max_new_island_food = 30 63 64 # minimum amount of a resource required to start a new feeder island 65 min_new_feeder_island_gold = 4000 66 min_new_feeder_island_tools = 10 67 min_new_feeder_island_boards = 20 68 69 # maximum amount of a resource loaded on a ship to start a new feeder island 70 max_new_feeder_island_tools = 30 71 max_new_feeder_island_boards = 30
72
74 little_money = 3000 # cutoff to decide that we really need to get more money by selling resources on other players' islands 75 buy_coefficient_rich = 30 # value coefficient of buying resources when we have more than little_money gold 76 buy_coefficient_poor = 10 # value coefficient of buying resources when we have less than or equal to little_money gold
77
78 - class AreaBuilder:
89
90 - class ProductionBuilder(AreaBuilder):
91 pass
92
93 - class VillageBuilder(AreaBuilder):
94 max_village_section_size = 22 # maximum side length of a village section 95 96 tent_value = 10 # the value of a tent in a village 97 bad_road_penalty = 1 # the penalty for an impossible road tile 98 double_road_penalty = 30 # the penalty for building two roads right next to each other (per complete road, not segment) 99 100 max_coverage_building_capacity = 22 # maximum number of residences a coverage building can service 101 normal_coverage_building_capacity = 20 # the initial plan calls for this number of residences per coverage building (may or may not be optimized away) 102 103 max_fire_station_capacity = 40 # maximum number of residences a fire station can service 104 normal_fire_station_capacity = 30 # the initial plan calls for this number of residences per fire station 105 106 max_doctor_capacity = 40 # maximum number of residences a doctor can service 107 normal_doctor_capacity = 30 # the initial plan calls for this number of residences per doctor 108 109 min_coverage_building_options = 10 # consider at least this many coverage building options 110 coverage_building_option_ratio = 0.4 # consider this * 100% of the possible options
111
112 - class LandManager:
113 max_section_side = 22 # minimize the number of village sections by considering this to be its maximum side length 114 115 village_area_small = 0.23 # use this fraction of the area for the village if <= 1600 tiles are available for the settlement 116 village_area_40 = 0.26 # use this fraction of the area for the village if <= 2500 tiles are available for the settlement 117 village_area_50 = 0.28 # use this fraction of the area for the village if <= 3600 tiles are available for the settlement 118 village_area_60 = 0.31 # use this fraction of the area for the village if > 3600 tiles are available for the settlement 119 min_village_size = 81 # minimum possible village size in tiles 120 min_village_proportion = 0.95 # the proportion of the chosen village area size that must be present
121
122 - class ResourceManager:
123 default_resource_requirement = 30 # try to always have this much tools and boards in settlement inventory 124 default_food_requirement = 30 # try to always have this much food in settlement inventory in settlements with a village 125 default_feeder_island_brick_requirement = 20 # try to always have this much bricks in feeder island inventory (active on level > 0) 126 default_cannon_requirement = 4 127 128 # the following constants affect the way the AI buys and sells resources 129 reserve_time = 1000 # number of ticks to pre-reserve resources for 130 max_upgraded_houses = 10 # maximum number of houses whose upgrades should be accounted for in the reserve_time 131 buy_threshold = 0.66666 # when more than buy_threshold * needed_amount of resource exists then stop buying 132 sell_threshold = 1.33333 # when less than sell_threshold * needed_amount of resource exists then stop selling 133 low_requirement_threshold = 5 # when we need less than or equal to this amount of resource then disregard buy_threshold
134
135 - class RoadPlanner:
136 turn_penalty = 1 # penalty for a bend in the road
137
138 - class SettlementManager:
139 production_level_multiplier = 1.1 # always aim to produce the needed_amount * production_level_multiplier of required resources per tick 140 new_settlement_settler_ratio = 0.5 # more than this proportion of residences must have settler status to be able to start a new settlement 141 142 # dummy values to cause various producers to be built (production per tick) 143 dummy_bricks_requirement = 0.001 144 dummy_boards_requirement = 0.01 145 dummy_tools_requirement = 0.001 146 147 # tax rates and upgrade rights in new settlements 148 initial_sailor_taxes = 0.5 149 initial_pioneer_taxes = 0.8 150 initial_settler_taxes = 0.8 151 initial_citizen_taxes = 0.8 152 initial_merchants_taxes = 0.8 153 initial_sailor_upgrades = False 154 initial_pioneer_upgrades = False 155 initial_settler_upgrades = False 156 initial_citizen_upgrades = False 157 158 # tax rates and upgrade rights in settlements where the first sailors have been given the right to upgrade 159 early_sailor_taxes = 0.9 160 early_pioneer_taxes = 0.8 161 early_settler_taxes = 0.8 162 early_citizen_taxes = 0.8 163 early_merchants_taxes = 0.8 164 early_sailor_upgrades = False 165 early_pioneer_upgrades = False 166 early_settler_upgrades = False 167 early_citizen_upgrades = False 168 169 # tax rates and upgrade rights in settlements where bricks production exists but there is no school 170 no_school_sailor_taxes = 0.9 171 no_school_pioneer_taxes = 0.8 172 no_school_settler_taxes = 0.8 173 no_school_citizen_taxes = 0.8 174 no_school_merchants_taxes = 0.8 175 no_school_sailor_upgrades = True 176 no_school_pioneer_upgrades = True 177 no_school_settler_upgrades = False 178 no_school_citizen_upgrades = False 179 180 # tax rates and upgrade rights in settlements where there is a school but not enough resources to build something 181 school_sailor_taxes = 0.9 182 school_pioneer_taxes = 1.0 183 school_settler_taxes = 0.8 184 school_citizen_taxes = 0.8 185 school_merchants_taxes = 0.8 186 school_sailor_upgrades = False 187 school_pioneer_upgrades = False 188 school_settler_upgrades = False 189 school_citizen_upgrades = False 190 191 # tax rates and upgrade rights in settlements with a school and none of the above problems 192 final_sailor_taxes = 0.9 193 final_pioneer_taxes = 1.0 194 final_settler_taxes = 1.0 195 final_citizen_taxes = 0.8 196 final_merchants_taxes = 0.8 197 final_sailor_upgrades = True 198 final_pioneer_upgrades = True 199 final_settler_upgrades = True 200 final_citizen_upgrades = False # Set to true to enable merchant level
201
202 - class FoundSettlement:
203 # use a penalty for warehouse being too close to the village area 204 too_close_penalty_threshold = 3 205 too_close_constant_penalty = 100 206 too_close_linear_penalty = 0 207 208 linear_warehouse_penalty = 1000 # add a penalty of this constant * distance to a warehouse to the warehouse penalty 209 max_options = 10 # maximum number of options to consider
210
211 - class FeederChainGoal:
212 extra_priority = 1 # extra priority given to goals that are supposed to produce resources for other settlements on feeder islands
213
214 - class BoatBuilderGoal:
215 enabled = True 216 default_priority = 600 217 residences_required = 16 218 min_tier = TIER.PIONEERS
219
221 enabled = True 222 default_priority = 450 223 residences_required = 0 224 min_tier = TIER.PIONEERS 225 226 alignment_coefficient = 0.7 # the importance of alignment when choosing a location for a storage to get closer to a deposit
227
229 enabled = True 230 default_priority = 450 231 residences_required = 0 232 min_tier = TIER.PIONEERS 233 234 alignment_coefficient = 0.7 # the importance of alignment when choosing a location for a storage to get closer to a deposit
235
236 - class DoNothingGoal:
237 enabled = True 238 default_priority = 1500 # mean priority; changing this will influence which goals are more important than doing nothing 239 min_tier = TIER.SAILORS 240 priority_variance = 50 241 likelihood = 0.1 # likelihood that it will be active [0, 1]
242
244 enabled = True 245 default_priority = 850 246 residences_required = 0 247 min_tier = TIER.SAILORS 248 249 alignment_coefficient = 3 # the importance of alignment when choosing a location for a storage to enlarge collector coverage 250 max_interesting_collector_area = 100 # maximum collector area (of 3x3 squares) we are interested in when considering whether to enlarge the area 251 max_collector_area_unreachable = 10 # maximum collector area (of 3x3 squares) that doesn't have to be reachable when considering whether to enlarge the area 252 overlap_precision = 0.2 # probability that a tile in the radius will be checked for match for useful coordinates
253
255 enabled = True 256 default_priority = 650 257 residences_required = 16 258 min_tier = TIER.SAILORS 259 260 feeder_island_requirement_cutoff = 30 # if there are less than this many free 3x3 squares in a settlement then a feeder island is needed 261 usable_feeder_island_cutoff = 30 # if there are less than this many free 3x3 on a feeder island then another feeder island may be needed
262
264 enabled = True 265 default_priority = 1000 266 residences_required = 0 267 min_tier = TIER.SAILORS 268 269 min_bad_collector_coverage = 0.5 # collector coverage should be improved when a production building is stopped for more than this amount of time 270 min_free_space = 20 # if there is less than this much free space for a resource then it doesn't matter that the building in badly covered 271 max_good_collector_utilization = 0.7 # if the collector building is used more than this then don't attempt to improve coverage by connecting more production buildings 272 273 max_reasonably_served_buildings = 3 # maximum number of buildings a storage can reasonably serve (not a hard limit) 274 collector_extra_distance = 6.0 # constant distance on top of the actual distance a collector has to move (accounts for breaks) 275 alignment_coefficient = 0.001 # the importance of alignment when choosing a location for a storage to improve collector coverage 276 277 collector_improvement_road_expires = 1500 # minimum number of ticks between collector improvement road connections 278 collector_improvement_storage_expires = 4000 # minimum number of ticks between collector improvement extra storages
279
281 enabled = True 282 default_priority = 200 283 residences_required = 0 284 min_tier = TIER.SETTLERS 285 286 alignment_coefficient = 0.7 # the importance of alignment when choosing a location for a storage to get closer to a deposit
287
288 - class SignalFireGoal:
289 enabled = True 290 default_priority = 750 291 residences_required = 0 292 min_tier = TIER.SAILORS
293
294 - class StorageSpaceGoal(ImproveCollectorCoverageGoal):
295 enabled = True 296 default_priority = 825 297 residences_required = 0 298 min_tier = TIER.SAILORS 299 300 max_required_storage_space = 60 # maximum storage capacity to go for when the inventory starts to get full 301 full_storage_threshold = 5 # when there is less than this amount of free space for a resource then we might need more space
302
303 - class TentGoal:
304 enabled = True 305 default_priority = 480 306 residences_required = 0 307 min_tier = TIER.SAILORS
308
309 - class TradingShipGoal:
310 enabled = True 311 default_priority = 550 312 residences_required = 0 313 min_tier = TIER.SAILORS
314
315 - class CombatShipGoal:
316 enabled = True 317 default_priority = 560 318 residences_required = 0 319 min_tier = TIER.SAILORS
320
321 - class FaithGoal:
322 enabled = True 323 default_priority = 700 324 residences_required = 10 325 min_tier = TIER.SAILORS
326
327 - class TextileGoal:
332
333 - class BricksGoal:
338
339 - class EducationGoal:
340 enabled = True 341 default_priority = 300 342 residences_required = 10 343 min_tier = TIER.PIONEERS
344
345 - class GetTogetherGoal:
346 enabled = True 347 default_priority = 250 348 residences_required = 10 349 min_tier = TIER.SETTLERS
350
351 - class ToolsGoal:
356
357 - class BoardsGoal:
358 enabled = True 359 default_priority = 950 360 residences_required = 0 361 min_tier = TIER.SAILORS
362
363 - class FoodGoal:
364 enabled = True 365 default_priority = 800 366 residences_required = 0 367 min_tier = TIER.SAILORS
368
369 - class CommunityGoal:
370 enabled = True 371 default_priority = 900 372 residences_required = 0 373 min_tier = TIER.SAILORS
374
375 - class LiquorGoal:
376 # this goal is only used on feeder islands 377 enabled = True 378 default_priority = 250 379 residences_required = 0 380 min_tier = TIER.SETTLERS
381
382 - class SaltGoal:
383 enabled = True 384 default_priority = 230 385 residences_required = 10 386 min_tier = TIER.SETTLERS
387
388 - class FeederSaltGoal:
393
395 enabled = True 396 default_priority = 220 397 residences_required = 13 398 min_tier = TIER.SETTLERS
399 405
407 enabled = True 408 default_priority = 230 409 residences_required = 13 410 min_tier = TIER.SETTLERS
411 417
419 fraction_of_assigned_residences_built = 0.75 # build a coverage building if at least this amount of the assigned residences have been built
420
421 - class BuildingEvaluator:
422 # the following constants are used to calculate the alignment bonus for buildings 423 alignment_road = 3 424 alignment_production_building = 1 425 alignment_other_building = 1 426 alignment_edge = 1
427
429 alignment_importance = 0.02 # the larger this value, the larger the effect of alignment on the placement
430
431 - class BrickyardEvaluator:
432 alignment_importance = 0.02 # the larger this value, the larger the effect of alignment on the placement 433 collector_distance_importance = 0.1 # importance of the distance to the nearest collector in the range [0, 1] 434 distance_penalty = 2 # when no clay pit is in reach then apply a penalty of this times the radius
435
437 alignment_importance = 0.02 # the larger this value, the larger the effect of alignment on the placement 438 lumberjack_distance_importance = 0.05 # importance of the distance to the nearest lumberjack in the range [0, 1] 439 iron_mine_distance_importance = 0.1 # importance of the distance to the nearest iron mine in the range [0, 1] 440 distance_penalty = 2 # when no lumberjack or iron mine is in reach then apply a penalty of this times the radius
441
443 alignment_importance = 0.02 # the larger this value, the larger the effect of alignment on the placement 444 farm_distance_importance = 0.3 # importance of the distance to the nearest relevant farm in the range [0, 1] 445 distance_penalty = 2 # when no relevant farm is in reach then apply a penalty of this times the radius
446
447 - class FarmEvaluator:
448 alignment_importance = 0.001 # the larger this value, the larger the effect of alignment on the placement 449 existing_road_importance = 0.005 # bonus for every reused tile of existing (or planned) road 450 wasted_space_penalty = 0.02 451 immediate_connection_importance = 0.005 # bonus for road and non-blocked access to the road 452 453 immediate_connection_road = 3 # bonus for a road in an entrance of the farm 454 immediate_connection_free = 1 # bonus for an unused tile in an entrance of the farm 455 456 max_options = 100 # maximum number of farm options to consider
457
459 alignment_importance = 0.5 # the larger this value, the larger the effect of alignment on the placement 460 new_tree = 3 # number of points for a new tree in range 461 shared_tree = 1 # number of points for a shared tree in range (at least one lumberjack already using it) 462 min_forest_value = 30 # minimum number of points to consider the position 463 max_forest_value = 100 # maximum number of relevant points (more than this is ignored)
464
466 alignment_importance = 1.5 # the larger this value, the larger the effect of alignment on the placement
467
468 - class SmelteryEvaluator:
469 alignment_importance = 0.02 # the larger this value, the larger the effect of alignment on the placement 470 collector_distance_importance = 0.4 # importance of the distance to the nearest collector in the range [0, 1] 471 charcoal_burner_distance_importance = 0.1 # importance of the distance to the nearest charcoal burner in the range [0, 1] 472 distance_penalty = 2 # when no collector or charcoal burner is in reach then apply a penalty of this times the radius
473
474 - class ToolmakerEvaluator:
475 alignment_importance = 0.02 # the larger this value, the larger the effect of alignment on the placement 476 smeltery_distance_importance = 0.4 # importance of the distance to the nearest smeltery in the range [0, 1] 477 lumberjack_distance_importance = 0.1 # importance of the distance to the nearest lumberjack in the range [0, 1] 478 charcoal_burner_distance_importance = 0.4 # importance of the distance to the nearest charcoal burner in the range [0, 1] 479 distance_penalty = 2 # when no smeltery, lumberjack, or charcoal burner is in reach then apply a penalty of this times the radius
480
481 - class WeaverEvaluator:
482 alignment_importance = 0.02 # the larger this value, the larger the effect of alignment on the placement 483 farm_distance_importance = 0.3 # importance of the distance to the nearest relevant farm in the range [0, 1] 484 distance_penalty = 2 # when no relevant farm is in reach then apply a penalty of this times the radius
485
487 alignment_importance = 0.02 # the larger this value, the larger the effect of alignment on the placement 488 farm_distance_importance = 0.3 # importance of the distance to the nearest relevant farm in the range [0, 1] 489 distance_penalty = 2 # when no relevant farm is in reach then apply a penalty of this times the radius
490
492 add_potato_field_value = 1.5 # the value of adding a potato field 493 add_pasture_value = 2.5 # the value of adding a pasture 494 add_sugarcane_field_value = 3.5 # the value of adding a sugarcane field 495 add_tobacco_field_value = 3.5 # the value of adding a tobacco field 496 add_herbary_field_value = 3.5 # the value of adding a herbary 497 remove_unused_potato_field_penalty = 0 # the penalty for removing an unused potato field 498 remove_unused_pasture_penalty = 1 # the penalty for removing an unused pasture 499 remove_unused_sugarcane_field_penalty = 1.5 # the penalty for removing an unused sugarcane field 500 remove_unused_tobacco_field_penalty = 1.5 # the penalty for removing an unused tobacco field 501 remove_unused_herbary_field_penalty = 1.5 # the penalty for removing an unused herbary
502
503 - class FireStationGoal:
508
509 - class DoctorGoal:
514
516 fraction_of_assigned_residences_built = 0.4 # build a fire station if at least this amount of the assigned residences have been built
517
518 - class AbstractDoctor:
519 fraction_of_assigned_residences_built = 0.4 # build a doctor if at least this amount of the assigned residences have been built
520
521 - class AbstractFisher:
522 max_options = 30 # maximum number of farm options to consider
523
525 alignment_importance = 0.02 # the larger this value, the larger the effect of alignment on the placement 526 distance_penalty = 2 # (guessing) When no relevant mason is in reach, then apply a penalty of this time the radius. 527 stone_pit_distance_importance = 0.3 # importance of the distance to the nearest relevant stone-pit in the range [0, 1]
528