Tries 3 different clients

This commit is contained in:
Geoffrey Frogeye 2016-02-13 17:40:19 +01:00
parent 6bd43ed2ad
commit 0d8cd171bb

View file

@ -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,7 +306,6 @@ def route(roadmap):
roadmap['clients'].append(client)
roadmap['stops'].append((client, pack))
return route(roadmap)
else:
return roadmap