Stockfish in Lozza UIs

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

op12no2
Posts: 489
Joined: Tue Feb 04, 2014 12:25 pm
Full name: Colin Jenkins

Re: Stockfish in Lozza UIs

Post by op12no2 »

gladius wrote: I will get UCI support added to garbochess.js one of these days and we can have a js engine tournament :).
PS: the onmessage() function in here http://op12no2.me/toys/lozzadev/lozza.js does all the UCI input stuff. feel free to use it. It's not elegant but get's the job done. It updates a global object uci.spec that is then used by the native code. Regular expressions would be more elegant by they turn my brain to mush... :)
op12no2
Posts: 489
Joined: Tue Feb 04, 2014 12:25 pm
Full name: Colin Jenkins

Re: Stockfish in Lozza UIs

Post by op12no2 »

Gary,

It was quiet in work this afternoon so I did the necessary tweaks to your original Javascript GarboChess engine to make it UCI compliant.

source: http://op12no2.me/posts/1964

I've added it to the Lozza engines:-

play | analyse | console

As well as working online it now works in UIs like Arena and the command line using node.js or jsUCI as the host exe.

Another alternative is to compile V8 and tweak their shell example to create your own stand alone exe. I am trying to do this but totally failing to follow the destructions to build V8. Edmund? :)

Note also the link to jxCore in the above post which makes it easy to create executables.

Please do feel free to send me any new versions; it'd be great to to keep the Lozza site up to date.

If anybody else is interested in developing a Javascript (not Java) engine, I made some notes here.

PS: the time control stuff I added is very primitive...
op12no2
Posts: 489
Joined: Tue Feb 04, 2014 12:25 pm
Full name: Colin Jenkins

Re: Stockfish in Lozza UIs

Post by op12no2 »

PPS: I'm not totally convinced I'm initialising the right stuff on a POSITION message.
gladius
Posts: 568
Joined: Tue Dec 12, 2006 10:10 am
Full name: Gary Linscott

Re: Stockfish in Lozza UIs

Post by gladius »

op12no2 wrote:Gary,

It was quiet in work this afternoon so I did the necessary tweaks to your original Javascript GarboChess engine to make it UCI compliant.
Awesome!! Thanks so much :).

Is there a way to do engine-engine play in your UI?

Really nice web UI too btw :).
op12no2
Posts: 489
Joined: Tue Feb 04, 2014 12:25 pm
Full name: Colin Jenkins

Re: Stockfish in Lozza UIs

Post by op12no2 »

gladius wrote:
Awesome!! Thanks so much :).

Is there a way to do engine-engine play in your UI?

Really nice web UI too btw :).
Not yet. I want to add time controls to the play UI then add a match capability. For now you can do it offline in Arena or Winboard etc using jsUCI or node. When I tried GarboChess in Arena (using node) it was displaying some pretty wild centipawn values - I may not be sending back the right variable and/or not initialising correctly on UCINEWGAME and/or POSITION.

It would be really interesting if you could develop your JS version to be equal in strength to the C# version (I think) that is on CCRL.

I can't help feeling that JIT compiling and optimising in real-time a la V8 is in fact a good thing for chess engines since "hot" funcs are targetted. V8 often deoptimises though and the trick is finding out why and stopping it. You can fire up GarboChess in node and watch V8 optimising and deoptimising using:-

Code: Select all

node --trace-opt --trace-deopt --code-comments --allow-natives-syntax garbo.js
I started with a depth 1 search and worked from there. I've only got to depth 3 without any deoptimising so far :)

--allow-natives-syntax is a really interesting option that allows you to control V8 using a special syntax, e.g. I tell it to never optimise my TT initialisation function like this:-

Code: Select all

if (lozzaHost == HOST_NODEJS) {
  %NeverOptimizeFunction(lozBoard.prototype.ttInit);
}
You can also trace what is and isn't optimised etc etc. I'm guessing it's possible to get a really good performance (to compete with some of the better native executables out there) from a Javascript chess engine in this way, but I'm probably not the person to eventually do it.

Apologies if you know all this node stuff :)

Thanks for the comment on the UI - chessboard.js you know and the lovely buttons and general presentation is courtesy of the most awesome Twitter bootstrap.
op12no2
Posts: 489
Joined: Tue Feb 04, 2014 12:25 pm
Full name: Colin Jenkins

Re: Stockfish in Lozza UIs

Post by op12no2 »

PS: GarboChess 64 bit Windows exe I was messing around with - may be useful: http://op12no2.me/toys/lozza/garbo.zip