Coder Social home page Coder Social logo

dbergan / fairy_stockfish_flutter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arjanaswal/stockfish

0.0 0.0 0.0 431 KB

Brining Fairy Stockfish to my Flutter app

License: GNU General Public License v3.0

Shell 1.05% Ruby 0.50% C++ 94.18% C 1.95% Objective-C 0.02% Java 0.07% Kotlin 0.02% Dart 2.01% Objective-C++ 0.05% Swift 0.06% CMake 0.08%

fairy_stockfish_flutter's Introduction

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 >=11.0.

Add dependency

Update dependencies section inside pubspec.yaml:

  stockfish: ^1.4.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.

fairy_stockfish_flutter's People

Contributors

daohoangson avatar arjanaswal avatar veloce avatar restyled-commits avatar restyled-io[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.