GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - mcoria/goyeneche: Java library implementing the UCI (Universal Chess Interface) Protocol

BranchesTags
Open more actions menu

Latest commit

 

History

132 Commits
132 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.junie
.junie
 
 
docs
docs
 
 
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pom.xml
pom.xml
 
 

Repository files navigation

Java CI with Maven

goyeneche

goyeneche is a Java library implementing the UCI (Universal Chess Interface) Protocol, enabling easy integration with chess engines or GUI controllers supporting this protocol.

Features

  • Provides a streamlined way to communicate with UCI-compatible chess engines.
  • Send and receive UCI commands with ease.
  • Built with Java, making it simple to integrate into existing Java projects.

Prerequisites

  • Java 25 or higher
  • Maven or Gradle for dependency management (optional)

Installation

To use goyeneche in your project, add the dependency to your pom.xml (for Maven) or build.gradle (for Gradle).

Maven

<dependency>
    <groupId>net.chesstango</groupId>
    <artifactId>goyeneche</artifactId>
    <version>1.0.14</version>
</dependency>

Gradle

implementation 'net.chesstango:goyeneche:1.0.14'

Usage

Follow the steps below to integrate goyeneche into your project:

  1. Initialize and Configure the UCI Client

    Set up the UCI client to connect with a UCI-compatible chess engine (e.g., Stockfish).

    public class EngineSkeleton extends AbstractUCIEngine {
    
     public static void main(String[] args) {
    
         // Create an instance of the EngineSkeleton to handle UCI commands.
         EngineSkeleton engineSkeleton = new EngineSkeleton();
    
         // Configure the engine's output stream to forward responses to the GUI via standard output,
         // using a StringConsumer for protocol-compliant communication.
         engineSkeleton.setOutputStream(new UCIOutputStreamToStringAdapter(new StringConsumer(new OutputStreamWriter(System.out))));
    
         // Open the engine to prepare it for communication with the GUI.
         engineSkeleton.open();
    
         // Initialize and set up the UCIActiveStreamReader to read UCI commands from standard input.
         UCIActiveStreamReader uciActiveStreamReader = createUciActiveStreamReader(engineSkeleton);
    
         // Start processing UCI commands in the active reader loop.
         uciActiveStreamReader.run();
    
         // Close the engine after completing the communication.
         engineSkeleton.close();
     }
    
    
    
     private static UCIActiveStreamReader createUciActiveStreamReader(Consumer<UCICommand> uciCommandConsumer) {
         UCIActiveStreamReader uciActiveStreamReader = new UCIActiveStreamReader();
    
         // Configures the active stream reader to read input from the standard input (System.in)
         // by adapting it to the UCIInputStream interface through a StringSupplier.
         uciActiveStreamReader.setInputStream(new UCIInputStreamFromStringAdapter(new StringSupplier(new InputStreamReader(System.in))));
    
         // Directs the output of the active stream reader to be handled by the engineSkeleton's accept method,
         // enabling the engine to process UCI commands received from the input.
         uciActiveStreamReader.setOutputStream(uciCommandConsumer::accept);
    
         // Return the configured UCIActiveStreamReader instance to handle communication with the GUI.
         return uciActiveStreamReader;
     }
    
    
     @Override
     public void do_uci(ReqUci reqUci) {
         replyResponse(new RspId(RspId.RspIdType.NAME, "Skeleton 1.0"));
         replyResponse(new RspId(RspId.RspIdType.AUTHOR, "John Doe"));
         replyResponse(new RspUciOk());
     }
    
    
     @Override
     public void do_isReady(ReqIsReady cmdIsReady) {
         replyResponse(new RspReadyOk());
     }
     
    
     @Override
     public void do_go(ReqGo reqGo) {
         replyResponse(new RspBestMove("c2c4"));
     }
    }

    Execute EngineSkeleton and start exchanging commands as follows:

    >> uci
    << id name Skeleton 1.0
    << id author John Doe
    << uciok
    >> isready
    << readyok
    >> ucinewgame
    >> position startpos moves e2e4 e7e5
    >> go infinite
    << bestmove c2c4
    >> quit
    
  2. Commands for UCI Protocol

    Here are some commonly used UCI commands you can send through the client:

    • uci: Initialize the UCI mode.
    • isready: Check if the engine is ready.
    • usinewgame: Initialize a new game.
    • position: Set up the board position.
    • go: Start calculating the best move.
    • stop: Stop the current calculation.

Contributing

Contributions are welcome! Feel free to open issues and submit pull requests.

License

This project is licensed under the BSD 3-Clause License. See the LICENSE file for details.

About

Java library implementing the UCI (Universal Chess Interface) Protocol

Topics

chessjavauniversal-chess-interface

Resources

Readme
BSD-3-Clause license
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.