예제 #1
0
def determineNextMove(playerLocation, opponentLocation, coins):
    global route, old_coins, playerScore, enemyScore
    u.update_dists_from_each(dists_matrix, route_matrix, playerLocation, mazeMap, coins)
    u.update_dists_from_each(dists_matrix, route_matrix, opponentLocation, mazeMap, coins + [playerLocation])

    # Calculate our score and en score :
    if playerLocation in old_coins and playerLocation not in coins:
        playerScore += 1
    if opponentLocation in old_coins and opponentLocation not in coins:
        enemyScore += 1

    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)
예제 #2
0
파일: closest.py 프로젝트: dimtion/jml
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)
예제 #3
0
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)
예제 #4
0
def determineNextMove(playerLocation, opponentLocation, coins):
    """Function called at each turn, must return the next move of the player"""
    global packages, dists, route_table, best_path, best_weight, current_package

    if playerLocation in current_package:
        current_package.remove(playerLocation)

    i1, i2, j1, j2 = find_players(packages, opponentLocation, playerLocation)
    if i1 >= 0:
        packages[i1].remove(packages[i1][i2])
        if len(packages[i1]) == 0:
            packages.remove(packages[i1])
    if j1 >= 0:
        api.debug(packages[j1])
        packages[j1].remove(packages[j1][j2])
        if len(packages[j1]) == 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))
예제 #5
0
파일: f_closest2.py 프로젝트: dimtion/jml
def determineNextMove(playerLocation, opponentLocation, coins):
    """܁ ­ ͏ ­͏  ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏       ͏­­ ­   ͏   ͏­͏ ͏͏   ͏­ ͏ ͏ ͏­  ­ ͏ ͏ ͏ ͏­  ͏   ­   ­͏  ­ ͏ ͏   ­    ­­ ­   ͏   ­   ͏͏  ͏­  ͏   ­   ­͏   ­­ ­   ͏   ­   ͏͏   ­  ͏­  ͏   ­ ­ ­   ͏   ͏͏  ͏­͏ ­­       ͏          ͏­  ͏   ­ ­ ­   ͏   ͏­­ ­   ­   ­­       ͏          ͏­  ͏   ­ ­ ­   ͏܁
    Cette fonction܁   ͏   ­ ͏ ­ ͏ ­­       ͏          ͏͏   ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­͏  ͏ ­ ͏   ­   ­   ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏ ­ ͏­­ ͏­͏ ­   ͏͏  ͏­͏ ­   ͏    ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏    ͏͏ ͏   ͏   ͏   ͏   ­ ­ ͏­  ͏   ͏   ­   ͏͏  ­   ͏­͏ ­   ­   ͏͏   ͏͏ ͏   ͏   ͏   ͏   ͏͏  ­­ ܁
    est܁ ­    ͏͏ ͏   ͏   ͏   ͏   ­   ­ ͏ ­͏  ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­    ­­ ͏ ͏ ͏   ­­  ͏   ͏ ­ ͏­­ ͏   ͏   ͏ ­ ­ ­ ͏­͏ ͏­­ ­   ͏   ͏­͏ ͏͏  ­   ­͏  ­ ͏ ͏   ­    ­­ ­   ͏   ­   ͏͏  ͏­  ͏   ͏ ͏ ­ ͏ ͏͏­ ͏ ͏ ͏­  ͏   ͏ ͏ ­   ­   ͏ ͏ ͏­  ­͏  ͏ ͏ ͏͏  ͏­͏ ­ ͏ ͏   ͏   ͏   ͏͏  ͏͏   ͏͏ ͏   ͏   ͏   ͏   ͏   ­͏  ͏ ­ ͏܁
    plutot܁   ­   ­   ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­    ­­ ͏ ͏ ͏   ­­  ͏   ͏ ͏ ͏ ͏  ͏͏ ͏   ͏   ͏   ͏   ­ ­ ͏͏  ͏͏  ͏­  ͏   ͏   ͏­͏ ͏­­ ­   ͏   ­    ­­ ͏ ͏ ͏­͏ ­ ­ ­   ͏   ­ ͏ ­   ­ ­ ­ ­ ͏͏  ­   ͏͏  ͏͏  ­ ͏ ͏   ͏­  ­   ͏­  ͏   ͏͏  ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏͏  ͏   ͏͏­ ­­  ͏   ­    ͏͏ ͏   ͏   ͏   ͏  ܁
    cool܁ ͏   ͏   ͏   ͏   ͏͏  ͏ ͏ ͏   ͏͏  ͏   ­­͏ ͏   ­   ­   ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏ ͏ ­ ͏ ͏   ͏   ͏͏­  ͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­   ­ ͏ ­͏  ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏ ͏ ͏͏  ͏   ­­  ͏   ͏ ­ ͏­­ ͏   ͏   ͏ ­ ­ ­ ͏­͏ ͏­­ ­   ͏   ͏­͏ ͏͏  ­   ­͏  ­܁
    en effet tout est dedans܁ ͏ ͏   ­    ­­ ­   ͏   ­   ͏͏  ͏­  ͏   ͏ ͏ ­ ­ ͏ ͏ ͏­  ͏   ͏ ͏ ­   ­   ͏ ͏ ͏­  ­͏  ͏ ͏ ͏͏   ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏ ͏ ͏͏  ͏­͏ ­ ­ ­ ͏ ͏͏  ­   ͏   ͏͏  ­ ͏ ͏   ͏­  ­   ͏­  ͏   ͏͏   ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏ ͏ ͏͏  ͏­͏ ͏ ­ ͏­  ͏­­ ­ ­ ͏   ͏͏  ͏͏   ͏͏ ͏   ͏   ͏  ܁
    mais il faut faire attention܁ ͏   ͏   ͏   ͏   ͏   ͏   ­͏  ͏ ­ ͏   ­   ­   ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­ ­ ͏­  ͏   ͏   ­   ͏͏  ­   ͏­͏ ­   ­   ͏͏   ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­   ­ ͏ ­͏  ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­    ­­ ͏ ͏ ͏   ­­  ͏   ͏ ­ ͏­­ ͏   ͏   ͏ ­ ­ ­ ͏­͏ ͏­­ ­   ͏   ͏܁
    car sinon on ne pourra rien décoder܁­͏ ͏͏  ­   ­͏  ­ ͏ ͏   ­    ­­ ­   ͏   ­   ͏͏  ͏­  ͏   ͏ ͏ ­ ͏ ͏͏­ ͏ ͏ ͏­  ͏   ͏ ͏ ­   ­   ͏ ͏ ͏­  ­͏  ͏ ͏ ͏͏  ͏­͏ ­ ͏ ͏   ͏   ͏   ͏͏  ͏͏   ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­͏  ͏ ­ ͏   ­   ­   ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­   ͏   ­ ­ ­ ­  ͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏    ͏͏܁
    de plus les jours nous sont comptés܁܁
    """
    global route
    load_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)
