How does one integrate stockfish into an Android App?

故事扮演 提交于 2019-12-08 15:19:01

问题


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: Download Stockfish Engine.

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:


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.



来源:https://stackoverflow.com/questions/43566840/how-does-one-integrate-stockfish-into-an-android-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!