Skip to content

An asynchronous java wrapper for the popular uci chess engine Stockfish 10

License

Notifications You must be signed in to change notification settings

senyast4745/Stockfish-Java

Repository files navigation

license FAQ

Stockfish Java

Stockfish Java is an open source asynchronous high level wrapper for a very popular and the world strongest UCI chess engine Stockfish. Stockfish Java is not tied to any specific Stockfish version: originally built on version 10, now is also supporting the latest version 16.

Quick Start

To start, create a Stockfish Client instance:

StockfishClient client = new StockfishClient.Builder()
        .setInstances(4)
        .setVariant(Variant.BMI2)
        .build();

This library allows multiple Stockfish instances to run concurrently to lessen the impact of thread blocking chess computation. By default, the client only creates one instance, but we can override that by setting the number in the builder. There are also multiple variants of Stockfish. In the builder, we can specify BMI2, POPCNT (Windows only), or MODERN (Linux only). A general rule of thumb is to go with BMI2 first and if it crashes or is incompatible with your system, use POPCNT/MODERN depending on your operating system. If variant is not set in the builder, we default to the regular Stockfish binary.

After creating the client, we can define a query for the client to compute:

Query query = new Query.Builder(QueryType.Legal_Moves)
        .setFen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1")
        .build();

More on queries can be found in the wiki, but for now we're just going to submit the query to the client:

client.submit(query, result -> {
    // Do something with the result
})

Using a callback, we grab the result and can use it with a lambda.

The included tester shows some more example usage of the Stockfish Java library.

Documentation

Information regarding Stockfish Java as well as full usage of the client is detailed in the wiki. As this is a constantly evolving project, the wiki will receive frequent updates and will have the most up to date documentation.

Contributors

Owners and Developers

Other Contributors

Dependencies

About

An asynchronous java wrapper for the popular uci chess engine Stockfish 10

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages