예제 #1
0
import hlt
import logging
import time
import random
import numpy as np
import itertools
import collections
import math

game = hlt.Game("EB10")

while True:
    game_map = game.update_map()
    t_start = time.time()
    lastTime = t_start

    def checkpoint(msg):
        logging.info(msg + " - " + str(time.time()-t_start))

    def pos_dist(pos1, pos2):
        return ((pos1[0]-pos2[0])**2 + (pos1[1]-pos2[1])**2) ** 0.5

    my_id = game_map.my_id
    n_players = len(game_map.all_players())
    command_queue = []

    all_my_ships = list(game_map.get_me().all_ships())
    ship_radius = 1.2
    for s in all_my_ships:
        s.radius = ship_radius
예제 #2
0
        if conflict_check:
            immobile_obstacles = immobile_ships + game_map.all_planets
            valid_commands = resolve_conflicts(list_moves, immobile_obstacles)
            command_queue.append(valid_commands)

        # Send our set of commands to the Halite engine for this turn
        game.send_command_queue(command_queue)
        # TURN END

        # GAME END


if __name__ == "__main__":

    parser = argparse.ArgumentParser()

    parser.add_argument("--collision_offset", type=float, default=1)
    parser.add_argument("--k_collision", type=float, default=1.5)
    parser.add_argument("--k_foe", type=float, default=60)
    parser.add_argument("--k_planet", type=float, default=60)
    parser.add_argument("--k_swarm", type=float, default=30)
    parser.add_argument("--threat_threshold", type=float, default=1)
    parser.add_argument("--w_collision", type=float, default=-2)
    parser.add_argument("--w_swarm", type=float, default=1)
    parser.add_argument("--w_foe", type=float, default=1)
    parser.add_argument("--w_planet", type=float, default=1)
    parser.add_argument("--thrust_ratio", type=float, default=0.5)

    run_game(hlt.Game("Settler"), **vars(parser.parse_args()))
예제 #3
0
import hlt
import logging
import time

game = hlt.Game("ezboi")
logging.info("Starting my dope bot!")


def closest_planet(ship):
    entities_by_distance = game_map.nearby_entities_by_distance(ship)
    nearest_planet = None
    for distance in sorted(entities_by_distance):
        nearest_planet = next(
            (nearest_entity
             for nearest_entity in entities_by_distance[distance]
             if isinstance(nearest_entity, hlt.entity.Planet)), None)
        if nearest_planet:
            break
    return nearest_planet


def closest_open_planet(ship):
    entities_by_distance = game_map.nearby_entities_by_distance(ship)
    nearest_planet = None
    for distance in sorted(entities_by_distance):
        nearest_planet = next(
            (nearest_entity
             for nearest_entity in entities_by_distance[distance]
             if isinstance(nearest_entity, hlt.entity.Planet)
             and not nearest_entity.is_full()), None)
        if nearest_planet:
예제 #4
0
#mport tsmlstarterbot

import hlt
import logging
from collections import OrderedDict
import numpy as np
import random
import os

VERSION = 5

HM_ENT_FEATURES = 10
PCT_CHANGE_CHANCE = 15
DESIRED_SHIP_COUNT = 25

game = hlt.Game("PetrovSA{}".format(VERSION))
logging.info("PetrovSA-{} Start".format(VERSION))

ship_plans = {}

if os.path.exists("PetrovSA{}_input.vec".format(VERSION)):
    os.remove("PetrovSA{}_input.vec".format(VERSION))

if os.path.exists("PetrovSA{}_out.vec".format(VERSION)):
    os.remove("PetrovSA{}_out.vec".format(VERSION))


def key_by_value(dictionary, value):
    for k, v in dictionary.items():
        if v[0] == value:
            return k
예제 #5
0
import hlt
import logging
from collections import OrderedDict

game = hlt.Game("SheckyBot_v3funct")
logging.info("Go Shecky bot")

#### TO DO. ADD GOING TO VULNERABLE PLANETS AND TEAM STUFF####


