diff --git a/reborn.py b/reborn.py index 8032b52..10286b2 100755 --- a/reborn.py +++ b/reborn.py @@ -287,15 +287,16 @@ def newTurn(): #log("Drones", ", ".join(availableDrones), "("+str(len(availableDrones))+")", "are available") # Algorithm that only works for 1 warehouse +CLIENT_TRIES = 3 # Determined by trial and error. Not really reliable def route(roadmap): # Find the nearest client that still has things to be delivered remainingClients = [c for c in Client.near(roadmap['pos']) if c.plannedNeeds and c not in roadmap['clients']] - if remainingClients: - client = remainingClients[0] + #for client in remainingClients: + for client in remainingClients[:CLIENT_TRIES]: # Create a pack to deliver pack = client.pack(Drone.PAYLOAD - Product.totalWeight(roadmap['loads'])) if not pack: - return roadmap + continue # Plan the delivery roadmap['warehouse'].plan(pack) client.plan(pack) @@ -305,8 +306,7 @@ def route(roadmap): roadmap['clients'].append(client) roadmap['stops'].append((client, pack)) return route(roadmap) - else: - return roadmap + return roadmap def think():