當前位置: 首頁>>代碼示例>>Python>>正文


Python chess.uci方法代碼示例

本文整理匯總了Python中chess.uci方法的典型用法代碼示例。如果您正苦於以下問題:Python chess.uci方法的具體用法?Python chess.uci怎麽用?Python chess.uci使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在chess的用法示例。


在下文中一共展示了chess.uci方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import chess [as 別名]
# 或者: from chess import uci [as 別名]
def __init__(self, board, commands, options, silence_stderr=False):
        commands = commands[0] if len(commands) == 1 else commands
        self.go_commands = options.get("go_commands", {})

        self.engine = chess.uci.popen_engine(commands, stderr = subprocess.DEVNULL if silence_stderr else None)
        self.engine.uci()

        if options:
            self.engine.setoption(options)

        self.engine.setoption({
            "UCI_Variant": type(board).uci_variant,
            "UCI_Chess960": board.chess960
        })
        self.engine.position(board)

        info_handler = chess.uci.InfoHandler()
        self.engine.info_handlers.append(info_handler) 
開發者ID:ShailChoksi,項目名稱:lichess-bot,代碼行數:20,代碼來源:engine_wrapper.py

示例2: book

# 需要導入模塊: import chess [as 別名]
# 或者: from chess import uci [as 別名]
def book(self, bookreader, game_copy: chess.Board):
        """Get a BookMove or None from game position."""
        try:
            choice = bookreader.weighted_choice(game_copy, self.excludemoves)
        except IndexError:
            return None

        book_move = choice.move()
        self.add(book_move)
        game_copy.push(book_move)
        try:
            choice = bookreader.weighted_choice(game_copy)
            book_ponder = choice.move()
        except IndexError:
            book_ponder = None
        return chess.uci.BestMove(book_move, book_ponder) 
開發者ID:jromang,項目名稱:picochess,代碼行數:18,代碼來源:picochess.py

示例3: run_thread

# 需要導入模塊: import chess [as 別名]
# 或者: from chess import uci [as 別名]
def run_thread(thread_id, module, example_queue):
    selfplay_model = args.model and module.Model(args.model)

    engine = chess.uci.popen_engine(STOCKFISH_PATH)
    info_handler = chess.uci.InfoHandler()
    engine.info_handlers.append(info_handler)
    engine.uci()
    engine.isready()
    start, last = time.time(), 0
    for i in range(N_GAMES // THREADS):
        # Predicting progress and ETA
        if thread_id == 0 and time.time() - last > .5:
            pg = i * THREADS / N_GAMES
            if i == 0:
                pg += 1 / 1000000
            etr = (time.time() - start) * (1 / pg - 1)
            print('Progress: {:.1f}%. Remaining: {}'
                  .format(pg * 100, str(timedelta(seconds=int(etr)))),
                  file=sys.stderr, end='\r')
            last = time.time()

        # Play a game
        for line in play_game(engine, info_handler, module, selfplay_model):
            example_queue.put(line)
    example_queue.put(None)

    if thread_id == 0:
        print()
        print('Finishing remaining threads...', file=sys.stderr) 
開發者ID:thomasahle,項目名稱:fastchess,代碼行數:31,代碼來源:make_data.py

示例4: initialize

# 需要導入模塊: import chess [as 別名]
# 或者: from chess import uci [as 別名]
def initialize(self, bot_handler: Any) -> None:
        self.config_info = bot_handler.get_config_info('chess')

        try:
            self.engine = chess.uci.popen_engine(
                self.config_info['stockfish_location']
            )
            self.engine.uci()
        except FileNotFoundError:
            # It is helpful to allow for fake Stockfish locations if the bot
            # runner is testing or knows they won't be using an engine.
            print('That Stockfish doesn\'t exist. Continuing.') 
開發者ID:zulip,項目名稱:python-zulip-api,代碼行數:14,代碼來源:chessbot.py


注:本文中的chess.uci方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。