def recreate_items(self): for item in self.items: item.loaded = False for agent in self.agents: if agent.get_position() == item.get_position(): x,y = self.move_to_empty_place() item.set_position(x,y) if self.main_agent is not None: if self.main_agent.get_position() == item.get_position(): x,y = self.move_to_empty_place() item.set_position(x,y) if self.enemy_agent is not None: if self.enemy_agent.get_position() == item.get_position(): x,y = self.move_to_empty_place() item.set_position(x,y) return
def take_m_observation(self): tmp_sim = self.copy() observation = list() self.main_agent.refresh_visibility(self) for agent in self.main_agent.visible_agents: observation.append(agent.position) for item in self.main_agent.visible_items: if not item.loaded: observation.append(item.get_position()) return observation
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 for agent in item.agents_load_item: self.agents[ agent.index].last_loaded_item_pos = item.get_position( ) self.agents[agent.index].reset_memory() #print '2' item.agents_load_item = list() c_reward += 1 self.update_the_map() return
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)