def load_item(self, agent, destination_item_index): self.items[destination_item_index].loaded = True (agent_x, agent_y) = agent.get_position() self.items[destination_item_index].remove_agent(agent_x, agent_y) agent.last_loaded_item = copy(agent.item_to_load) agent.last_loaded_item_pos = self.items[destination_item_index].get_position() agent.item_to_load = -1 agent.reset_memory() return agent
def load_item(self, agent, destination_item_index): # print 'loaded item information by agent:' ,agent.index # print 'position:' ,self.items[destination_item_index].get_position() # print 'index: ',destination_item_index self.items[destination_item_index].loaded = True (agent_x, agent_y) = agent.get_position() self.items[destination_item_index].remove_agent(agent_x, agent_y) agent.last_loaded_item = deepcopy(agent.item_to_load) agent.item_to_load = -1 # Empty the memory to choose new target agent.reset_memory() # print '6AGA_O_2' return agent
def do_collaboration(self): c_reward = 0 for item in self.items: agents_total_level = 0 for agent in item.agents_load_item: agents_total_level += agent.level if agents_total_level >= item.level and item.agents_load_item !=[]: item.loaded = True c_reward += 1 for agent in item.agents_load_item: if not agent.intelligent_agent: agent.last_loaded_item_pos = item.get_position() agent.reset_memory() #print '2' item.agents_load_item = list() self.update_the_map() return float(c_reward)