Stockfish in Lozza UIs

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

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
op12no2
Posts: 349
Joined: Tue Feb 04, 2014 11:25 am
Location: Mumbles, Wales, UK.
Full name: Colin Jenkins
Contact:

Stockfish in Lozza UIs

Post by op12no2 » Wed Jan 07, 2015 2:08 pm

There is a growing need to 'compile' static languages into Javascript for native use in web browsers etc. Mozilla's approach is to use Clang to convert C/C++ to LLVM then emscripten to convert that in a subset of Javascript that minimises garbage collection (asm.js).

Norbert pointed me at a project where somebody had done that for Stockfish 5. https://github.com/exoticorn/stockfish-js

Given that Lozza is a UCI compliant engine needing no extra commands for web use - it's an edit of one line to replace Lozza with stockfish in my web UIs. I tweaked the play UI to take the engine as a paramater:-

Play Lozza (default): http://op12no2.me/toys/lozzadev/play.htm

Play Stockfish: http://op12no2.me/toys/lozzadev/play.htm?e=stockfish.js

So if you want your engine on the web, feel free to start with my UI code or donate your .js file for inclusion in the Lozza repertoire... Can then extend a bit to run Javascript tournys in client browsers...

Thanks Norbert!

PS: Firefox support asm.js explicitly, Google does not, indeed their whole approach to this is different but Stockfish will run in both Browsers. Dunno about Explorer etc.

op12no2
Posts: 349
Joined: Tue Feb 04, 2014 11:25 am
Location: Mumbles, Wales, UK.
Full name: Colin Jenkins
Contact:

Re: Stockfish in Lozza UIs

Post by op12no2 » Wed Jan 07, 2015 3:17 pm

Lozza UCI console + stockfish.js

http://op12no2.me/toys/lozzadev/console ... ockfish.js

The undefined stuff means I must be making some Lozza specific assumptions which I shall resolve.

James Constance
Posts: 353
Joined: Wed Mar 08, 2006 7:36 pm
Location: UK

Re: Stockfish in Lozza UIs

Post by James Constance » Wed Jan 07, 2015 4:25 pm

Very nice - thanks!

op12no2
Posts: 349
Joined: Tue Feb 04, 2014 11:25 am
Location: Mumbles, Wales, UK.
Full name: Colin Jenkins
Contact:

Re: Stockfish in Lozza UIs

Post by op12no2 » Wed Jan 07, 2015 5:56 pm

James Constance wrote:Very nice - thanks!
:) Thanks, done the analysis UI as well now.

http://op12no2.me/toys/lozzadev/fen.htm?e=stockfish.js

I've never looked at the Stockfish code but the NPS reported is slow, so it's either an artifact of my UI or it's pruning like my Grandmother used to prune her roses every year. It gets to crazy depths with a tiny node count!

op12no2
Posts: 349
Joined: Tue Feb 04, 2014 11:25 am
Location: Mumbles, Wales, UK.
Full name: Colin Jenkins
Contact:

Re: Stockfish in Lozza UIs

Post by op12no2 » Wed Jan 07, 2015 6:01 pm

The analysis UI can take a FEN and an action (analyse|evaluate). This is stockfish.js analysing fine #70 - it's insane.

http://op12no2.me/toys/lozzadev/fen.htm ... 0-&act=ana

I give up writing Javascript engines by hand :)

This is Lozza doing the same:-

http://op12no2.me/toys/lozzadev/fen.htm ... 0-&act=ana

gladius
Posts: 538
Joined: Tue Dec 12, 2006 9:10 am

Re: Stockfish in Lozza UIs

Post by gladius » Wed Jan 07, 2015 6:34 pm

Very very cool :). asm.js/emscripten is great stuff. Your UI is really nice too!

I will get UCI support added to garbochess.js one of these days and we can have a js engine tournament :).

User avatar
cdani
Posts: 2104
Joined: Sat Jan 18, 2014 9:24 am
Location: Andorra
Contact:

Re: Stockfish in Lozza UIs

Post by cdani » Wed Jan 07, 2015 7:28 pm

Incredible!! :-)

op12no2
Posts: 349
Joined: Tue Feb 04, 2014 11:25 am
Location: Mumbles, Wales, UK.
Full name: Colin Jenkins
Contact:

Re: Stockfish in Lozza UIs

Post by op12no2 » Wed Jan 07, 2015 9:33 pm

gladius wrote: I will get UCI support added to garbochess.js one of these days and we can have a js engine tournament :).
Yay!

op12no2
Posts: 349
Joined: Tue Feb 04, 2014 11:25 am
Location: Mumbles, Wales, UK.
Full name: Colin Jenkins
Contact:

Re: Stockfish in Lozza UIs

Post by op12no2 » Thu Jan 08, 2015 9:01 am

cdani wrote:Incredible!! :-)
When you consider that Javascript has no 64bit integer type so all Stockfish 5's bitboard stuff is being done 32 bits at a time - and the javascript is being compiled and optimsied in real time - the performance is amazing.

op12no2
Posts: 349
Joined: Tue Feb 04, 2014 11:25 am
Location: Mumbles, Wales, UK.
Full name: Colin Jenkins
Contact:

Re: Stockfish in Lozza UIs

Post by op12no2 » Thu Jan 08, 2015 9:07 am

The Fine #70 comparison is interesting. Stockfish just keeps on quickly getting through the plys, finding Kb1 from the outset. Lozza takes a while to get to the point were it discovers Kb1 then grinds to a virtual halt... I presume the number of legal moves explodes soon after that point? Or I have a bug (better!).

Post Reply