https://github.com/lichess-org/dart-multistockfish
Multiple flavors of Stockfish Chess Engine
https://github.com/lichess-org/dart-multistockfish
chess dart dartlang engine stockfish stockfish-engine
Last synced: 7 months ago
JSON representation
Multiple flavors of Stockfish Chess Engine
- Host: GitHub
- URL: https://github.com/lichess-org/dart-multistockfish
- Owner: lichess-org
- License: gpl-3.0
- Created: 2025-03-18T10:05:55.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-03-19T15:17:54.000Z (7 months ago)
- Last Synced: 2025-03-19T16:22:28.371Z (7 months ago)
- Topics: chess, dart, dartlang, engine, stockfish, stockfish-engine
- Language: C++
- Homepage:
- Size: 439 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# multistockfish
Multiple flavors of Stockfish Engine.
This plugin supports the following Stockfish engines:
* Stockfish 11 with the handcrafted evaluation function (HCE)
* Stockfish 17 with the NNUE evaluation function## Usage
### Init engine
> [!WARNING]
> Only one instance can be created at a time. The `Stockfish()` constructor
> will throw a StateError if called while another instance is running.> [!NOTE]
> When using the NNUE flavor, you need to download the `.nnue` files before
> starting an evaluation, since it is not embedded in the binary.```dart
import 'package:multistockfish/multistockfish.dart';// create a new instance (here we use the handcrafted evaluation function)
final stockfish = Stockfish(StockfishFlavor.hce);// state is a ValueListenable
print(stockfish.state.value); # StockfishState.starting// the engine takes a few moment to start
await Future.delayed(...)
print(stockfish.state.value); # StockfishState.ready
```### UCI command
Wait until the state is ready before sending commands.
```dart
stockfish.stdin = 'isready';
stockfish.stdin = 'go movetime 3000';
stockfish.stdin = 'go infinite';
stockfish.stdin = 'stop';
```Engine output is directed to a `Stream`, add a listener to process results.
```dart
stockfish.stdout.listen((line) {
// do something useful
print(line);
});
```### Dispose / Hot reload
There are two active isolates when Stockfish engine is running. That interferes with Flutter's hot reload feature so you need to dispose it before attempting to reload.
```dart
// sends the UCI quit command
stockfish.stdin = 'quit';// or even easier...
stockfish.dispose();
```