예제 #6
0
파일: f_closest2.py 프로젝트: dimtion/jml
def determineNextMove(playerLocation, opponentLocation, coins):
    """܁ ­ ͏ ­͏  ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏       ͏­­ ­   ͏   ͏­͏ ͏͏   ͏­ ͏ ͏ ͏­  ­ ͏ ͏ ͏ ͏­  ͏   ­   ­͏  ­ ͏ ͏   ­    ­­ ­   ͏   ­   ͏͏  ͏­  ͏   ­   ­͏   ­­ ­   ͏   ­   ͏͏   ­  ͏­  ͏   ­ ­ ­   ͏   ͏͏  ͏­͏ ­­       ͏          ͏­  ͏   ­ ­ ­   ͏   ͏­­ ­   ­   ­­       ͏          ͏­  ͏   ­ ­ ­   ͏܁
    Cette fonction܁   ͏   ­ ͏ ­ ͏ ­­       ͏          ͏͏   ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­͏  ͏ ­ ͏   ­   ­   ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏ ­ ͏­­ ͏­͏ ­   ͏͏  ͏­͏ ­   ͏    ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏    ͏͏ ͏   ͏   ͏   ͏   ­ ­ ͏­  ͏   ͏   ­   ͏͏  ­   ͏­͏ ­   ­   ͏͏   ͏͏ ͏   ͏   ͏   ͏   ͏͏  ­­ ܁
    est܁ ­    ͏͏ ͏   ͏   ͏   ͏   ­   ­ ͏ ­͏  ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­    ­­ ͏ ͏ ͏   ­­  ͏   ͏ ­ ͏­­ ͏   ͏   ͏ ­ ­ ­ ͏­͏ ͏­­ ­   ͏   ͏­͏ ͏͏  ­   ­͏  ­ ͏ ͏   ­    ­­ ­   ͏   ­   ͏͏  ͏­  ͏   ͏ ͏ ­ ͏ ͏͏­ ͏ ͏ ͏­  ͏   ͏ ͏ ­   ­   ͏ ͏ ͏­  ­͏  ͏ ͏ ͏͏  ͏­͏ ­ ͏ ͏   ͏   ͏   ͏͏  ͏͏   ͏͏ ͏   ͏   ͏   ͏   ͏   ­͏  ͏ ­ ͏܁
    plutot܁   ­   ­   ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­    ­­ ͏ ͏ ͏   ­­  ͏   ͏ ͏ ͏ ͏  ͏͏ ͏   ͏   ͏   ͏   ­ ­ ͏͏  ͏͏  ͏­  ͏   ͏   ͏­͏ ͏­­ ­   ͏   ­    ­­ ͏ ͏ ͏­͏ ­ ­ ­   ͏   ­ ͏ ­   ­ ­ ­ ­ ͏͏  ­   ͏͏  ͏͏  ­ ͏ ͏   ͏­  ­   ͏­  ͏   ͏͏  ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏͏  ͏   ͏͏­ ­­  ͏   ­    ͏͏ ͏   ͏   ͏   ͏  ܁
    cool܁ ͏   ͏   ͏   ͏   ͏͏  ͏ ͏ ͏   ͏͏  ͏   ­­͏ ͏   ­   ­   ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏ ͏ ­ ͏ ͏   ͏   ͏͏­  ͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­   ­ ͏ ­͏  ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏ ͏ ͏͏  ͏   ­­  ͏   ͏ ­ ͏­­ ͏   ͏   ͏ ­ ­ ­ ͏­͏ ͏­­ ­   ͏   ͏­͏ ͏͏  ­   ­͏  ­܁
    en effet tout est dedans܁ ͏ ͏   ­    ­­ ­   ͏   ­   ͏͏  ͏­  ͏   ͏ ͏ ­ ­ ͏ ͏ ͏­  ͏   ͏ ͏ ­   ­   ͏ ͏ ͏­  ­͏  ͏ ͏ ͏͏   ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏ ͏ ͏͏  ͏­͏ ­ ­ ­ ͏ ͏͏  ­   ͏   ͏͏  ­ ͏ ͏   ͏­  ­   ͏­  ͏   ͏͏   ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏ ͏ ͏͏  ͏­͏ ͏ ­ ͏­  ͏­­ ­ ­ ͏   ͏͏  ͏͏   ͏͏ ͏   ͏   ͏  ܁
    mais il faut faire attention܁ ͏   ͏   ͏   ͏   ͏   ͏   ­͏  ͏ ­ ͏   ­   ­   ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­ ­ ͏­  ͏   ͏   ­   ͏͏  ­   ͏­͏ ­   ­   ͏͏   ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­   ­ ͏ ­͏  ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­    ­­ ͏ ͏ ͏   ­­  ͏   ͏ ­ ͏­­ ͏   ͏   ͏ ­ ­ ­ ͏­͏ ͏­­ ­   ͏   ͏܁
    car sinon on ne pourra rien décoder܁­͏ ͏͏  ­   ­͏  ­ ͏ ͏   ­    ­­ ­   ͏   ­   ͏͏  ͏­  ͏   ͏ ͏ ­ ͏ ͏͏­ ͏ ͏ ͏­  ͏   ͏ ͏ ­   ­   ͏ ͏ ͏­  ­͏  ͏ ͏ ͏͏  ͏­͏ ­ ͏ ͏   ͏   ͏   ͏͏  ͏͏   ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­͏  ͏ ­ ͏   ­   ­   ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏   ­   ͏   ­ ­ ­ ­  ͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏   ͏   ͏   ͏    ͏͏܁
    de plus les jours nous sont comptés܁܁
    """
    global route
    load_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)
