2023-10-29 22:47:21 +01:00
# flutter_stockfish_plugin
2023-11-01 20:03:05 +01:00
A Flutter plugin for the Stockfish Chess engine.
2023-10-29 22:47:21 +01:00
2023-11-01 20:03:05 +01:00
The current version is based on Stockfish 16.
2023-10-29 22:47:21 +01:00
## Usage
```dart
final stockfish = new Stockfish()
// Listen on stdout of Stockfish engine
final stockfishSubscription = stockfish.stdout.listen((line) {
print("received: $line");
});
// Sending UCI command to get Stockfish ready
stockfish.stdin = 'isready'
stockfish.stdin = 'position startpos moves e2e4' // set up start position
stockfish.stdin = 'go depth 20' // search bestmove with a max septh of 20
// Don't remember to dispose Stockfish when you're done.
// Make shure to dispose Stockfish when closing the app. May use WindowListener.
stockfishSubscription.cancel();
stockfish.dispose();
```
2023-11-01 20:33:41 +01:00
A complete Example can be found at [stockfish_chess_engine ](https://github.com/loloof64/StockfishChessEngineFlutter ).
2024-02-25 00:39:40 +01:00
## Web support
2024-03-16 15:42:00 +01:00
Web support is currently experimental and requires manuly adding assets. It uses a version of stockfish compiled with [emscripten ](https://emscripten.org/ ).
2024-02-25 00:39:40 +01:00
2024-03-07 23:13:29 +01:00
Usage:
2024-03-16 15:42:00 +01:00
- Install `emscripten` and set the the Environment-Variable `EMSDK`
2024-03-07 23:13:29 +01:00
- Build the CMakeLists.txt in `web/`
- Copy the following files to `web/stockfish/` in your project:
- flutter_stockfish_plugin.js
- flutter_stockfish_plugin.wasm
- flutter_stockfish_plugin.worker.js
- js_bindings.js
- stockfish_data.bin
If a different path should be used: Change the path const's in `js_bindungs.js` and `stockfish_web_bindings.dart`
2024-02-25 00:39:40 +01:00
In order to make multithreading available, the site must run in a secure environment.
The following headers must be set for this:
- `Cross-Origin-Embedder-Policy: require-corp`
- `Cross-Origin-Opener-Policy: same-origin`
Problems:
2024-03-07 23:13:29 +01:00
- The current version does not include the `.js` , `.wasm` and neuralnetwork data as assets.
This files will not be bundles automaticly on the web.
2024-02-25 00:39:40 +01:00
2023-10-29 22:47:21 +01:00
## Goal of this fork of stockfish_chess_engine
2023-11-01 20:03:05 +01:00
* Avoid limitation. This version does not redirect stdout and stdin of the app for communication with stockfish.
* stdin and stdout were replaced with a fakestream element.
* Stockfish internal logging might not work (could be fixed).
2023-10-29 22:47:21 +01:00
## Credits
* Based on and using source code from [stockfish_chess_engine ](https://github.com/loloof64/StockfishChessEngineFlutter )
* Using source code from [Stockfish ](https://stockfishchess.org ).
* Using source code from [Flutter Stockfish ](https://github.com/ArjanAswal/Stockfish ).
Directory src/Stockfish contains the latest current release.
The code is modified to use a different communication interface.
2024-02-23 19:38:19 +01:00
The original license for [Stockfish ](https://stockfishchess.org ) can be found in their [GitHub ](https://github.com/official-stockfish/Stockfish ) repository.
2024-02-25 01:18:13 +01:00
Directory web/ may contains code compiled from [emscripten ](https://emscripten.org/ ). Emscripten is licensed among others under the MIT License. [License Page ](https://emscripten.org/docs/introducing_emscripten/emscripten_license.html )