pikafish 1.0.5 copy "pikafish: ^1.0.5" to clipboard
pikafish: ^1.0.5 copied to clipboard

PlatformiOS

The Flutter plugin for PIKAFISH (base on Stockfish), A well-known Chinese chess open source engine.

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>

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

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';

Engine output is directed to a Stream

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

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();

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.

Refer the implementation #

https://github.com/ArjanAswal/stockfish

0
likes
160
points
26
downloads

Publisher

unverified uploader

Weekly Downloads

The Flutter plugin for PIKAFISH (base on Stockfish), A well-known Chinese chess open source engine.

Homepage
Repository (GitHub)

Documentation

API reference

License

GPL-3.0 (license)

Dependencies

ffi, flutter, logging

More

Packages that depend on pikafish