Page 1 of 2

Anticrux UCI Javascript Engine

Posted: Sat Aug 05, 2017 9:06 am
by Norbert Raimund Leisner
Hello,

can you tell me how the implementation of
Anticrux UCI Javascript https://github.com/ecrucru/anticrux works correctly with the software Javascript Universal Chess Interface https://sourceforge.net/projects/jsuci/ like Lozza JS / Stockfish JS into WinBoard 4.8.0 http://www.open-aurec.com/wbforum/viewt ... 19&t=51528 ?

Which necessary informations have to be inserted into the following rows?

engine (.exe or .jar): __________________________
commandline-line parameters:________________________
WinBoard options:____________________________

> option UCI

I have mentioned Anticrux on CCWiki ici:
http://computer-chess.org/doku.php?id=c ... ngine_list (>Losing Chess/Suicide Chess)

Best wishes,
Norbert

Re: Anticrux UCI Javascript Engine

Posted: Sat Aug 05, 2017 9:42 am
by gbtami
I have never used jsuci but if you have installed Node.js as https://github.com/ecrucru/anticrux#anticrux-engine say you can run it from command line like:

Code: Select all

node --expose-gc anticrux-engine.js

Re: Anticrux UCI Javascript Engine

Posted: Sat Aug 05, 2017 1:33 pm
by hgm
The best procedure for experimenting with engines that need special adapters / interpreters is to first try to get it running from the commad line. E.g. if you establish that

jsuci Anticrux.js

or

node --bla-bla anticrux.js

works on the command line (i.e. it responds when you type 'uci' to it), you can then install it with the first word of the command (i.e. jsuci or node) as the engine executable, and the remainder of the line (i.e. Anticruc.js or --bla-bla anticrux.js) as command-line parameters. And of course do't forget to tick the 'UCI' checkbox.

Re: Anticrux UCI Javascript Engine

Posted: Mon Aug 07, 2017 2:41 am
by Edmund
Thank you Norbert for pointing out this interesting project!

Anticrux is not out of the box portable with jsuci, as jsuci is basically a lightweight nodejs wrapper that communicates via the functions postmessage and onmessage with the js code. Anticrux apparently directly communicates with nodejs.
Porting the code however only requires a few code line-additions.

I started downloading the whole package (at least we need anticrux.js and anticrux-engine.js).

Next I modify the file anticrux-engine.js:
- before //======== Initialization (line 29) I insert the following two lines

Code: Select all

function require(x) {};
var process = {on: function(x,y) {}};
- before //======== Entry point (line 51) I insert the following five lines

Code: Select all

importScripts('anticrux.js');
var msgfun;
var readline = {createInterface: function(x) {return { on: function(x,y) { msgfun = y } };}};
var aceng_output = postMessage;
var onmessage = function(e) { msgfun(e.data); }


now I can run the engine. in the command line I navigate to the jsuci folder and enter:
jsuci_1_2 anticrux-engine.js

When I then write "uci" the engine correctly returns: id name AntiCrux 0.3.0 ...

Norbert, are you in touch with the author? Maybe he is interested in supplying a modified anticrux-engine.js together with his download package to also allow for this port.

Re: Anticrux UCI Javascript Engine

Posted: Mon Aug 07, 2017 10:40 am
by gbtami
Maybe I misunderstand the problem, but anticrux can be used without jsuci. At least it works with pychess and should work with other GUI-s too the same way as HGM explained it. Why anyone wants to complicate hes life with jsuci at all here?

Re: Anticrux UCI Javascript Engine

Posted: Wed Aug 09, 2017 1:14 am
by Edmund
I have now also tried running the engine in winboard using the following configuration line:
"jsuci_1_2.exe anticrux-master\anticrux-engine.js" -fd "..\jsuci 1.2" -fUCI

as you can see I placed the "anticrux-master" folder in the "jsuci 1.2" folder. And this folder is in the parent folder of winboard. I managed to play a few moves by hand (in standard mode), but I was unable to tell winboard that anticrux is playing suicide chess. And consequentially the game always ended with anticrux not moving the king out of check.

anticrux sends:

Code: Select all

option name UCI_Chess960 type check default false
option name UCI_Variant type combo default suicide var suicide
However in the polyglot log I only read

Code: Select all

