pikafish_engine2

Last updated:

0 purchases

pikafish_engine2 Image
pikafish_engine2 Images
Add to Cart

Description:

pikafish engine2

flutter_pikafish #
The Flutter plugin for PIKAFISH (base on Stockfish), A well-known Chinese chess open source engine.
Usages #
iOS project must have IPHONEOS_DEPLOYMENT_TARGET >=11.0.
Add dependency
Update dependencies section inside pubspec.yaml:
flutter_pikafish: ^<last-version>
copied to clipboard
Init engine
import 'package:pikafish_engine/pikafish_engine.dart';

// create a new instance
final pikafish = Pikafish();

// state is a ValueListenable<PikafishState>
print(pikafish.state.value); # PikafishState.starting

// the engine takes a few moment to start
await Future.delayed(...)
print(pikafish.state.value); # PikafishState.ready
copied to clipboard
UCI command
Waits until the state is ready before sending commands.
pikafish.stdin = 'isready';
pikafish.stdin = 'go movetime 3000';
pikafish.stdin = 'go infinite';
pikafish.stdin = 'stop';
copied to clipboard
Engine output is directed to a Stream
pikafish.stdout.listen((line) {
// do something useful
print(line);
});
copied to clipboard
Dispose / Hot reload
There are two active isolates when Pikafish 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
pikafish.stdin = 'quit';

// or even easier...
pikafish.dispose();
copied to clipboard
Note: only one instance can be created at a time.
The factory method Pikafish() will return null if it was called when an existing instance is active.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.