Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
823 B
5
Indexable
Never
def assign_orders(self, availableOrders, availableAgents):
        assignedAgents = []
        for order in availableOrders:
            orderWasAccepted = False
            sortedAgentsByDistance = self.get_sorted_agents_list(order, availableAgents)
            for agent in sortedAgentsByDistance:
                if(agent.order_meets_thresholds(order)):
                    print("agent accepting order\n")
                    agent.accept_order(order)
                    availableAgents.remove(agent)
                    availableOrders.remove(order)
                    assignedAgents.append(agent)
                    break
                order.pay += 0.25
                
            if not orderWasAccepted:
                order.ticksInQueue += 1
                
        return assignedAgents