def calculate_dijkstra_map(dijkstra):
	_map = dijkstra['map']
	_min_x = dijkstra['x_range'][0]
	_max_x = dijkstra['x_range'][1]
	_min_y = dijkstra['y_range'][0]
	_max_y = dijkstra['y_range'][1]
	_target_positions = [tuple(target['position']) for target in dijkstra['targets']]
	
	_i = 0
	while 1==1:
		_i += 1
		_orig_map = _map.copy()
		
		for _x in range(_min_x,_max_x):
			for _y in range(_min_y,_max_y):
				if (_x,_y) in _target_positions or _orig_map[_y-_min_y,_x-_min_x] == -1:
					
					continue
				
				_lowest_score = 9000
				
				for x1 in range(-1,2):
					x = _x+x1
					
					if 0>x or x>=_max_x:
						continue
					
					for y1 in range(-1,2):
						#if (x1,y1) in [(-1,-1),(1,-1),(-1,1),(1,1)]:
						#	continue
						
						y = _y+y1
						
						if 0>y or y>=_max_y or (x1,y1) == (0,0) or _orig_map[y-_min_y,x-_min_x] == -1:
							continue
						
						if _orig_map[y-_min_y,x-_min_x] < _lowest_score:
							_lowest_score = _orig_map[y-_min_y,x-_min_x]
				
				if _lowest_score>=0:
					if _orig_map[_y-_min_y,_x-_min_x]-_lowest_score>=2:
						_map[_y-_min_y,_x-_min_x] = _lowest_score+1
		
		if numpy.array_equal(_map,_orig_map):
			break
dataset/ETHPy150Open flags/Reactor-3/numbers.py/calculate_dijkstra_map/original