コード例 #1
0
ファイル: go_env.py プロジェクト: mattrym/GymGo
 def step(self, action):
     '''
     Assumes the correct player is making a move. Black goes first.
     return observation, reward, done, info
     '''
     if action is None:
         action = self.size**2
     elif isinstance(action, tuple) or isinstance(
             action, list) or isinstance(action, np.ndarray):
         assert action[0] >= 0 and action[1] >= 0
         assert action[0] < self.size and action[1] < self.size
         action = action[0] * self.size + action[1]
     if self.children is not None:
         valid_moves = self.get_valid_moves()
         child_idx = int(np.sum(valid_moves[:action]))
         self.state, self.group_map = self.children[
             child_idx], self.child_groupmaps[child_idx]
     else:
         self.state, self.group_map = GoGame.get_next_state(self.state,
                                                            action,
                                                            self.group_map,
                                                            inplace=True)
     self.clear_cache()
     return np.copy(self.state), self.get_reward(), GoGame.get_game_ended(
         self.state), self.get_info()
コード例 #2
0
ファイル: go_env.py プロジェクト: Hizoul/GymGo
 def step(self, action):
     '''
     Assumes the correct player is making a move. Black goes first.
     return observation, reward, done, info
     '''
     if action is None:
         action = self.size**2
     elif isinstance(action, tuple) or isinstance(
             action, list) or isinstance(action, np.ndarray):
         assert action[0] >= 0 and action[1] >= 0
         assert action[0] < self.size and action[1] < self.size
         action = action[0] * self.size + action[1]
     self.state = GoGame.get_next_state(self.state, action)
     return np.copy(self.state), self.get_reward(), GoGame.get_game_ended(
         self.state), self.get_info()