if isinstance(target, hlt.entity.Planet) else f'S{target.id}'
        for ship, target in alloc.items()
    }
    logging.info(f'Minimal dist alloc: {logging_alloc}')
    logging.info(
        f'Time to calculate minimal distance job allocation: {timer.get_time()} ms'
    )

    # rushing
    if len(my_docked_ships) == 0 and len(my_fighting_ships) <= 3 and len(
            game_map.all_players()) == 2:
        if len(
                bot_utils.get_proximity_alerts(
                    my_fighting_ships, [rush_mode_proximity] *
                    len(my_fighting_ships), enemy_ships)) > 0:
            closest_enemy = bot_utils.get_closest(my_fighting_ships[0],
                                                  enemy_ships)
            fighting_opportunities.append(closest_enemy)
            alloc = {}
            for ship in my_fighting_ships:
                alloc[ship] = closest_enemy

    # sort ships by type of objective
    potential_packs = {
        fighting_opportunity: []
        for fighting_opportunity in fighting_opportunities
    }
    for ship, target in alloc.items():
        if target in fighting_opportunities:
            potential_packs[target].append(ship)
        elif target in good_dock_spots:
            orders[ship] = target
Beispiel #2
0
                target = bot_utils.pop_closest(ship, dockable_spots_list)
                orders[ship] = target
            else:
                # make this ship a hunter
                type_table[ship.id] = 'hunter'

    # handle orders for hunters here
    docked_enemy_ships_full = copy.copy(docked_enemy_ships)
    for ship in my_fighting_ships:
        ship_type = type_table[ship.id]
        if ship_type == 'hunter':
            if len(docked_enemy_ships) > 0:
                target = bot_utils.pop_closest(ship, docked_enemy_ships)
                orders[ship] = target
            elif len(docked_enemy_ships_full) > 0:
                target = bot_utils.get_closest(ship, docked_enemy_ships_full)
                orders[ship] = target
            else:
                target = bot_utils.get_closest(ship, enemy_ships)
                orders[ship] = target

    # create abbreviated order dict for logging
    logging_orders = {}
    for ship, order in orders.items():
        logging_orders[ship.id] = f'S{order.id}' if isinstance(order, hlt.entity.Ship) else f'P{order.id}'
    logging.info(f'orders: {logging_orders}')

    for ship in orders:
        command = None
        ship_type = type_table[ship.id]
        target = orders[ship]
        if isinstance(target, hlt.entity.Planet) else f'S{target.id}'
        for ship, target in alloc.items()
    }
    logging.info(f'Minimal dist alloc: {logging_alloc}')
    logging.info(
        f'Time to calculate minimal distance job allocation: {timer.get_time()} ms'
    )

    # rushing
    if len(my_docked_ships) == 0 and len(my_fighting_ships) <= 3 and len(
            game_map.all_players()) == 2:
        if len(
                bot_utils.get_proximity_alerts(
                    my_fighting_ships, [rush_mode_proximity] *
                    len(my_fighting_ships), enemy_ships)) > 1:
            closest_enemy = bot_utils.get_closest(my_fighting_ships[0],
                                                  enemy_ships)
            fighting_opportunities.append(closest_enemy)
            alloc = {}
            for ship in my_fighting_ships:
                alloc[ship] = closest_enemy

    # merge fighting opportunities if they are close
    merged_fighting_opp_map = {}
    for i, ship1 in enumerate(fighting_opportunities):
        for j, ship2 in enumerate(fighting_opportunities):
            if i >= j:
                continue
            if ship1.calculate_distance_between(
                    ship2) < fighting_opportunity_merge_distance:
                if len([ship for ship in alloc.values() if ship is ship1]) > \
                        len([ship for ship in alloc.values() if ship is ship2]):
