2025-03-15 11:16:35 -04:00
2021-10-21 14:44:47 +05:30
2025-02-24 15:30:31 -05:00
2024-06-11 08:51:10 +07:00
2025-02-24 15:30:31 -05:00
2020-12-27 21:51:12 +07:00
2020-12-27 21:51:12 +07:00
2020-12-19 23:06:31 +05:30
2025-02-24 15:39:53 -05:00
2025-02-24 15:42:02 -05:00
2025-02-24 15:39:53 -05:00
2025-02-24 15:39:53 -05:00
2020-12-19 23:06:31 +05:30

stockfish

Pipeline

The Stockfish Chess Engine for Flutter.

Example

@PScottZero was kind enough to create a working chess game using this package.

Usages

iOS project must have IPHONEOS_DEPLOYMENT_TARGET >=12.0.

Add dependency

Update dependencies section inside pubspec.yaml:

  stockfish: ^1.7.0

Init engine

import 'package:stockfish/stockfish.dart';

// create a new instance
final stockfish = Stockfish();

// state is a ValueListenable<StockfishState>
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

Waits 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);
});

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.

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

// or even easier...
stockfish.dispose();

Note: only one instance can be created at a time. The factory method Stockfish() will return null if it was called when an existing instance is active.

S
Description
The Stockfish Chess Engine for dart/Flutter.
Readme GPL-3.0 942 KiB
Languages
C++ 95.3%
Dart 2%
C 1.9%
Ruby 0.5%
CMake 0.1%