def largest_dockable_planet(planets):
    if planets:
        return max([planet for planet in planets if not planet.is_owned()], key=lambda x: x.radius)
    else:
        return None


def docking(target_planet, less_than):
    if target_planet:
        if ship.can_dock(target_planet):
            command_queue.append(ship.dock(target_planet))
        else:
            navigate_command = ship.navigate(
                ship.closest_point_to(target_planet),
                game_map,
                speed=int(hlt.constants.MAX_SPEED + less_than),
                ignore_ships=False)
            if navigate_command:
                command_queue.append(navigate_command)

예제 #6
0
import hlt
import logging
from collections import OrderedDict

game = hlt.Game("T-Clap Aggressive")
logging.info("Starting T-Clap Aggressive")

while True:
    game_map = game.update_map()
    command_queue = []
    planets = game_map.all_planets()
    my_ships = game_map.get_me().all_ships()
    all_players = game_map.all_players()
    turns = 0
    for ship in my_ships:
        if ship.docking_status != ship.DockingStatus.UNDOCKED:
            continue

        entities_by_distance = game_map.nearby_entities_by_distance(ship)
        largest_planet = max(planet.radius
                             for planet in game_map.all_planets())
        entities_by_distance = OrderedDict(
            sorted(entities_by_distance.items(), key=lambda t: t[0]))

        closest_empty_planets = [
            entities_by_distance[distance][0]
            for distance in entities_by_distance
            if isinstance(entities_by_distance[distance][0], hlt.entity.Planet)
            and not entities_by_distance[distance][0].is_owned()
        ]
예제 #7
0
        else:
            continue

    if closest:
        return closest
    elif depth > 2:
        return None
    else:
        return closest_entity(ship,
                              entities,
                              exclusions=exclusions,
                              max_distance=max_distance * 2,
                              depth=depth + 1)


game = hlt.Game("CommandCenterV01")
logging.info("Initializing commmand center.")
cc = CommandCenter(game)

while True:
    cc.next_move()
    logging.info(cc.turn)
    command_queue = cc.command_queue
    # logging.info(f"command queue: {command_queue}")
    game.send_command_queue(command_queue)
    # logging.info("sent...")

# # GAME START
# game = hlt.Game("Main3")
# logging.info("Starting my Settler bot!")
# TURN = 0
예제 #8
0
import hlt
import logging
from collections import OrderedDict

game = hlt.Game("optimus_v3")
logging.info("Starting optimus")

while True:
    game_map = game.update_map()
    command_queue = []

    team_ships = game_map.get_me().all_ships()

    for ship in team_ships:
        if ship.docking_status != ship.DockingStatus.UNDOCKED:
            continue

        entities_by_distance = game_map.nearby_entities_by_distance(ship)
        entities_by_distance = OrderedDict(
            sorted(entities_by_distance.items(), key=lambda t: t[0]))

        closest_empty_planets = [
            entities_by_distance[distance][0]
            for distance in entities_by_distance
            if isinstance(entities_by_distance[distance][0], hlt.entity.Planet)
            and not entities_by_distance[distance][0].is_owned()
        ]
        # just enemy ships list
        closest_enemy_ships = [
            entities_by_distance[distance][0]
            for distance in entities_by_distance
예제 #9
0
파일: MyBot.py 프로젝트: hsperr/Halite2Bot
}
botname = "Vectorian"

if len(sys.argv) ==2:
    weights = [float(x) for x in sys.argv[1].split("#")]
    biases = {
            "my_planet": (1, weights[0]),
            "empty_planet": (1, weights[1]),
            "enemy_planet": (1, weights[2]),
            "my_ship": (-1, weights[3]),
            "enemy_ship": (1, weights[4])
    }

    botname = "Vect"+sys.argv[1]

game = hlt.Game(botname)

