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
def command(): with self.semaphore: for option_line in option_lines: self.send_line(option_line) 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()
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.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()
def command(): with self.semaphore: self.send_line("xboard") self.send_line("protover 2") if self.terminated.is_set(): raise EngineTerminatedException() # TODO: Remove perhaps? 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