Exemple #1
0
# Note: The algorithm is not stable with respect to pid order.  i.e. Two empire with
#       exactly the same colonies, but different pids may make different choices.
from logging import info, warn, debug
from operator import itemgetter

import freeOrionAIInterface as fo  # pylint: disable=import-error
from aistate_interface import get_aistate
from EnumsAI import PriorityType, get_priority_resource_types, FocusType
import PlanetUtilsAI
import ColonisationAI
import AIDependencies
import CombatRatingsAI
from common.print_utils import Table, Text
from freeorion_tools import tech_is_complete, AITimer

resource_timer = AITimer('timer_bucket')

# Local Constants
INDUSTRY = FocusType.FOCUS_INDUSTRY
RESEARCH = FocusType.FOCUS_RESEARCH
GROWTH = FocusType.FOCUS_GROWTH
PROTECTION = FocusType.FOCUS_PROTECTION
_focus_names = {
    INDUSTRY: "Industry",
    RESEARCH: "Research",
    GROWTH: "Growth",
    PROTECTION: "Defense"
}

# TODO use the priorityRatio to weight
RESEARCH_WEIGHTING = 2.3
Exemple #2
0
import PlanetUtilsAI
import PriorityAI
import ProductionAI
import ResearchAI
import ResourcesAI
import TechsListsAI
import turn_state
from aistate_interface import create_new_aistate, load_aistate, get_aistate
from AIDependencies import INVALID_ID
from freeorion_tools import handle_debug_chat, AITimer
from common.handlers import init_handlers
from common.listeners import listener
from character.character_module import Aggression
from character.character_strings_module import get_trait_name_aggression, possible_capitals

main_timer = AITimer('timer', write_log=True)
turn_timer = AITimer('bucket', write_log=True)

using_statprof = False
try:
    import statprof
    # statprof.start()
    # using_statprof = True
except ImportError:
    pass


user_dir = fo.getUserDataDir()
debug("Path to folder for user specific data: %s" % user_dir)
debug('Python paths %s' % sys.path)
Exemple #3
0
import PlanetUtilsAI
import universe_object
import ProductionAI
import ColonisationAI
import MilitaryAI
from EnumsAI import MissionType, PriorityType
import CombatRatingsAI
from freeorion_tools import tech_is_complete, AITimer, get_partial_visibility_turn
from AIDependencies import INVALID_ID

MAX_BASE_TROOPERS_GOOD_INVADERS = 20
MAX_BASE_TROOPERS_POOR_INVADERS = 10
_TROOPS_SAFETY_MARGIN = 1  # try to send this amount of additional troops to account for uncertainties in calculation
MIN_INVASION_SCORE = 20

invasion_timer = AITimer('get_invasion_fleets()', write_log=False)


def get_invasion_fleets():
    invasion_timer.start("gathering initial info")
    universe = fo.getUniverse()
    empire = fo.getEmpire()
    empire_id = fo.empireID()

    home_system_id = PlanetUtilsAI.get_capital_sys_id()
    visible_system_ids = list(foAI.foAIstate.visInteriorSystemIDs) + list(
        foAI.foAIstate.visBorderSystemIDs)

    if home_system_id != INVALID_ID:
        accessible_system_ids = [
            sys_id for sys_id in visible_system_ids if (sys_id != INVALID_ID)
Exemple #4
0
import AIstate
import ColonisationAI
import ExplorationAI
import FleetUtilsAI
import FreeOrionAI as foAI
import InvasionAI
import MilitaryAI
import PlanetUtilsAI
import ProductionAI
import ResearchAI
from AIDependencies import INVALID_ID
from EnumsAI import EmpireProductionTypes, MissionType, PriorityType, ShipRoleType, get_priority_production_types
from freeorion_tools import AITimer, tech_is_complete
from turn_state import state

prioritiees_timer = AITimer('calculate_priorities()')

allottedColonyTargets = 0
allotted_outpost_targets = 0
unmetThreat = 0


def calculate_priorities():
    """Calculates the priorities of the AI player."""
    print "\n", 10 * "=", "Preparing to Calculate Priorities", 10 * "="
    prioritiees_timer.start('setting Production Priority')
    foAI.foAIstate.set_priority(PriorityType.RESOURCE_PRODUCTION, 50)  # let this one stay fixed & just adjust Research

    print "\n*** Calculating Research Priority ***\n"
    prioritiees_timer.start('setting Research Priority')
    foAI.foAIstate.set_priority(PriorityType.RESOURCE_RESEARCH, _calculate_research_priority())  # TODO: do univ _survey before this