action = find_drone_action(state, d) if action == None: continue w, o, items_to_deliver = action turns_till_idle_again = 0 # drone has to get to the warehouse first turns_till_idle_again += distance(d.pos, w.pos) print(" * sending drone " + str(d.id) + " to warehouse " + str(w.id) + " at " + str(w.pos[0]) + "-" + str(w.pos[1]) + " (distance: " + str(distance(d.pos, w.pos)) + ")") # load stuff from warehouse for item in items_to_deliver: output.load(d.id, w.id, item.pt_id, 1) print(" * loading drone " + str(d.id) + " with product " + str(item.pt_id)) print(" $ stock of " + str(item.pt_id) + " at warehouse " + str(w.id) + " was " + str(w.stock[item.pt_id]) + ", is now " + str(w.stock[item.pt_id] - 1)) w.stock[item.pt_id] -= 1 # every load command takes one turn turns_till_idle_again += 1 # drone has to get to order turns_till_idle_again += distance(w.pos, o.pos) print(" * sending drone " + str(d.id) + " to order " + str(o.id) + " pos " + str(o.pos[0]) + "-" + str(o.pos[1]) + " (distance: " + str(distance(w.pos, o.pos)) + ")") # drone has to unload for item in items_to_deliver: output.deliver(d.id, o.id, item.pt_id, 1)
if chunk == None: continue w = chunk.w turns_till_idle_again = 0 # drone has to get to the warehouse first turns_till_idle_again += distance(d.pos, w.pos) print(" * sending drone " + str(d.id) + " to warehouse " + str(w.id) + " at " + str(w.pos[0]) + "-" + str(w.pos[1]) + " (distance: " + str(distance(d.pos, w.pos)) + ")") # load stuff from warehouse for pt_id, items in chunk.items_by_pt_id.items(): qty = len(items) output.load(d.id, w.id, pt_id, qty) print(" * loading drone " + str(d.id) + " with product " + str(pt_id) + " of qty " + str(qty)) print(" $ stock of " + str(pt_id) + " at warehouse " + str(w.id) + " was " + str(w.stock[pt_id]) + ", is now " + str(w.stock[pt_id] - qty)) w.stock[pt_id] -= qty # every load command takes one turn turns_till_idle_again += 1 from_pos = w.pos for o_id, items_by_pt_id in chunk.items_by_o_id_and_pt_id.items(): o = state.open_orders[o_id] # TODO: somehow plan the route between orders!!! right now it is random