def obstacles_between(ship, target, fudge=0.0):
    """
    Check whether there is a straight-line path to the given point, without planetary obstacles in between.
    :param entity.Ship ship: Source entity
    :param entity.Entity target: Target entity
    :return: The list of obstacles between the ship and target
    :rtype: list[entity.Entity]
    """
    obstacles = []
    for foreign_entity in game_map.all_planets() + game_map.all_own_ships() + move_targets:
        if foreign_entity == target:
            continue
        if hlt.collision.intersect_segment_circle(ship, target, foreign_entity, fudge=ship.radius + fudge):
            obstacles.append(foreign_entity)
예제 #10
0
import hlt
import logging
from collections import OrderedDict

game = hlt.Game("The Abyss_v6_start")
logging.info("Go Abyss bot")

#### TO DO ADD GOING TO VULNERABLE PLANETS AND TEAM STUFF####
### ADD VIABLE PLANETS TO ALL PLANETS LISTS NECESSARY###

# This function gets list of planets in order of size by radius starting with the max #


def largest_dockable_planet(planets):
    if planets:
        return max([planet for planet in planets if not planet.is_owned()], key=lambda x: x.radius)
    else:
        return None


#This fuction is used when I want to travel to/ dock on a planet.  I also gave the option of using a speed less than the constant max#

