UCI and XBoard Protocols for Android
UCI engine on an HTC HD2 with Android
(photo courtesey Thorsten Czub)
![[HTC]](htc.jpg) |
UCI engine on Aart's Nexus One
(complete 3-4-5-piece Nalimov on 8GB SD card)
![[HTC]](nexus.jpg) |
The
Universal Chess Interface (UCI)
was designed by Stefan Meyer-Kahlen and Rudolf Huber
as an open interface between a chess engine and a chess
GUI. The interface allows chess programmers to focus on
writing the chess engine, leaving details such as board
setup and play, clock and notation display, and possibly
opening book and root-level endgame tablebases play to
the GUI. Examples of programs on Windows, Linux, and
Mac OS with UCI engine support are
Arena,
ChessBase Fritz,
Lucas Chess, and
Sigma Chess.
Since August 2010, Chess for Android
provides UCI support on the Android platform.
The
Chess Engine Communication Protocol (often simply called the
XBoard or WinBoard protocol) provides an alternative protocol
between engines and a GUI. In October 2011,
Chess for Android
added support for the XBoard protocol as well.
Android Development
Applications for the Android platform (mainly ARMv5TE-based devices,
although x86-based devices are emerging as well) can be developed in
several ways. (1) Most development for Android is done using the
Android SDK
and the Java programming language. An application is compiled
into bytecode that runs on the Dalvik Virtual Machine, making
this approach the most portable (it runs on ARMv5TE and x86,
as well as on possible future architectures). Because
bytecode interpretation has lower performance than native code,
Android 2.2
(aka Froyo) introduced the Dalvik JIT compiler, which translates
bytecode into native code right before execution for a speed boost.
The Chess for Android GUI and its built-in engine are implemented
using this first approach, and ship as a single package.
(2) Alternatively, developers that want higher performance can use the
Android NDK
to write performance-critical portions in C/C++, which is compiled
into native code (ARMv5TE and/or x86). Those native components are then
embedded through JNI in a regular Android application that is developed
with the SDK. In this second approach, the bytecode and native components
still ship as a single package.
(3) Finally, developers can do all development in C/C++ and generate
stand-alone native code using the appropriate compiler toolchain (e.g.
CodeSourcery for ARM
or the toolchain that ships with the NDK).
This third approach is used by Chess for Android to
import engines that do not ship with the application.
Users can first get Chess for Android from the market, and later install
third party engines from any other (possibly private) source.
Importing UCI and XBoard Engines in Chess for Android
Before UCI and XBoard engines can be imported in
Chess for Android
they first must be installed in internal memory as follows:
- Get one or more engines in the proper native format
(ARMv5TE for most mobile devices, x86 for a few others).
You can either compile your own engine
or obtain binaries elsewhere, see
UCI and XBoard Engines for Android.
- Copy the engines anywhere on the SD card of the Android
device. To do this from a desktop, connect the device through
the USB cable and select the USB storage option. This
usually pops up a navigation window to which engines
can be dragged-and-dropped. Alternatively, one can
download engines directly to the device over the
internet (this typically saves in
/sdcard/download).
- Open Chess for Android on the device, long press the
notation window, enter the UCI and XBoard submenu,
and select Install Engine from SD, which
opens a file navigation window. Select the appropriate
engine and wait until a message pops up that the
engine has been installed on internal memory.
Repeat this install for every new engine.
- Optionally, if useful for any of the installed engines,
copy the Nalimov, Gaviota, Scorpio, and/or Robbobases endgame
tablebases to SD card in the recommended default folders
/sdcard/tb, /sdcard/gtb,
/sdcard/egbb, and/or /sdcard/robbo,
respectively (complete 3- and 4-piece Nalimov takes 29.6MB,
complete 3-, 4- and 5-piece Nalimov takes 7.05GB).
This only has to be done once per Android device.
Engine authors probably need to change
probing heuristics when reading from SD card.
To actually import an engine in Chess for Android for game play, go
to the UCI and XBoard submenu again, but now pick Import Engine
and select the appropriate engine from the list of installed engines.
If the import is successful, a window pops up with the engine name and
author to indicate that the built-in Java chess engine now has been
replaced by the imported engine (exiting the application
unloads the engine). Some screenshots are shown below. Also see the
Chess for Android Manual.
Please note that this page is privately maintained by
Aart Bik.