def handle_genmove(self, color):
     move = self.agent.select_move(self.game_state)
     self.game_state = self.game_state.apply_move(move)
     if move.is_pass:
         return response.success('pass')
     if move.is_resign:
         return response.success('resign')
     return response.success(coords_to_gtp_position(move))
 def handle_play(self, color, move):
     if move.lower() == 'pass':
         self.game_state = self.game_state.apply_move(Move.pass_turn())
     elif move.lower() == 'resign':
         self.game_state = self.game_state.apply_move(Move.resign())
     else:
         self.game_state = self.game_state.apply_move(gtp_position_to_coords(move))
     return response.success()
 def handle_fixed_handicap(self, nstones):
     nstones = int(nstones)
     for stone in HANDICAP_STONES[nstones]:
         self.game_state = self.game_state.apply_move(
             gtp_position_to_coords(stone))
     return response.success()
 def ignore(self, *args):
     return response.success()
 def handle_protocol_version(self):
     return response.success('2')
 def handle_time_left(self, color, time, stones):
     # TODO: Arguments: color color, int time, int stones
     return response.success()
 def handle_time_settings(self, main_time, byo_yomi_time, byo_yomi_stones):
     # TODO: Arguments: int main_time, int byo_yomi_time, int byo_yomi_stones
     return response.success()
 def handle_showboard(self):
     print_board(self.game_state.board)
     return response.success()
 def handle_boardsize(self, size):
     if int(size) != 19:
         return response.error('Only 19x19 currently supported, requested {}'.format(size))
     return response.success()
 def handle_clear_board(self):
     self.game_state = GameState.new_game(19)
     return response.success()
 def handle_quit(self):
     self._stopped = True
     return response.success()
Exemple #12
0
 def not_implemented_but_respond_success(fn_name):
     print(
         f'Received {fn_name} command but it is not implemented by this frontend'
     )
     return response.success()