java.lang.Object
net.chesstango.goyeneche.AbstractUCIEngine
- All Implemented Interfaces:
Consumer<UCICommand>,UCIEngine,UCIService
Represents an abstract implementation of a Universal Chess Interface (UCI) engine.
This class serves as a base implementation for UCI-based engines, providing a framework to handle communication with a graphical user interface (GUI). Subclasses can override specific methods to implement engine logic for responding to UCI commands such as `uci`, `isready`, `position`, and others.
The class manages an UCIOutputStreamEngineExecutor for command execution
and provides a mechanism for processing responses through an output stream.
- Author:
- Mauricio Coria
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(UCICommand command) voidclose()voidHandles the "go" command as part of the Universal Chess Interface (UCI) protocol.voiddo_isReady(ReqIsReady reqIsReady) Handles the "isready" command as part of the Universal Chess Interface (UCI) protocol.voiddo_newGame(ReqUciNewGame reqUciNewGame) Handles the "ucinewgame" command as part of the Universal Chess Interface (UCI) protocol.voiddo_position(ReqPosition reqPosition) Handles the "position" command as part of the Universal Chess Interface (UCI) protocol.voidHandles the "quit" command as part of the Universal Chess Interface (UCI) protocol.voiddo_setOption(ReqSetOption reqSetOption) Handles the "setoption" command as part of the Universal Chess Interface (UCI) protocol.voidHandles the "stop" command as part of the Universal Chess Interface (UCI) protocol.voidHandles the "uci" command as part of the Universal Chess Interface (UCI) protocol.voidopen()voidreplyResponse(UCIResponse response) voidsetOutputStream(UCIOutputStream output)
-
Constructor Details
-
AbstractUCIEngine
public AbstractUCIEngine()
-
-
Method Details
-
do_uci
Description copied from interface:UCIEngineHandles the "uci" command as part of the Universal Chess Interface (UCI) protocol. This command is sent by the GUI to initialize communication with the chess engine, requiring the engine to identify itself and confirm support for the UCI protocol. -
do_setOption
Description copied from interface:UCIEngineHandles the "setoption" command as part of the Universal Chess Interface (UCI) protocol. This command is sent by the GUI to configure a specific option in the chess engine. The option is identified by its name (id) and may have an associated value.- Specified by:
do_setOptionin interfaceUCIEngine- Parameters:
reqSetOption- The request object representing the "setoption" command. It contains the name of the option to be configured (id) and the value to set, if applicable.
-
do_isReady
Description copied from interface:UCIEngineHandles the "isready" command as part of the Universal Chess Interface (UCI) protocol. This command is sent by the GUI to query the chess engine's readiness state. The engine should respond with "readyok" once it is prepared to receive further commands.- Specified by:
do_isReadyin interfaceUCIEngine- Parameters:
reqIsReady- The request object representing the "isready" command.
-
do_newGame
Description copied from interface:UCIEngineHandles the "ucinewgame" command as part of the Universal Chess Interface (UCI) protocol. This command is sent by the GUI to notify the chess engine that a new game has started. The engine should reset its internal state as necessary to ensure it operates correctly for the new game.- Specified by:
do_newGamein interfaceUCIEngine- Parameters:
reqUciNewGame- The request object representing the "ucinewgame" command. It informs the engine to reinitialize itself for handling a new game session.
-
do_position
Description copied from interface:UCIEngineHandles the "position" command as part of the Universal Chess Interface (UCI) protocol. This command sets up a specific chessboard state, either starting from the default initial position or from a given FEN (Forsyth-Edwards Notation) string, along with any moves to be applied to the position.- Specified by:
do_positionin interfaceUCIEngine- Parameters:
reqPosition- The request object containing the required information to set up the position. It includes the type of position (starting position or FEN), the FEN string (if provided), and a list of moves in UCI format to apply to the position.
-
do_go
Description copied from interface:UCIEngineHandles the "go" command as part of the Universal Chess Interface (UCI) protocol. This command is sent by the GUI to instruct the chess engine to begin searching for the best move in the current position. The parameters of this command can include various search constraints, such as time limits, depth limits, or specific search strategies. -
do_stop
Description copied from interface:UCIEngineHandles the "stop" command as part of the Universal Chess Interface (UCI) protocol. This command is sent by the GUI to instruct the chess engine to stop its current search or processing immediately. The engine should halt its computations and return control promptly to handle subsequent commands. -
do_quit
Description copied from interface:UCIEngineHandles the "quit" command as part of the Universal Chess Interface (UCI) protocol. This command is sent by the GUI to instruct the chess engine to terminate its execution. Upon receiving this command, the engine should release any resources and prepare for a safe shutdown. -
open
public void open()- Specified by:
openin interfaceUCIService
-
close
public void close()- Specified by:
closein interfaceUCIService
-
setOutputStream
- Specified by:
setOutputStreamin interfaceUCIService
-
accept
- Specified by:
acceptin interfaceConsumer<UCICommand>
-
replyResponse
-