Adapter->GUI: feature variants="normal,fischerandom"
Adapter->GUI: feature option="UCI_Variant -combo *suicide"
Any idea how I can communicate to Winboard/Polyglot that the engine is in fact capable of suicide chess?

Re: Anticrux UCI Javascript Engine

Posted: Wed Aug 09, 2017 1:46 am
by Edmund
gbtami wrote:Maybe I misunderstand the problem, but anticrux can be used without jsuci. At least it works with pychess and should work with other GUI-s too the same way as HGM explained it. Why anyone wants to complicate hes life with jsuci at all here?
I agree that nodejs does the trick. After all jsuci is just a lightweight wrapper around nodejs. The advantage of a jsuci for end-users is that it is a small one-file download, with no necessary installation, compilation etc. and the advantage for javascript programmers is that you can avoid low level commands dealing with input/output interfaces. If you are however a programmer who is familiar with the technology, of cause, feel free to go with nodejs.

My original aim for when I developed jsuci was to establish a common standard interface for javascript engines. An engine abiding by this standard should be useable as exe (through jsuci) as well as on websites (as webworker) alike. After all its a simple standard - you can see how I transformed anticrux to this standard with a few changed code lines.

Re: Anticrux UCI Javascript Engine

Posted: Wed Aug 09, 2017 8:12 am
by hgm
Edmund wrote:Any idea how I can communicate to Winboard/Polyglot that the engine is in fact capable of suicide chess?
Polyglot does not support Suicide Chess (or in fact any variant); it pedantically enforces the rules of normal Chess. You would heve to use UCI2WB.

Re: Anticrux UCI Javascript Engine

Posted: Wed Aug 09, 2017 11:29 am
by gbtami
Edmund wrote:
gbtami wrote:Maybe I misunderstand the problem, but anticrux can be used without jsuci. At least it works with pychess and should work with other GUI-s too the same way as HGM explained it. Why anyone wants to complicate hes life with jsuci at all here?
I agree that nodejs does the trick. After all jsuci is just a lightweight wrapper around nodejs. The advantage of a jsuci for end-users is that it is a small one-file download, with no necessary installation, compilation etc. and the advantage for javascript programmers is that you can avoid low level commands dealing with input/output interfaces. If you are however a programmer who is familiar with the technology, of cause, feel free to go with nodejs.

My original aim for when I developed jsuci was to establish a common standard interface for javascript engines. An engine abiding by this standard should be useable as exe (through jsuci) as well as on websites (as webworker) alike. After all its a simple standard - you can see how I transformed anticrux to this standard with a few changed code lines.
I see the advantage of jsuci from end-user perspective when an engine supports it, but if it's not, the traditional way like run "script" engine with appropriate "runtime environment" is always usable. python for .py, node for .js and so on.

Re: Anticrux UCI Javascript Engine

Posted: Thu Aug 10, 2017 4:09 am
by Edmund
hgm wrote:
Edmund wrote:Any idea how I can communicate to Winboard/Polyglot that the engine is in fact capable of suicide chess?
Polyglot does not support Suicide Chess (or in fact any variant); it pedantically enforces the rules of normal Chess. You would heve to use UCI2WB.
Thank you very much, hgm!
As I have never dealt with installing variant engines before, I am now standing in front of the same problem than before.

I managed to get Anticrux to run under the uci2wb shipped with the latest winboard ("UCI2WB 1.10").
This is the dialog I get:

Code: Select all

C:\Program Files (x86)\Winboard\WinBoard>UCI2WB "jsuci_1_2.exe anticrux-master\a
nticrux-engine.js" "..\jsuci 1.2"
xboard
protover 2
feature variants="normal,xiangqi" setboard=1 usermove=1 debug=1 ping=1 reuse=0 e
xclude=1 pause=1 done=0
feature option="UCI2WB debug output -check 0"
feature myname="AntiCrux 0.3.0 (UCI2WB)"
feature option="UCI_Chess960 -check 0"
feature option="UCI_Variant -combo suicide"
feature option="level -spin 5 1 20"
feature option="debug -check 0"
feature smp=1 memory=0 done=1
new
variant suicide
usermove e2e4
go
ping 1
pong 1
go
move e7e6
If I try to run /variant suicide in Winboard, it again reports that the variant is not known to the engine. Can you recommend how to inject the additional variants feature (preferably without having to compile the code myself) or tell winboard to ignore the variant feature received.