def get_closest_resources_church(pprint,loc,robot_map,full_map,fuel_map,karbonite_map): closest_resources=[] #ill get the closest resources in a radius of 25, then ill go through that list and make all the resources in a radius of two, #then each castle or church should send pilgrims to any in their radius two circle then send three more out to the next two elements #on the radius 25 list x_start=loc[0]-2 x_end=loc[0]+3 y_start=loc[1]-2 y_end=loc[1]+3 if x_start<0: x_start=0 if y_start<0: y_start=0 if x_end>len(full_map): x_end=len(full_map) if y_end>len(full_map): y_end=len(full_map) for x in range(x_start,x_end): for y in range(y_start,y_end): if (fuel_map[y][x] or karbonite_map[y][x]) and robot_map[y][x]<=0: closest_resources.append((x,y)) #now have order both lists by distance util.insertionSortLoc(pprint, closest_resources, loc) # quickSort(closest_resources,closest_resources[0],closest_resources[len(closest_resources)+1],loc) # quickSort(closest_resources_large,closest_resources_large[0],closest_resources_large[len(closest_resources_large)+1],loc) return closest_resources
def sortedResources(pprint, karb_map, fuel_map, loc): size = len(karb_map) lst1 = [] for y in range(size): for x in range(size): if karb_map[y][x]: # or fuel_map[y][x]: lst1.append((x, y)) util.insertionSortLoc(pprint, lst1, loc) return lst1
def get_closest_resources_pilgrim(pprint, loc, robot_map, full_map, fuel_map, karbonite_map): closest_resources_large = [] #getting all the closest resources where a pilgrim is if x_end > len(full_map): x_end = len(full_map) if y_end > len(full_map): y_end = len(full_map) for x in range(0, len(full_map)): for y in range(0, len(full_map)): if (fuel_map[y][x] or karbonite_map[y][x]) and robot_map[y][x] <= 0: closest_resources_large.append((x, y)) util.insertionSortLoc(pprint, closest_resources_large, loc) # quickSort(closest_resources,closest_resources[0],closest_resources[len(closest_resources)+1],loc) # quickSort(closest_resources_large,closest_resources_large[0],closest_resources_large[len(closest_resources_large)+1],loc) return closest_resources_large
def get_closest_resources(pprint,loc,full_map,fuel_map,karbonite_map): closest_resources=[] closest_resources_large=[] all_resources = [] for i in range(len(fuel_map)): for k in range(len(fuel_map)): if fuel_map[i][k] or karbonite_map[i][k]: all_resources.append((k,i)) #ill get the closest resources in a radius of 25, then ill go through that list and make all the resources in a radius of two, #then each castle or church should send pilgrims to any in their radius two circle then send three more out to the next two elements #on the radius 25 list x_start=loc[0]-(len(full_map)//2) y_start=loc[1]-(len(full_map)//2) if x_start<0: x_start=0 if y_start<0: y_start=0 x_end=loc[0]+(len(full_map)//2) y_end=loc[1]+(len(full_map)//2) if x_end>len(full_map): x_end=len(full_map) if y_end>len(full_map): y_end=len(full_map) for x in range(x_start,x_end): for y in range(y_start,y_end): if fuel_map[y][x] or karbonite_map[y][x]: # pprint("Adding Resource: " + str([x,y])) closest_resources_large.append((x,y)) x_start=loc[0]-2 x_end=loc[0]+3 y_start=loc[1]-2 y_end=loc[1]+3 if x_start<0: x_start=0 if y_start<0: y_start=0 if x_end>len(full_map): x_end=len(full_map) if y_end>len(full_map): y_end=len(full_map) for x in range(x_start,x_end): for y in range(y_start,y_end): if fuel_map[y][x] or karbonite_map[y][x]: closest_resources.append((x,y)) #now have order both lists by distance util.insertionSortLoc(pprint, closest_resources, loc) util.insertionSortLoc(pprint, closest_resources_large, loc) util.insertionSortLoc(pprint, all_resources, loc) # quickSort(closest_resources,closest_resources[0],closest_resources[len(closest_resources)+1],loc) # quickSort(closest_resources_large,closest_resources_large[0],closest_resources_large[len(closest_resources_large)+1],loc) if len(closest_resources)<len(closest_resources_large): closest_resources.append(closest_resources_large[len(closest_resources)]) if len(closest_resources)<len(closest_resources_large): closest_resources.append(closest_resources_large[len(closest_resources)]) # pprint("my closest resources are "+ str(closest_resources) + " with a location of: " + str(loc)) # pprint(str(closest_resources_large)) return closest_resources_large