Skip to content

Multiple flavors of Stockfish Chess Engine

License

Notifications You must be signed in to change notification settings

lichess-org/dart-multistockfish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Tests pub package package publisher Discord

multistockfish

Multiple flavors of Stockfish Engine.

This plugin provides the following Stockfish engines:

Usage

Start engine

Stockfish is a singleton. Access it via Stockfish.instance and call start() to run the engine.

Note

When using the StockfishFlavor.latestNoNNUE flavor, you need to download the .nnue files before starting an evaluation, since it is not embedded in the binary.

import 'package:multistockfish/multistockfish.dart';

final stockfish = Stockfish.instance;

// state is a ValueListenable<StockfishState>
print(stockfish.state.value); // StockfishState.initial

// start the engine (defaults to StockfishFlavor.sf16)
await stockfish.start();
print(stockfish.state.value); // StockfishState.ready

// to change flavor, quit first then start with new configuration
await stockfish.quit();
await stockfish.start(
  flavor: StockfishFlavor.variant,
  variant: 'atomic',
);

// for latestNoNNUE flavor, NNUE file paths are required
await stockfish.quit();
await stockfish.start(
  flavor: StockfishFlavor.latestNoNNUE,
  bigNetPath: '/path/to/big.nnue',
  smallNetPath: '/path/to/small.nnue',
);

UCI command

Wait until the state is ready before sending commands.

stockfish.stdin = 'isready';
stockfish.stdin = 'go movetime 3000';
stockfish.stdin = 'go infinite';
stockfish.stdin = 'stop';

Engine output is directed to a Stream<String>, add a listener to process results.

stockfish.stdout.listen((line) {
  // do something useful
  print(line);
});

Quit / Hot reload

There are two active isolates when Stockfish engine is running. That interferes with Flutter's hot reload feature so you need to quit the engine before attempting to reload.

// sends the UCI quit command
stockfish.stdin = 'quit';

// or even easier...
await stockfish.quit();

About

Multiple flavors of Stockfish Chess Engine

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 3

  •  
  •  
  •