Esempio n. 1
0
 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))
Esempio n. 2
0
 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()
Esempio n. 3
0
 def handle_boardsize(self, size):
     if int(size) != 19:
         return response.error('Only 19x19 currently supported, requested {}'.format(size))
     return response.success()
Esempio n. 4
0
 def handle_clear_board(self):
     self.game_state = GameState.new_game(19)
     return response.success()
Esempio n. 5
0
 def handle_quit(self):
     self._stopped = True
     return response.success()
Esempio n. 6
0
 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()
Esempio n. 7
0
 def handle_protocol_version(self):
     return response.success('2')
Esempio n. 8
0
 def ignore(self, *args):
     return response.success()
Esempio n. 9
0
 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()
Esempio n. 10
0
 def handle_time_left(self, color, time, stones):
     # TODO: Arguments: color color, int time, int stones
     return response.success()
Esempio n. 11
0
 def handle_showboard(self):
     print_board(self.game_state.board)
     return response.success()