Class AbstractUCIEngine

java.lang.Object
net.chesstango.goyeneche.AbstractUCIEngine
All Implemented Interfaces:
Consumer<UCICommand>, UCIEngine, UCIService

public class AbstractUCIEngine extends Object implements UCIService, UCIEngine
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 Details

    • AbstractUCIEngine

      public AbstractUCIEngine()
  • Method Details

    • do_uci

      public void do_uci(ReqUci reqUci)
      Description copied from interface: UCIEngine
      Handles 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.
      Specified by:
      do_uci in interface UCIEngine
      Parameters:
      reqUci - The request object representing the "uci" command.
    • do_setOption

      public void do_setOption(ReqSetOption reqSetOption)
      Description copied from interface: UCIEngine
      Handles 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_setOption in interface UCIEngine
      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

      public void do_isReady(ReqIsReady reqIsReady)
      Description copied from interface: UCIEngine
      Handles 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_isReady in interface UCIEngine
      Parameters:
      reqIsReady - The request object representing the "isready" command.
    • do_newGame

      public void do_newGame(ReqUciNewGame reqUciNewGame)
      Description copied from interface: UCIEngine
      Handles 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_newGame in interface UCIEngine
      Parameters:
      reqUciNewGame - The request object representing the "ucinewgame" command. It informs the engine to reinitialize itself for handling a new game session.
    • do_position

      public void do_position(ReqPosition reqPosition)
      Description copied from interface: UCIEngine
      Handles 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_position in interface UCIEngine
      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

      public void do_go(ReqGo reqGo)
      Description copied from interface: UCIEngine
      Handles 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.
      Specified by:
      do_go in interface UCIEngine
      Parameters:
      reqGo - The request object representing the "go" command. It contains the parameters for configuring the engine's search, such as limits on time or depth, move ordering, or other search-related constraints.
    • do_stop

      public void do_stop(ReqStop reqStop)
      Description copied from interface: UCIEngine
      Handles 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.
      Specified by:
      do_stop in interface UCIEngine
      Parameters:
      reqStop - The request object representing the "stop" command. It indicates that the engine should cease its ongoing operations.
    • do_quit

      public void do_quit(ReqQuit reqQuit)
      Description copied from interface: UCIEngine
      Handles 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.
      Specified by:
      do_quit in interface UCIEngine
      Parameters:
      reqQuit - The request object representing the "quit" command.
    • open

      public void open()
      Specified by:
      open in interface UCIService
    • close

      public void close()
      Specified by:
      close in interface UCIService
    • setOutputStream

      public void setOutputStream(UCIOutputStream output)
      Specified by:
      setOutputStream in interface UCIService
    • accept

      public void accept(UCICommand command)
      Specified by:
      accept in interface Consumer<UCICommand>
    • replyResponse

      public void replyResponse(UCIResponse response)