Saturday, December 23, 2017

How to integrate stockfish in Android App

Leave a Comment

I'm trying to work out how to integrate stockfish (or any UCI compatible engine) into my Android application.

I've downloaded the stockfish Android zip from here: https://stockfishchess.org/download/

Under the Android directory of the zip there are two files:

  • stockfish-8-arm64-v8a
  • stockfish-8-armeabi-v7a

I have two questions:

  1. Do I just need to include these two files into my app (and if so where do I put them)? I'm hoping these are pre-built binaries so I don't need to worry about compiling myself.
  2. How do I call into these files from my android Java code?

Thanks!

1 Answers

Answers 1

Stockfish is written in C++, to call it from a regular Android app written in Java, you need to

  1. rely on JNI (Java Native Interface, see jni-sample) to do the trick.
  2. After you have learned how to compile Stockfish with JNI, you can interact with the engine via UCI protocol: Here are the UCI Specification.

  3. Then you can call specific methods (e.g. to evaluate a position, or to suggest the best move). It all starts with sending the engine isready. If you get an answer, you are on the right track.

It would be far easier to modify an existing project like Droidfish instead of starting from scratch.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment