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
pack = client.pack()
# Plan the delivery
# TODO Optimise for same product wanted more than once
for i in pack:
drone.addTask('load', warehouse, Product.get(i), 1)
packOccurences = dict((i, pack.count(i)) for i in pack)
# From http://stackoverflow.com/a/7843090/2766106
for i in packOccurences:
drone.addTask('load', warehouse, Product.get(i), packOccurences[i])
warehouse.plan(pack)
for i in pack:
drone.addTask('deliver', client, Product.get(i), 1)
for i in packOccurences:
drone.addTask('deliver', client, Product.get(i), packOccurences[i])
client.plan(pack)
else:
global done