def process_slice(z):
	print 'Processing:',z
	_runs = 0
	_slice = create_map_array(flat=True)
	
	while 1:
		WORLD_INFO['zoneid'] += 1
		_z_id = WORLD_INFO['zoneid']
		_ramps = []
		_start_pos = get_unzoned(_slice, z)
		
		if not _start_pos:
			if 'slice' in sys.argv:
				draw_slice(_slice)
			
			if 'map' in sys.argv:
				draw_map(MAP, z)
			
			print '\tRuns:',_runs,'Time:',
			break
		
		_slice[_start_pos[0]][_start_pos[1]] = _z_id
		
		_changed = True
		while _changed:
			_runs += 1
			_changed = False
			
			for x in range(MAP_SIZE[0]):
				for y in range(MAP_SIZE[1]):
					if z < MAP_SIZE[2]-1 and WORLD_INFO['map'][x][y][z+1]:
						if z < MAP_SIZE[2]-2 and WORLD_INFO['map'][x][y][z+2]:
							_slice[x][y] = -2
						else:
							_slice[x][y] = -1
					
					if not _slice[x][y] == _z_id:
						continue
					
					for x_mod,y_mod in [(-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1)]:
						_x = x+x_mod
						_y = y+y_mod
						
						if _x<0 or _x>=MAP_SIZE[0] or _y<0 or _y>=MAP_SIZE[1]:
							continue
						
						if WORLD_INFO['map'][_x][_y][z] and not (_slice[_x][_y] == _z_id or _slice[_x][_y] == -1):
							_slice[_x][_y] = _z_id
							_changed = True
						
						#Above, Below
						if z < MAP_SIZE[2]-1 and WORLD_INFO['map'][_x][_y][z+1]:
							if z < MAP_SIZE[2]-2 and WORLD_INFO['map'][_x][_y][z+2]:
								pass
							else:
								_ramps.append((_x, _y, z+1))
								continue
						
						if z and not WORLD_INFO['map'][_x][_y][z] and WORLD_INFO['map'][_x][_y][1-z]:
							_ramps.append((_x, _y, z-1))
	
		WORLD_INFO['slices'][_z_id] = {'z': z, 'id': _z_id, 'map': _slice, 'ramps': _ramps, 'neighbors': {}}
		
		if 'ramp' in sys.argv:
			draw_ramps(_ramps)
			print
dataset/ETHPy150Open flags/Reactor-3/tests/M06_zonepath.py/process_slice/swapped operands of `-`