如何将鳕鱼整合到Android应用程序中? [英] How does one integrate stockfish into an Android App?

查看:489
本文介绍了如何将鳕鱼整合到Android应用程序中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试研究如何将鳕鱼(或任何UCI兼容引擎)集成到我的Android应用程序中。

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

我从这里下载了Stockfish Android zip:
下载Stockfish引擎

I've downloaded the stockfish Android zip from here: Download Stockfish Engine.

在zip的Android目录下有两个文件:

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


  • stockfish-8-arm64-v8a

  • stockfish-8-armeabi-v7a

我有两个问题:


  1. 我是否只需要将这两个文件包含到我的应用程序中(如果那我该把它们放在哪里)?我希望这些是预先构建的二进制文件,所以我不需要担心编译自己。

  2. 如何从我的android Java代码调用这些文件?

谢谢!

推荐答案

鳕鱼是用C ++,要从用Java编写的常规Android应用程序调用它,你需要

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


  1. 依赖 JNI (Java Native Interface,见 jni-sample )来做这个伎俩。

  2. 在学习了如何使用JNI编译Stockfish之后,您可以通过 UCI协议与引擎进行交互:这里是UCI 规范

  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.

然后你可以调用特定的方法(例如评估po sition,或建议最好的举动)。这一切都始于发送引擎 isready 。如果你得到了答案,那么你就走在了正确的轨道上。

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.

修改现有项目要容易得多比如 Droidfish 而不是从头开始。

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

这篇关于如何将鳕鱼整合到Android应用程序中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