stockfish 0.0.1 copy "stockfish: ^0.0.1" to clipboard
stockfish: ^0.0.1 copied to clipboard

outdated

The Stockfish Chess Engine for Flutter.

stockfish #

The Stockfish Chess Engine for Flutter.

Usages #

  • iOS project must have IPHONEOS_DEPLOYMENT_TARGET >=11.0.

Add dependency #

Update dependencies section inside pubspec.yaml:

  stockfish:
    git:
      url: git@github.com:ArjanAswal/Stockfish.git

The git dependency is temporary until the plugin is published to pub.dev.

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.

19
likes
0
pub points
81%
popularity

Publisher

verified publisherarjanaswal.com

The Stockfish Chess Engine for Flutter.

Homepage

License

unknown (LICENSE)

Dependencies

ffi, flutter

More

Packages that depend on stockfish