Example #1
0
        def command():
            # Use the join(builder) once we parse usermove=1 feature
            move_str = " ".join(builder)
            if self.in_force:
                with self.semaphore:
                    self.send_line(move_str)

                if self.terminated.is_set():
                    raise EngineTerminatedException()
            else:
                with self.semaphore:
                    self.send_line(move_str)
                    self.search_started.set()

                self.move_received.wait()

                with self.state_changed:
                    self.idle = True
                    self.state_changed.notify_all()

                if self.terminated.is_set():
                    raise EngineTerminatedException()

                try:
                    self.board.push_uci(str(self.move))
                except ValueError:
                    try:
                        self.board.push_san(str(self.move))
                    except ValueError:
                        LOGGER.exception("exception parsing move")

                return self.move
        def command():
            move_str = " ".join(builder)
            self.ponder_move = None
            if self.in_force:
                with self.semaphore:
                    self.send_line(move_str)

                if self.terminated.is_set():
                    raise EngineTerminatedException()
            else:
                with self.semaphore:
                    self.send_line(move_str)
                    self.search_started.set()

                self.move_received.wait()

                with self.state_changed:
                    self.idle = True
                    self.state_changed.notify_all()

                if self.terminated.is_set():
                    raise EngineTerminatedException()

                try_move(self.board, str(self.move))

                return self.move
Example #3
0
        def command():
            with self.semaphore:
                self.send_line("go")
                self.search_started.set()

            self.move_received.wait()

            with self.state_changed:
                self.idle = True
                self.state_changed.notify_all()

            if self.terminated.is_set():
                raise EngineTerminatedException()

            if self.auto_force:
                self.force()

            try:
                self.board.push_uci(str(self.move))
            except ValueError:
                try:
                    self.board.push_san(str(self.move))
                except ValueError:
                    LOGGER.exception("exception parsing move")

            return self.move
        def command():
            with self.semaphore:
                for option_line in option_lines:
                    self.send_line(option_line)

                if self.terminated.is_set():
                    raise EngineTerminatedException()
Example #5
0
        def command():
            with self.semaphore:
                with self.training_data_received:
                    self.send_line("traindata version {}".format(version))
                    self.training_data_received.wait()

                if self.terminated.is_set():
                    raise EngineTerminatedException()
        def command():
            with self.semaphore:
                with self.readyok_received:
                    self.send_line("isready")
                    self.readyok_received.wait()

                    if self.terminated.is_set():
                        raise EngineTerminatedException()
        def command():
            with self.semaphore:
                with self.pong_received:
                    self.send_line("ping " + str(self.ping_num))
                    self.pong_received.wait()

                    if self.terminated.is_set():
                        raise EngineTerminatedException()
Example #8
0
        def command():
            with self.semaphore:
                if ponder:
                    self.send_line("hard")
                else:
                    self.send_line("easy")

                if self.terminated.is_set():
                    raise EngineTerminatedException()
Example #9
0
        def command():
            with self.semaphore:
                if flag == True:
                    self.send_line("post")
                else:
                    self.send_line("nopost")

                if self.terminated.is_set():
                    raise EngineTerminatedException()
        def command():
            with self.semaphore:
                with self.state_changed:
                    if not self.idle:
                        self.search_started.wait()

                    self.send_line("exit")
                    self.move_received.set()

                if self.terminated.is_set():
                    raise EngineTerminatedException()
Example #11
0
        def command():
            with self.semaphore:
                self.send_line("xboard")
                self.send_line("protover 2")

                if self.terminated.is_set():
                    raise EngineTerminatedException()

            self.post()
            self.easy()
            self.ping()
Example #12
0
        def command():
            with self.semaphore:
                self.send_line("xboard")
                self.send_line(
                    "protover 2")  # TODO: Add option for this and parse input

                if self.terminated.is_set():
                    raise EngineTerminatedException()

            self.post()
            self.easy()
            self.ping()
        def command():
            with self.semaphore:
                self.send_line(" ".join(builder))
                self.search_started.set()

            self.bestmove_received.wait()

            with self.state_changed:
                self.idle = True
                self.state_changed.notify_all()

            if self.terminated.is_set():
                raise EngineTerminatedException()

            return BestMove(self.bestmove, self.ponder)
        def command():
            with self.semaphore:
                self.send_line("analyze")
                self.search_started.set()

            self.move_received.wait()

            with self.state_changed:
                self.idle = True
                self.state_changed.notify_all()

            if self.terminated.is_set():
                raise EngineTerminatedException()

            if self.auto_force:
                self.force()
    def _queue_command(self, command, async_callback):
        try:
            future = self.pool.submit(command)
        except RuntimeError:
            raise EngineTerminatedException()

        if async_callback is True:
            return future
        elif async_callback:
            future.add_done_callback(async_callback)
            return future
        else:
            # Avoid calling future.result() without a timeout.
            # In Python 2, such a call can't be interrupted.
            while True:
                try:
                    return future.result(timeout=FUTURE_POLL_TIMEOUT)
                except concurrent.futures.TimeoutError:
                    pass
        def command():
            with self.semaphore:
                with self.state_changed:
                    if not self.idle:
                        self.search_started.wait()

                    backoff = 0.5
                    while not self.move_received.is_set() and not self.terminated.is_set():
                        if self.idle:
                            break
                        else:
                            self.send_line("?")
                        self.move_received.wait(backoff)
                        backoff *= 2

                    self.idle = True
                    self.state_changed.notify_all()

                if self.terminated.is_set():
                    raise EngineTerminatedException()
        def command():
            with self.semaphore:
                self.send_line("go")
                self.search_started.set()

            self.move_received.wait()

            with self.state_changed:
                self.idle = True
                self.state_changed.notify_all()

            if self.terminated.is_set():
                raise EngineTerminatedException()

            if self.auto_force:
                self.force()

            if self.move in DUMMY_RESPONSES:
                return self.move

            try_move(self.board, str(self.move))

            return self.move
Example #18
0
        def command():
            with self.semaphore:
                self.send_line(" ".join(builder))

                if self.terminated.is_set():
                    raise EngineTerminatedException()
Example #19
0
        def command():
            with self.semaphore:
                self.send_line("new")

                if self.terminated.is_set():
                    raise EngineTerminatedException()