+ def dijkstra(speaker):
+ n_max = 255
+
+ map_size = game.map.size_i
+ dijkstra_map = [n_max for i in range(game.map.size_i)]
+ dijkstra_map[game.map.get_position_index(speaker.position)] = 0
+
+ shrunk = True
+ while shrunk:
+ shrunk = False
+ for i in range(map_size):
+ if game.map.terrain[i] == 'X':
+ continue
+ neighbors = game.map_geometry.get_neighbors_i(i)
+ for direction in [d for d in neighbors if neighbors[d]]:
+ j = neighbors[direction]
+ if dijkstra_map[j] < dijkstra_map[i] - 1:
+ dijkstra_map[i] = dijkstra_map[j] + 1
+ shrunk = True
+ #print('DEBUG')
+ #line_to_print = []
+ #x = 0
+ #for n in dijkstra_map:
+ # line_to_print += ['%3s' % n]
+ # x += 1
+ # if x >= game.map.size.x:
+ # x = 0
+ # print(' '.join(line_to_print))
+ # line_to_print = []
+ return dijkstra_map
+