def docking(target_planet, less_than):
    # if target_planet.get_remaining_resources() != 0:
    if ship.can_dock(target_planet):
        command_queue.append(ship.dock(target_planet))
    else:
        navigate_command = ship.navigate(
            ship.closest_point_to(target_planet),
            game_map,
            speed=int(hlt.constants.MAX_SPEED + less_than),
예제 #11
0
import hlt
import logging
import custom_entities
import time

game = hlt.Game("Custom_Bot_V8")
my_map = custom_entities.Map(game.map)
logging.info("Starting the bot")
game_map = game.update_map()
dispatch = custom_entities.Dispatch(game_map, my_map)
dispatch.update(game_map)
logging.info("getting targets in MyBot")
dispatch.get_targets()
logging.info("sending commands in MyBot")
game.send_command_queue(dispatch.get_commands())


while True:
    begin = time.time()
    game_map = game.update_map()
    dispatch.update(game_map)
    dispatch.get_targets()
    command_queue = dispatch.get_commands()

    end = time.time()
    logging.info("whole turn time: " + str(end - begin))

    game.send_command_queue(command_queue)
예제 #12
0
1. Initialize game
2. If a ship is not docked and there are unowned planets
2.a. Try to Dock in the planet if close enough
2.b If not, go towards the planet

Note: Please do not place print statements here as they are used to communicate with the Halite engine. If you need
to log anything use the logging module.
"""
# Let's start by importing the Halite Starter Kit so we can interface with the Halite engine
import hlt
# Then let's import the logging module so we can print out information
import logging

# GAME START
# Here we define the bot's name as Settler and initialize the game, including communication with the Halite engine.
game = hlt.Game("Idle")
# Then we print our start message to the logs
logging.info("Starting my Idle bot!")

while True:
    # TURN START
    # Update the map for the new turn and get the latest version
    game_map = game.update_map()

    # Here we define the set of commands to be sent to the Halite engine at the end of the turn
    command_queue = []
    # For every ship that I control
    game.send_command_queue(command_queue)
    # TURN END
# GAME END
예제 #13
0
        target = np.array([reward])

        self.critic.fit([prior_state, action],
                        target,
                        batch_size=1,
                        epochs=1,
                        verbose=0)

    def update_target(self):
        weights = self.model.get_weights()
        self.target_model.set_weights(weights)


# GAME START
# Here we define the bot's name as Settler and initialize the game, including communication with the Halite engine.
game = hlt.Game("Xan")
# Then we print our start message to the logs
logging.info("Starting my Xan bot!")


def distance2(x1, y1, x2, y2):
    return (x1 - x2)**2 + (y1 - y2)**2


def distance(x1, y1, x2, y2):
    return math.sqrt(distance2(x1, y1, x2, y2))


def angle_between(x1, y1, x2, y2):
    return math.degrees(math.atan2(y2 - y1, x2 - x1)) % 360
예제 #14
0
import hlt
import bot_utils
import logging
import copy

game = hlt.Game("Settler-Improved")

"""
TO TEST IF A MORE EXPANSIVE SETTLING STRATEGY IS USEFUL - RESULT: NO
"""

# PARAMETERS
# strategic parameters
defensive_action_radius = 33.2
max_response = 5
safe_docking_distance = 10.9
job_base_benefit = 80.7
fighting_relative_benefit = 1.5
available_ships_for_rogue_mission_trigger = 12

# micro movement parameters
general_approach_dist = 3.7
planet_approach_dist = 3.46
leader_approach_dist = 0.8
tether_dist = 2.0
padding = 0.14
motion_ghost_points = 4

# navigation parameters
angular_step = 5
horizon_reduction_factor = 0.99
예제 #15
0
import logging
import signal

import hlt

game = hlt.Game('TomFaulknerBot')
logging.info('Starting Tombot!')

destination_by_ship_id = {}


def get_undocked_ships(ships):
    """Returns an iterable of undocked ships from the given list of ships."""
    for ship in ships:
        if ship.docking_status == hlt.entity.Ship.DockingStatus.UNDOCKED:
            yield ship


def get_owned_planets(planets):
    """Returns an iterable of owned planets from the given planets."""
    for planet in planets:
        if planet.is_owned():
            yield planet


def get_unowned_planets(planets):
    """Returns an iterable of unowned planets from the given planets."""
    for planet in planets:
        if not planet.is_owned():
            yield planet
예제 #16
0
from keras.models import load_model

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '99'
tf.logging.set_verbosity(tf.logging.ERROR)

from keras.backend.tensorflow_backend import set_session
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.4
set_session(tf.Session(config=config))

model = load_model('model_checkpoint_128_batch_10_epochs.h5')

VERSION = 1

HM_ENT_FEATURES = 5
game = hlt.Game("Charles-AI-{}".format(VERSION))
logging.info("CharlesBot-{} Start".format(VERSION))

PCT_CHANGE_CHANCE = 5
DESIRED_SHIP_COUNT = 20

ship_plans = {}


def handle_list(l):
    new_list = []
    for i in range(HM_ENT_FEATURES):
        try:
            new_list.append(l[i])
        except:
            new_list.append(-99)
예제 #17
0
2.a. Try to Dock in the planet if close enough
2.b If not, go towards the planet

Note: Please do not place print statements here as they are used to communicate with the Halite engine. If you need
to log anything use the logging module.
"""
# Let's start by importing the Halite Starter Kit so we can interface with the Halite engine
import hlt
# Then let's import the logging module so we can print out information
import logging

from collections import OrderedDict

# GAME START
# Here we define the bot's name as Settler and initialize the game, including communication with the Halite engine.
game = hlt.Game("Settler V4")
# Then we print our start message to the logs
logging.info("Starting my Settler bot!")

while True:
    # TURN START
    # Update the map for the new turn and get the latest version
    game_map = game.update_map()

    # Here we define the set of commands to be sent to the Halite engine at the end of the turn
    command_queue = []
    # For every ship that I control
    for ship in game_map.get_me().all_ships():
        # If the ship is docked
        if ship.docking_status != ship.DockingStatus.UNDOCKED:
            # Skip this ship
예제 #18
0
# Python 3.6
import hlt  #main halite stuff
from hlt import constants  # halite constants
from hlt.positionals import Direction  # helper for moving
from hlt.positionals import Position

import random  # randomly picking a choice for now.
import logging  # logging stuff to console

import numpy as np
import time
import secrets

game = hlt.Game()  # game object
# Initializes the game
game.ready("Sentdebot-ML")

map_settings = {32: 400, 40: 425, 48: 450, 56: 475, 64: 500}

TOTAL_TURNS = 50
SAVE_THRESHOLD = 4100
MAX_SHIPS = 1
SIGHT_DISTANCE = 16

#specify direction order
direction_order = [
    Direction.North, Direction.South, Direction.East, Direction.West,
    Direction.Still
]

training_data = []
예제 #19
0
# Greedy solution for capturing closes planets first.

import time
import hlt
import logging
from hlt.entity import Position


game = hlt.Game("AM-Random-8")


def dest(a, b):
    x = a.x - b.x
    y = a.y - b.y
    return (x * x) + (y * y)


def navigate_planet(ship, planet, game_map):
    c = ship.navigate(
        ship.closest_point_to(planet),
        game_map,
        speed=int(hlt.constants.MAX_SPEED),
        ignore_ships=False)
    if not c:
        logging.warning("Couldn't navigate planet %s with ship %s" % (planet.id, ship.id))
    return c


def attack_planet(ship, planet, game_map):
    p = Position(planet.x, planet.y)
    c = ship.navigate(
예제 #20
0
import hlt
import logging
import time

game = hlt.Game("Gabeb v.7")


def is_docked(ship):
    '''
    Takes a Ship Entity object as an input
    returns true if the ship is docked
    '''
    return ship.docking_status != ship.DockingStatus.UNDOCKED


def get_closest_entities(game_map, ship):
    '''
    Given the current game map and a ship entity
    returns a list of planets in order from
    closest to farthest (from the ship)
    '''
    # Get dictionary of all entities with distances
    d = game_map.nearby_planets_by_distance(ship)
    # Now, we want to turn this into a list of tuples,
    # Sorted by the distances
    d = sorted(d.items(), key=lambda x: x[0])
    planets = [e[1][0] for e in d]

    return planets

예제 #21
0
                      })

    def update_targets(self):
        actor_weights = self.actor.get_weights()
        critic_weights = self.critic.get_weights()

        self.actor_target.set_weights(actor_weights)
        self.critic_target.set_weights(critic_weights)


