Giter Site home page Giter Site logo

garawaa / stockfish Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arjanaswal/stockfish

0.0 1.0 0.0 279 KB

The Stockfish Chess Engine for Flutter.

License: MIT License

Kotlin 0.02% Swift 0.07% Objective-C 0.02% Dart 2.19% Ruby 0.50% CMake 0.05% Java 0.08% Objective-C++ 0.06% C++ 94.80% C 2.19%

stockfish's Introduction

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: ^0.1.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.

stockfish's People

Watchers

 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.