Beispiel #4
0
                # make this ship a hunter
                type_table[ship.id] = 'hunter'

    # handle orders for hunters here
    # usual hunting tactics
    docked_enemy_ships_full = copy.copy(docked_enemy_ships)
    for ship in my_fighting_ships:
        if ship in orders:
            continue
        ship_type = type_table[ship.id]
        if ship_type == 'hunter':
            if len(docked_enemy_ships) > 0:
                target = bot_utils.pop_closest(ship, docked_enemy_ships)
                orders[ship] = target
            elif len(docked_enemy_ships_full) > 0:
                target = bot_utils.get_closest(ship, docked_enemy_ships_full)
                orders[ship] = target
            else:
                target = bot_utils.get_closest(ship, enemy_ships)
                orders[ship] = target

    # special case - docked ships under attack
    if len(belligerent_enemies) > 0:
        my_hunters = [
            ship for ship in my_fighting_ships
            if type_table[ship.id] == 'hunter'
        ]
        for enemy in belligerent_enemies:
            if len(my_hunters) > 0:
                closest_hunter = bot_utils.get_closest(enemy, my_hunters)
                if closest_hunter.calculate_distance_between(
Beispiel #5
0
    )

    # sort ships by type of objective
    potential_packs = {
        fighting_opportunity: []
        for fighting_opportunity in fighting_opportunities
    }
    for ship, target in alloc.items():
        if target in fighting_opportunities:
            potential_packs[target].append(ship)
        elif target in good_dock_spots:
            orders[ship] = target
        my_unassigned_ships.remove(ship)
    for ship in my_unassigned_ships:
        if use_unassigned_ships:
            enemy = bot_utils.get_closest(ship, enemy_ships)
            orders[ship] = enemy
        else:
            my_free_navigation_ships.remove(ship)

    if len(my_unassigned_ships) > 0:
        logging.info(
            f'Some ships were left unassigned: {[ship.id for ship in my_unassigned_ships]}'
        )

    # create packs from ships with the same objective
    packs = {}
    for target, pack in potential_packs.items():
        if len(pack) > 1:
            leader = bot_utils.get_central_entity(pack)
            packs[leader] = [ship for ship in pack if ship != leader]
    )

    # sort ships by type of objective
    potential_packs = {
        fighting_opportunity: []
        for fighting_opportunity in fighting_opportunities
    }
    for ship, target in alloc.items():
        if target in fighting_opportunities:
            potential_packs[target].append(ship)
        elif target in good_dock_spots:
            orders[ship] = target
        my_unassigned_ships.remove(ship)
    for ship in my_unassigned_ships:
        if use_unassigned_ships:
            enemy = bot_utils.get_closest(ship, enemy_ships)
            orders[ship] = enemy
        else:
            my_free_navigation_ships.remove(ship)

    if len(my_unassigned_ships) > 0:
        logging.info(
            f'Some ships were left unassigned: {[ship.id for ship in my_unassigned_ships]}'
        )

    # create packs from ships with the same objective
    packs = {}
    for target, pack in potential_packs.items():
        if len(pack) > 1:
            leader = bot_utils.get_closest(
                target, pack)  # bot_utils.get_central_entity(pack)
Beispiel #7
0
        if ship_id not in all_my_ship_ids:
            del type_table[ship_id]
    # add new guys
    for ship in my_fighting_ships:
        if ship.id not in type_table:
            type_table[ship.id] = 'interceptor'

    logging.info(f'type_table: {type_table}')

    interceptors = {enemy: [] for enemy in proximal_enemy_ships}
    # can also join all action lists (dock spots and proximal enemies) and then let each ship do the closest action
    orders = {}
    # attack any proximal enemies
    for ship in copy.copy(my_fighting_ships):
        if len(proximal_enemy_ships) > 0:
            enemy = bot_utils.get_closest(ship, proximal_enemy_ships)
            if ship.calculate_distance_between(enemy) < defensive_action_radius \
                    and len(interceptors[enemy]) < max_response:
                orders[ship] = enemy
                interceptors[enemy].append(ship)
                my_fighting_ships.remove(ship)
                if len(interceptors[enemy]) >= max_response:
                    proximal_enemy_ships.remove(enemy)

    # the rest can build or hunt good opportunities
    temp_alloc = {}
    # temporary - for comparison purposes:
    good_opportunities_copy = copy.deepcopy(good_opportunities)
    for ship in my_fighting_ships:
        if ship not in orders:
            if len(good_opportunities_copy) > 0:
Beispiel #8
0
    logging_alloc = {f'S{ship.id}': f'P{target.id}' if isinstance(target, hlt.entity.Planet) else f'S{target.id}' for
                     ship, target in alloc.items()}
    logging.info(f'Minimal dist alloc: {logging_alloc}')
    logging.info(f'Time to calculate minimal distance job allocation: {timer.get_time()} ms')

    # sort ships by type of objective
    potential_packs = {fighting_opportunity: [] for fighting_opportunity in fighting_opportunities}
    for ship, target in alloc.items():
        if target in fighting_opportunities:
            potential_packs[target].append(ship)
        elif target in good_dock_spots:
            orders[ship] = target
        my_unassigned_ships.remove(ship)
    for ship in my_unassigned_ships:
        if use_unassigned_ships:
            enemy = bot_utils.get_closest(ship, enemy_ships)
            orders[ship] = enemy
        else:
            my_free_navigation_ships.remove(ship)

    if len(my_unassigned_ships) > 0:
        logging.info(f'Some ships were left unassigned: {[ship.id for ship in my_unassigned_ships]}')

    # create packs from ships with the same objective
    packs = {}
    for target, pack in potential_packs.items():
        if len(pack) > 1:
            leader = bot_utils.get_closest(target, pack)  # bot_utils.get_central_entity(pack)
            packs[leader] = [ship for ship in pack if ship != leader]
            orders[leader] = target
            for ship in packs[leader]: