PDA

View Full Version : Using Windows UCI engines with HIARCS Mac Chess Explorer



Hasimir
09-08-2014, 09:21 PM
My primary chess database and management software these days is Deep HIARCS Chess Explorer for Mac (http://www.hiarcs.com/mac-chess-explorer.htm). I've used a lot of chess software over the years, but this is by far the cleanest and most intuitive of all the interfaces I've dealt with. Don't get me wrong, Rebel for DOS was brilliant for its time, but a clean interface wasn't exactly something it could lay claim to.

The engines this thing came with (mainly Deep HIARCS 14) are pretty damn good and do a more than reasonable job of playing a "human-like" game (no easy task), rather than just being compact power-houses of pure tactics, brute-forcing their way through games and, almost incidentally, their human masters (insert pointed look at Stockfish and Houdini here). That said, you should never rely on just one engine for analysis, training or whatever. Since I had Arena running under Wine before I bought HIARCS I began to wonder how difficult it would be to get those 32-bit Windows engines to play nicely on the Mac, but without using a Windows GUI.

A crash course in the Universal Chess Interface (UCI) ... also known as reading the protocol specs and I devised a cunning plan. Essentially it worked and the ongoing results of that little project are being posted to the HIARCS forum (http://hiarcs.net/forums/viewtopic.php?t=6776) as I go. I'm not going to simply repost everything here, but a summary will help (then if it's the sort of thing you're willing to try you can go to that forum for the step-by-step instructions).

What you will need:

1) A Mac running some version of OS X capable of running HIARCS (or possibly some other OS X only software), so probably 10.6.x (Snow Leopard) and above. My dev work has been on 10.9.x (Mavericks).

2) The XCode SDK from Apple, including the command line tools.

3) Wine or CrossOver. I used Wine installed with Mac Ports, many people swear by Home Brew, but it messes with other dev environments it shouldn't be touching so I avoid it. Mac Ports restricts itself to /opt/local and stays there (which is a nice way of saying Mac Ports is designed better than Home Brew, it's just that Home Brew is more popular).

4) One or more Win32 only UCI chess engines you want to get working.

5) A decent text editor, no qualms with using the command line and a rudimentary knowledge of compiling software.

The process to make the engine behave is to make a very simple wrapper for it that HIARCS Chess Explorer (HCE) will recognise as a mach-o executable and which will respond to all the UCI instructions appropriately. It needs to be a single file, so using a wineskin or cider port won't help. Fortunately all UCI needs is for data to be transmitted in and out using stdin, stdout and (kind of optionally) stderr. Actually, all those engines are just text based, you can type what you want them to do if you run them on the command line and can be bothered.

The solution I found was to write a little C++ code which would make a system call to run the Win32 engine in Wine. When compiled the result would be a small native OS X binary which HCE could run and would communicate via the UCI protocol properly.

The C++ code is essentially this:



#include <stdio>
#include <stdlib>

int main()
{
system("/path/to/bin/wine /path/to/collection/of/engines/engineUCI-1.0.2.exe");
}


If that was saved as engineUCI-1.0.2.cc the next step would be:


g++ engineUCI-1.0.2.cc -o engineUCI-1.0.2

If you used full paths to Wine and the (permanent) location of your engine, this file should be ready to be loaded into HCE. A proper example with additional details on file locations are in the original thread on the HIARCS site. The explanation for using full paths rather than relative paths is included, though it does make each installation fairly specific to that computer, which is why I do not make binaries available.

The first Win32 engine I tried this on was Dragon 4.6 and it worked. After that I tried Rybka, which failed utterly. AnMon started out alright, but crashed a short way in. Hermann 2.8 was fine.

Ruffian made it eleven moves in before quitting unexpectedly, but it did not crash. Nejmet was fine, but like Hermann before it, it lost badly when pitted against HIARCS. SOS 5 for Arena handled itself very well, even managing to draw one game out of 4. Spike 1.4 was an utter failure.

ProDeo 1.88 also doesn't work, though there are additional design complications with that. Not least of which being that ProDeo and Rebel are essentially the same design and the UCI executable (rebeluci.exe) which comes with it is really a wrapper for the old method of operating which Ed Schröder developed for Rebel when it was a commercial package and is now giving away. A wrapper for the wrapper doesn't work as expected and considerably more work will need to be done before that changes.

Finally, the most recent tests have been with the successful porting of Houdini 3a Pro and Houdini 4, with some surprising results in analysis. PGN for these contests between HIARCS and the new engines is in the original thread, you can get them there if you're interested.

Finally, I mentioned this throughout the hiarcs.net posts and I must stress it here too. There is no warranty, guarantee or offer of support with this. I tried it and it worked for me (sometimes), all I'm doing is offering information if anyone is willing enough to try it.