예제 #1
0
파일: heuristics.py 프로젝트: dimtion/jml
def update_dists_from_each(dists_matrix, routes_matrix, new_location, maze_map, coins):
    routing_table, dists_table = algo.dijkstra(maze_map, new_location)
    dists_matrix[new_location] = {}
    routes_matrix[new_location] = {}
    for loc in coins:
        route = u.way_width(routing_table, new_location, loc)

        dists_matrix[new_location][loc] = dists_table[loc]
        routes_matrix[new_location][loc] = route

        dists_matrix[loc][new_location] = dists_table[loc]
        routes_matrix[loc][new_location] = [l for l in reversed(route[:-1])] + [new_location]
    return dists_matrix, routes_matrix
예제 #2
0
def update_dists_from_each(dists_matrix, routes_matrix, new_location, maze_map,
                           coins):
    routing_table, dists_table = algo.dijkstra(maze_map, new_location)
    dists_matrix[new_location] = {}
    routes_matrix[new_location] = {}
    for loc in coins:
        route = u.way_width(routing_table, new_location, loc)

        dists_matrix[new_location][loc] = dists_table[loc]
        routes_matrix[new_location][loc] = route

        dists_matrix[loc][new_location] = dists_table[loc]
        routes_matrix[loc][new_location] = [l for l in reversed(route[:-1])
                                            ] + [new_location]
    return dists_matrix, routes_matrix
예제 #3
0
def dists_from_each(locations, maze_map):
    """ Return the dists and routes from each locations
    TODO :
    - Cache routes and dists
    """
    dists_matrix = {l: {} for l in locations}
    routes_matrix = {l: {} for l in locations}

    for i in range(len(locations)):
        l1 = locations[i]
        routing_table, dists_table = algo.dijkstra(maze_map, l1)

        for j in range(i + 1, len(locations)):
            l2 = locations[j]
            route = u.way_width(routing_table, l1, l2)

            dists_matrix[l1][l2] = dists_table[l2]
            routes_matrix[l1][l2] = route

            dists_matrix[l2][l1] = dists_table[l2]
            routes_matrix[l2][l1] = [l for l in reversed(route[:-1])] + [l1]

    return dists_matrix, routes_matrix
예제 #4
0
파일: geneticsTry.py 프로젝트: dimtion/jml
def dists_from_each(locations, maze_map):
    """ Return the dists and routes from each locations
    TODO :
    - Cache routes and dists
    """
    dists_matrix = {l: {} for l in locations}
    routes_matrix = {l: {} for l in locations}

    for i in range(len(locations)):
        l1 = locations[i]
        routing_table, dists_table = algo.dijkstra(maze_map, l1)

        for j in range(i + 1, len(locations)):
            l2 = locations[j]
            route = u.way_width(routing_table, l1, l2)

            dists_matrix[l1][l2] = dists_table[l2]
            routes_matrix[l1][l2] = route

            dists_matrix[l2][l1] = dists_table[l2]
            routes_matrix[l2][l1] = [l for l in reversed(route[:-1])] + [l1]

    return dists_matrix, routes_matrix
예제 #5
0
파일: dijkstra.py 프로젝트: dimtion/jml
def initializationCode(mazeWidth, mazeHeight, mazeMap, timeAllowed,
                       playerLocation, opponentLocation, coins):
    global route
    routingTable = algo.dijkstra(mazeMap, playerLocation)
    route = u.way_width(routingTable, playerLocation, (0, mazeWidth - 1))
예제 #6
0
def determineNextMove(playerLocation, opponentLocation, coins):
    global route, currentcoin
    if coinsNumber != len(coins):
        routingTable = algo.dijkstra(mazeMap, playerLocation)
        route = u.way_width(routingTable, playerLocation, coins[0])
    return u.direction(playerLocation, route.pop(0))
예제 #7
0
파일: pathWidth.py 프로젝트: dimtion/jml
def initializationCode(mazeWidth, mazeHeight, mazeMap, timeAllowed, playerLocation, opponentLocation, coins):
    global route
    route_table = algo.pathWidth(mazeMap, playerLocation, data_struct=u.Queue)
    route = u.way_width(route_table, playerLocation, (0, mazeWidth - 1))
예제 #8
0
파일: dijkstra.py 프로젝트: dimtion/jml
def initializationCode (mazeWidth, mazeHeight, mazeMap, timeAllowed, playerLocation, opponentLocation, coins) :
    global route
    routingTable = algo.dijkstra(mazeMap, playerLocation)
    route = u.way_width(routingTable, playerLocation, (0, mazeWidth - 1))
예제 #9
0
def initializationCode(mazeWidth, mazeHeight, mazeMap, timeAllowed,
                       playerLocation, opponentLocation, coins):
    global route
    route_table = algo.pathWidth(mazeMap, playerLocation, data_struct=u.Queue)
    route = u.way_width(route_table, playerLocation, (0, mazeWidth - 1))
예제 #10
0
def determineNextMove(playerLocation, opponentLocation, coins):
    global route, currentcoin
    if coinsNumber != len(coins):
        routingTable = algo.dijkstra(mazeMap, playerLocation)
        route = u.way_width(routingTable, playerLocation, coins[0])
    return u.direction(playerLocation, route.pop(0))