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
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
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
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))
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))
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))
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))