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.
Stockfish in Lozza UIs
Moderator: Ras
-
- Posts: 540
- Joined: Tue Feb 04, 2014 12:25 pm
- Location: Gower, Wales
- Full name: Colin Jenkins
-
- Posts: 540
- Joined: Tue Feb 04, 2014 12:25 pm
- Location: Gower, Wales
- Full name: Colin Jenkins
Re: Stockfish in Lozza UIs
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.
http://op12no2.me/toys/lozzadev/console ... ockfish.js
The undefined stuff means I must be making some Lozza specific assumptions which I shall resolve.
-
- Posts: 358
- Joined: Wed Mar 08, 2006 8:36 pm
- Location: UK
Re: Stockfish in Lozza UIs
Very nice - thanks!
-
- Posts: 540
- Joined: Tue Feb 04, 2014 12:25 pm
- Location: Gower, Wales
- Full name: Colin Jenkins
Re: Stockfish in Lozza UIs
James Constance wrote:Very nice - thanks!

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!
-
- Posts: 540
- Joined: Tue Feb 04, 2014 12:25 pm
- Location: Gower, Wales
- Full name: Colin Jenkins
Re: Stockfish in Lozza UIs
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
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
-
- Posts: 568
- Joined: Tue Dec 12, 2006 10:10 am
- Full name: Gary Linscott
Re: Stockfish in Lozza UIs
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
.

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

-
- Posts: 2204
- Joined: Sat Jan 18, 2014 10:24 am
- Location: Andorra
-
- Posts: 540
- Joined: Tue Feb 04, 2014 12:25 pm
- Location: Gower, Wales
- Full name: Colin Jenkins
Re: Stockfish in Lozza UIs
Yay!gladius wrote: I will get UCI support added to garbochess.js one of these days and we can have a js engine tournament.
-
- Posts: 540
- Joined: Tue Feb 04, 2014 12:25 pm
- Location: Gower, Wales
- Full name: Colin Jenkins
Re: Stockfish in Lozza UIs
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.cdani wrote:Incredible!!
-
- Posts: 540
- Joined: Tue Feb 04, 2014 12:25 pm
- Location: Gower, Wales
- Full name: Colin Jenkins
Re: Stockfish in Lozza UIs
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!).