Пример #1
0
    coin = (-1,-1)
    for c in coins:
        if candidates[1][c] < dist:
            dist = candidates[1][c]
            coin = c
    coins.remove(coin)
    return u.way_width(candidates[0], playerLocation, coin)


def initialisationTurn(mazeWidth, mazeHeight, mazeMap, timeAllowed, playerLocation, opponentLocation, coins) :
    global route
    route = next_way(playerLocation, coins)


def determineNextMove(playerLocation, opponentLocation, coins):
    global route
    if len(route) == 0:
        route = next_way(playerLocation, coins)
    else: 
        ennemy_dists = algo.dijkstra(mazeMap, opponentLocation)
        if ennemy_dists[1][route[-1]] < len(route):
            route = next_way(playerLocation, coins)
    next_pos = route.pop(0)
    return u.direction(playerLocation, next_pos)

# Init our AI
initialisationTurn(mazeWidth, mazeHeight, mazeMap, preparationTime, playerLocation, opponentLocation, coins)

# Starts the game
interface.startGameMainLoop(determineNextMove)
Пример #2
0
    if len(route) == 0 or route[-1] not in coins or 1==1:
        winning_value, en_best_path, pl_best_path = minmax(coins, playerScore, 0, playerLocation, enemyScore, 0, opponentLocation)
        interface.debug("------------")
        interface.debug(pl_best_path)
        interface.debug(en_best_path)
        interface.debug("score of : " + str(winning_value))
        route = route_matrix[playerLocation][pl_best_path[0]]

    # coins_which_are_close = coins_close(playerLocation, coins, dists_matrix, limit=2)
    # closest_coin = None
    # for coin in coins_which_are_close:
    #     # If we don't already go there, and the enemy is not going there
    #     if dists_matrix[playerLocation][coin] < dists_matrix[opponentLocation][coin]:  # TODO : magic number, same : with the enemy
    #         if closest_coin is None or dists_matrix[playerLocation][coin] < dists_matrix[playerLocation][closest_coin]:
    #             closest_coin = coin
    # if closest_coin is not None:
    #     pass
    #     # route = route_matrix[playerLocation][closest_coin]
    #     # interface.debug("NEAR : " + str(closest_coin))

    old_coins = coins
    next_pos = route.pop(0)
    return u.direction(playerLocation, next_pos)

# Init our AI
initialisationTurn(mazeWidth, mazeHeight, mazeMap, preparationTime, playerLocation, opponentLocation, coins)

# Starts the game
interface.startGameMainLoop(determineNextMove)
Пример #3
0
            packages.remove(packages[j1])
                           
    if opponentLocation in current_package:
        dists, route_table = u.update_dists_from_each(dists, route_table, playerLocation, mazeMap, coins)
        if len(current_package) > 1:
            current_package.remove(opponentLocation)
        else:
            current_package = packages.pop(0)
        best_weight = float("inf")
        best_path = []
        exhaustive(current_package, playerLocation, [], 0, (route_table, dists))
           
    if len(best_path) == 0:
        packages = list(reversed(sorted(packages, key=lambda x: (len(x)+3)/min([dists[playerLocation][c] for c in x]))))
        best_weight = float("inf")
        best_path = []
        current_package = packages.pop(0)
        if len(current_package) == 1 and packages != []:
            current_package = current_package + packages.pop(0)
        exhaustive(current_package, playerLocation, [], 0, (route_table, dists))
    return u.direction(playerLocation, best_path.pop(0))    

    

# Init our AI
initialisationTurn(mazeWidth, mazeHeight, mazeMap, preparationTime, turnTime, playerLocation, opponentLocation, coins)

# Starts the game
api.startGameMainLoop(determineNextMove)
                   
Пример #4
0
            current_package = packages.pop(0)
        best_weight = float("inf")
        best_path = []
        exhaustive(current_package, playerLocation, [], 0,
                   (route_table, dists))

    if len(best_path) == 0:
        packages = list(
            reversed(
                sorted(
                    packages,
                    key=lambda x:
                    (len(x) + 3) / min([dists[playerLocation][c]
                                        for c in x]))))
        best_weight = float("inf")
        best_path = []
        current_package = packages.pop(0)
        if len(current_package) == 1 and packages != []:
            current_package = current_package + packages.pop(0)
        exhaustive(current_package, playerLocation, [], 0,
                   (route_table, dists))
    return u.direction(playerLocation, best_path.pop(0))


# Init our AI
initialisationTurn(mazeWidth, mazeHeight, mazeMap, preparationTime, turnTime,
                   playerLocation, opponentLocation, coins)

# Starts the game
api.startGameMainLoop(determineNextMove)