示例#1
0
文件: server.py 项目: olk/ki-go
 def select_move(bot_name):
     content = request.json
     board_size = content['board_size']
     game_state = GameState.new_game(board_size)
     # Replay the game up to this point.
     for move in content['moves']:
         if move == 'pass':
             next_move = Move.pass_turn()
         elif move == 'resign':
             next_move = Move.resign()
         else:
             next_move = Move.play(point_from_coords(move))
         game_state = game_state.apply_move(next_move)
     bot_agent = bot_map[bot_name]
     bot_move = bot_agent.select_move(game_state)
     if bot_move.is_pass:
         bot_move_str = 'pass'
     elif bot_move.is_resign:
         bot_move_str = 'resign'
     else:
         bot_move_str = coords_from_point(bot_move.point)
     return jsonify({
         'bot_move': bot_move_str,
         'diagnostics': bot_agent.diagnostics()
     })
示例#2
0
文件: termination.py 项目: olk/ki-go
 def select_move(self, game_state):
     if self._strategy.should_pass(game_state):
         return Move.pass_turn()
     elif self._strategy.should_resign(game_state):
         return Move.resign()
     else:
         return self._agent.select_move(game_state)
示例#3
0
文件: betago_local.py 项目: olk/ki-go
    def _play_their_move(self):
        their_name = self._their_color.name
        their_letter = their_name[0].upper()

        pos = self._command_and_response("genmove {}\n".format(their_name))
        if pos.lower() == 'resign':
            self._game_state = self._game_state.apply_move(Move.resign())
            self._stopped = True
        elif pos.lower() == 'pass':
            self._game_state = self._game_state.apply_move(Move.pass_turn())
            self._sgf.append(";{}[]\n".format(their_letter))
            if self._game_state.last_move.is_pass:
                self._stopped = True
        else:
            move = Move(gtp_position_to_coords(pos))
            self._game_state = self._game_state.apply_move(move)
            self._sgf.append(";{}[{}]\n".format(their_letter, self._sgf.coordinates(move)))