- All Superinterfaces:
Consumer<UCICommand>
- All Known Implementing Classes:
AbstractUCIEngine
This interface is designed to handle the exchange of messages between a chess engine and a GUI, or vice versa, depending on the implementation. It acts as the bridge for processing UCI commands, communicating responses, and managing the lifecycle of the service.
Typical implementations could represent a chess engine that processes UCI commands from a GUI (Graphical User Interface)
or a GUI controller that interacts with a chess engine. By consuming UCICommand objects, the service interprets
and acts upon the received instructions while allowing responses to be sent back via an output stream.
Responsibilities
- Message Processing: Implements the
Consumerinterface to handle UCI protocol messages (UCICommand) sent to the service. - Resource Management: Offers lifecycle methods,
open()andclose(), which are used to initialize or release required resources (e.g., connections, streams, or engine processes). - Response Handling: Provides a method to direct responses to an output stream using
setOutputStream(UCIOutputStream). This allows flexibility in redirecting responses to a specific target.
Usage Scenarios
This interface can be implemented in various ways:
- Chess Engine: A chess engine can implement
UCIServiceto process commands such asucinewgame,position, orgo, and to send responses likebestmoveandinfoback to the GUI. - GUI Controller: A GUI controller can implement
UCIServiceto interact with a chess engine by sending commands and receiving responses, enabling the GUI to present move suggestions, evaluations, or other engine-provided details.
Interface Methods
open(): Prepares the service for use and initializes any required resources.close(): Cleans up and releases resources previously initialized by the service.setOutputStream(UCIOutputStream): Configures the output stream used to send commands from the service.Consumer.accept(Object): Processes individual UCI protocol commands passed to the service.
Design Considerations
The UCIService interface is intentionally minimalistic and abstract, focusing solely on the core operations
required for UCI protocol communication. This abstraction allows implementations to be tailored for both chess engines
and GUI controllers, enhancing reusability and adaptability in UCI-based chess systems.
- Author:
- Mauricio Coria
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidopen()voidsetOutputStream(UCIOutputStream output)
-
Method Details
-
open
void open() -
close
void close() -
setOutputStream
-