sess = tf.Session()
K.set_session(sess)

# GAME START
# Here we define the bot's name as Settler and initialize the game, including communication with the Halite engine.
game = hlt.Game("Adadelta")
# Then we print our start message to the logs
logging.info("Starting my Adadelta bot!")

FEATURE_NAMES = [
    "health", "available_docking_spots", "remaining_production",
    "signed_current_production", "gravity", "closest_friendly_ship_distance",
    "closest_enemy_ship_distance", "ownership", "distance_from_center",
    "weighted_average_distance_from_friendly_ships", "is_active"
]


def distance2(x1, y1, x2, y2):
    return (x1 - x2)**2 + (y1 - y2)**2

예제 #22
0
# Read available model files
models = os.listdir('./models')
# Load the model for this bot version
model = load_model('./models/' + models[VERSION])

# Build lookup tables for sin/cos
COS_LOOKUP = {a: 8 * np.cos(np.deg2rad(a)) for a in np.arange(0, 360, 1)}
SIN_LOOKUP = {a: 8 * np.sin(np.deg2rad(a)) for a in np.arange(0, 360, 1)}

####
# GAME START
# Define the bot's name and initialize the game, including
# communication with the Halite engine.
# Set logging level for local hlt.networking.Game
game = hlt.Game("v{}".format(VERSION), logging.INFO)

# Put entire loop inside try/except so we can
# log errors (tracebacks from game are limited)
try:
    # Initial values, flag for having completed first turn
    me, turn, ran_once = None, 0, False

    # output_vector will be the output from the Keras NN
    # Each parameter adjusts how every ship handles game mechanics

    # Output vector for first turn
    output_vector = np.array([1.4, 1.0, 1.0, .58, 1.0, 1.0])
    #                      fill   attack  big  bastard  defend  kamikaze
    # fill: prefer filling planets over acquiring
    # attack: prefer attacking enemies over mining
예제 #23
0
def attack_zerg():
    return


def defend_zerg():
    return


def destory_the_weak():
    return


