Load&Unload by sets
This commit is contained in:
parent
726474abb9
commit
f25aca1c31
11
reborn.py
11
reborn.py
|
@ -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
|
||||
|
|
Reference in a new issue