|
UCILoader 1.1.2
Small C++ library that allows user to connect to a chess engines via UCI protocol.
|
Manages and controls an ongoing chess engine search operation. More...
#include <EngineConnection.h>
Classes | |
| class | ResultNotReadyException |
| Exception thrown when attempting to retrieve results before search completes. More... | |
Public Member Functions | |
| SearchConnection (std::shared_ptr< ProcessWrapper > engine) | |
| Constructor for SearchConnection. | |
| SearchStatusCode | getStatus () |
| Get the current status of the search operation. | |
| const SearchResult< Move > & | getResult () |
| Retrieve the search result. | |
| void | stop () |
| Send a stop command to halt the engine's search. | |
| void | ponderhit () |
| Send a ponderhit command to the engine. | |
| void | waitFor (const std::chrono::milliseconds &time) |
| Block until the search completes or timeout expires. | |
| void | timeOutIfNotFinished () |
| Set status to TimedOut if search is still ongoing. | |
Manages and controls an ongoing chess engine search operation.
| Move | The move type used by the chess engine |
SearchConnection provides a handle to an active search, allowing the user to:
Instances are typically obtained by calling the search() method on an EngineInstance. The SearchConnection takes ownership of the search and manages its lifecycle.
|
inline |
Constructor for SearchConnection.
| engine | Shared pointer to the engine process |
|
inline |
Retrieve the search result.
| ResultNotReadyException | if the search status is not ResultReady |
Always call getStatus() first to verify the status is ResultReady before calling this method. This avoids potential ResultNotReadyException thrown when results are not yet available.
|
inline |
Get the current status of the search operation.
|
inline |
Send a ponderhit command to the engine.
Instructs the engine to switch from pondering mode to active searching. This is a no-op if the search status is not OnGoing. The search status remains unchanged regardless of whether the command is sent.
|
inline |
Send a stop command to halt the engine's search.
Sets search status to Stopped unless already in a final state (ResultReady or Terminated). This is a no-op if the search has already completed or been terminated. However, for TimedOut status, stop will still be sent to terminate the engine's ongoing work.
|
inline |
Set status to TimedOut if search is still ongoing.
This is intended for asynchronous use cases where the caller manages timeouts manually instead of using the waitFor() method. If status is already in a final state, this is a no-op.
|
inline |
Block until the search completes or timeout expires.
The calling thread will be suspended and woken when:
If the engine doesn't deliver bestmove before timeout, status will be set to TimedOut.
| time | Maximum duration to wait in milliseconds |