Load&Unload by sets

This commit is contained in:
Geoffrey Frogeye 2016-02-13 15:54:35 +01:00
parent 726474abb9
commit f25aca1c31

View file

@ -292,12 +292,13 @@ def think():
# Create a pack to deliver # Create a pack to deliver
pack = client.pack() pack = client.pack()
# Plan the delivery # Plan the delivery
# TODO Optimise for same product wanted more than once packOccurences = dict((i, pack.count(i)) for i in pack)
for i in pack: # From http://stackoverflow.com/a/7843090/2766106
drone.addTask('load', warehouse, Product.get(i), 1) for i in packOccurences:
drone.addTask('load', warehouse, Product.get(i), packOccurences[i])
warehouse.plan(pack) warehouse.plan(pack)
for i in pack: for i in packOccurences:
drone.addTask('deliver', client, Product.get(i), 1) drone.addTask('deliver', client, Product.get(i), packOccurences[i])
client.plan(pack) client.plan(pack)
else: else:
global done global done