# GAME START
# Here we define the bot's name as Settler and initialize the game, including communication with the Halite engine.
game = hlt.Game("heckbot")
# Then we print our start message to the logs
logging.info("Now witness this moderately operational bot!")

while True:
    # TURN START
    # Update the map for the new turn and get the latest version
    game_map = game.update_map()

    # Here we define the set of commands to be sent to the Halite engine at the end of the turn
    command_queue = []

    # planets = self.get_planet()
    # logging.info(planets)

    # get a list of players
예제 #24
0
import hlt
import logging
import numpy as np
from hlt.utils import Struct, get_centroid
from hlt.constants import *
import time, os, subprocess
import random

VERSION = os.path.basename(__file__).strip('.py')

COS_LOOKUP = {a: 8 * np.cos(np.deg2rad(a)) for a in np.arange(0, 360, 1)}
SIN_LOOKUP = {a: 8 * np.sin(np.deg2rad(a)) for a in np.arange(0, 360, 1)}

UPLOADED = not os.path.isfile('clear.bat')

game = hlt.Game(VERSION, logging.INFO)

try:
    # if not UPLOADED():
    # from hlt.layers import Images
    # Layer = Images.Layer
    #
    # shape = [game.map.height * hlt.layers.PIXELS_PER_UNIT, game.map.width * hlt.layers.PIXELS_PER_UNIT]
    #
    # Images.load()
    #
    # def blank_map():
    #     ret = Layer(shape)
    #     ret.offset = 0
    #     return ret
    #
예제 #25
0
1. Initialize game
2. If a ship is not docked and there are unowned planets
2.a. Try to Dock in the planet if close enough
2.b If not, go towards the planet

Note: Please do not place print statements here as they are used to communicate with the Halite engine. If you need
to log anything use the logging module.
"""
# Let's start by importing the Halite Starter Kit so we can interface with the Halite engine
import hlt
# Then let's import the logging module so we can print out information
import logging

# GAME START
# Here we define the bot's name as Settler and initialize the game, including communication with the Halite engine.
game = hlt.Game("Settler")
# Then we print our start message to the logs
logging.info("Starting my Settler bot!")

while True:
    # TURN START
    # Update the map for the new turn and get the latest version
    game_map = game.update_map()

    # Here we define the set of commands to be sent to the Halite engine at the end of the turn
    command_queue = []
    # For every ship that I control
    logging.info('I have %d ships' % len(game_map.get_me().all_ships()))
    for ship in game_map.get_me().all_ships():
        # If the ship is docked
        if ship.docking_status != ship.DockingStatus.UNDOCKED:
예제 #26
0
2.a. Try to Dock in the planet if close enough
2.b If not, go towards the planet

Note: Please do not place print statements here as they are used to communicate with the Halite engine. If you need
to log anything use the logging module.
"""
# Let's start by importing the Halite Starter Kit so we can interface with the Halite engine
import hlt
# Then let's import the logging module so we can print out information
import logging

from collections import OrderedDict

planetas_naves = []

game = hlt.Game("Settler V16")
game_map = 0

team_ships = []


def funcion_relevancia(nave, planeta):
    numero_naves_puerto = 1
    for p in planetas_naves:
        if p.id == planeta.id:
            numero_naves_puerto += 1
    distancia = nave.calculate_distance_between(planeta)

    tiempo = distancia / 7 + 12 / numero_naves_puerto

    return tiempo
예제 #27
0
import hlt
import logging
from collections import OrderedDict
game = hlt.Game("MyBot-attStrongerV8")
logging.info("Starting MyBot-attStrongerV8")


def bestOtherPlayer(players, myId):
    maxShip = -1
    for player in players:
        if player != myId and len(player.all_ships()) > maxShip:
            maxShip = len(player.all_ships())
            bestOtherPlayerId = player
    return bestOtherPlayerId