예제 #7
0
파일: closest2.py 프로젝트: dimtion/jml
def determineNextMove(playerLocation, opponentLocation, coins):
    """
    Cette fonction
    est
    plutot
    cool
    en effet tout est dedans
    mais il faut faire attention
    car sinon on ne pourra rien décoder
    de plus les jours nous sont comptés
    """
    global route
    load_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)
예제 #8
0
def determineNextMove(playerLocation, opponentLocation, coins):
    """
    Cette fonction
    est
    plutot
    cool
    en effet tout est dedans
    mais il faut faire attention
    car sinon on ne pourra rien décoder
    de plus les jours nous sont comptés
    """
    global route
    load_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)
예제 #9
0
파일: packagev2.py 프로젝트: dimtion/jml
def determineNextMove(playerLocation, opponentLocation, coins):
    """Function called at each turn, must return the next move of the player"""
    global packages, dists, route_table, best_path, best_weight, current_package
    
    if playerLocation in current_package:
        current_package.remove(playerLocation)
        
    i1,i2,j1,j2  = find_players(packages, opponentLocation, playerLocation)
    if i1 >= 0:
        packages[i1].remove(packages[i1][i2])
        if len(packages[i1]) == 0:
            packages.remove(packages[i1])
    if j1 >= 0:
        api.debug(packages[j1])
        packages[j1].remove(packages[j1][j2])
        if len(packages[j1]) == 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))