def swapAgentsPositions(env,id0,id1, kick,ammo,blast): tmp = copy.copy(env._agents[id0].position) env._board[tmp]=utility.agent_value(env._agents[id1].agent_id) env._board[env._agents[id1].position]=utility.agent_value(env._agents[id0].agent_id) env._agents[id0].set_start_position(env._agents[id1].position) env._agents[id0].reset(ammo,True,blast,kick) env._agents[id1].set_start_position(tmp) env._agents[id1].reset() # print(env.get_json_info()) env._init_game_state=env.get_json_info() return env
def reset(self, train_idx=0, goal=None): assert (self._agents is not None) self.train_idx = train_idx self.observation_pre = None # self.achive = False self.goal = self.get_goal(goal) self.get_items = 0 self.is_dijk = True self.dijk_act = 0 self.dijk_step = 0 self.achive = False self.goal_position = None if self._init_game_state is not None: self.set_json_info() else: self._step_count = 0 self.make_board() self.make_items() self._bombs = [] self._flames = [] self._powerups = [] for agent_id, agent in enumerate(self._agents): pos = np.where(self._board == utility.agent_value(agent_id)) row = pos[0][0] col = pos[1][0] agent.set_start_position((row, col)) agent.reset() return self.get_reset_observations()
def reset(self): assert (self._agents is not None) self.act_abs_pre = None if self._init_game_state is not None: self.set_json_info() else: self._step_count = 0 self.make_board() self.make_items() self._bombs = [] self._flames = [] self._powerups = [] for agent_id, agent in enumerate(self._agents): pos = np.where(self._board == utility.agent_value(agent_id)) row = pos[0][0] col = pos[1][0] agent.set_start_position((row, col)) agent.reset() return self.get_observations()
def reset(self, train_idx=0, goal=None, meas_size=5): assert (self._agents is not None) self.train_idx = train_idx if self._init_game_state is not None: self.set_json_info() else: self._step_count = 0 self.make_board() self.make_items() self._bombs = [] self._flames = [] self._powerups = [] for agent_id, agent in enumerate(self._agents): pos = np.where(self._board == utility.agent_value(agent_id)) row = pos[0][0] col = pos[1][0] agent.set_start_position((row, col)) agent.reset() self.observation_pre = None self.goal = self.get_goal(goal, meas_size=meas_size) return self.get_observations()