cpt = 0
while cpt < 500:
    game_map = game.update_map()
    command_queue = []
    myId = game_map.get_me()
    #if cpt % 5 == 0:
    bestOtherPlayerId = bestOtherPlayer(game_map.all_players(), myId)

    allPlanets = game_map.all_planets()
    num_docking_spots_planets = {}
    places = 0
    for planet in allPlanets:
        num_docking_spots_planets[planet.id] = planet.num_docking_spots - len(
            planet._docked_ship_ids) + 1
        places += planet.num_docking_spots - len(planet._docked_ship_ids) + 1
예제 #28
0
import hlt
import logging
from collections import OrderedDict
game = hlt.Game("Infinitum-V6")
logging.info("Starting SentdeBot")
turnCount = 0

while True:
    game_map = game.update_map()
    num_attackships = int(len(game_map.get_me().all_ships()) * .4)

    team_attackships = game_map.get_me().all_ships()[0:num_attackships]
    mining_ships = game_map.get_me().all_ships(
    )[num_attackships:len(game_map.get_me().all_ships())]
    command_queue = []
    myplanets = []
    for ship in game_map.get_me().all_ships():
        shipid = ship.id
        if ship.docking_status != ship.DockingStatus.UNDOCKED:
            # Skip this ship
            continue

        entities_by_distance = game_map.nearby_entities_by_distance(ship)
        entities_by_distance = OrderedDict(
            sorted(entities_by_distance.items(), key=lambda t: t[0]))

        closest_empty_planets = [
            entities_by_distance[distance][0]
            for distance in entities_by_distance
            if isinstance(entities_by_distance[distance][0], hlt.entity.Planet)
            and not entities_by_distance[distance][0].is_owned()
예제 #29
0
파일: MyBot.py 프로젝트: Jaraz/JarBot
                #logging.info("depo ship {} order {}".format(ship.id, orderList[ship.id]))
                finalOrder.append(ship.move(orderList[ship.id]))

        else:
            finalOrder.append(ship.move(orderList[ship.id]))
        nextTurnPosition[ship.id] = game_map.normalize(
            ship.position.directional_offset(orderList[ship.id]))

    #logging.info("order list {}, next turn pos{}".format(orderList, nextTurnPosition))
    return finalOrder, nextTurnPosition


""" <<<Game Begin>>> """

# This game object contains the initial game state.
game = hlt.Game()

################
### Settings ###
################
shipBuildingTurns = 90  # how many turns to build ships
collectingStop = 80  # Ignore halite less than this
returnHaliteFlag = 950  # halite to return to base
DEPO_DISTANCE_DELTA = 0
DEPO_PERCENTILE = 75
DEPO_MIN_SHIPS = 4

#DEPOs
MAX_DEPO = 3
DEPO_HALITE_LOOK = 5
DEPO_HALITE = 100
예제 #30
0
# Import hlt, logging and OrderDict to run gamebot
import hlt
import logging
from collections import OrderedDict
# Start the game
game = hlt.Game("SentdeBot-V1")
logging.info("Starting SentdeBot")

# Game Loop
while True:
    game_map = game.update_map()
    command_queue = []
    
    for ship in game_map.get_me().all_ships():
        shipid = ship.id
        if ship.docking_status != ship.DockingStatus.UNDOCKED:
            # Skip this ship
            continue

        # Create Lists for navigational purposes
        entities_by_distance = game_map.nearby_entities_by_distance(ship)
        entities_by_distance = OrderedDict(sorted(entities_by_distance.items(), key=lambda t: t[0]))
        
        closest_empty_planets = [entities_by_distance[distance][0] for distance in entities_by_distance
                                 if isinstance(entities_by_distance[distance][0], hlt.entity.Planet)
                                 and not entities_by_distance[distance][0].is_owned()]

        team_ships = game_map.get_me().all_ships()
        closest_enemy_ships = [entities_by_distance[distance][0] for distance in entities_by_distance
                               if isinstance(entities_by_distance[distance][0], hlt.entity.Ship)
                               and entities_by_distance[distance][0] not in team_ships]