Releasing Javascript engines as stand-alone executables

Discussion of chess software programming and technical issues.

Moderator: Ras

op12no2
Posts: 547
Joined: Tue Feb 04, 2014 12:25 pm
Location: Gower, Wales
Full name: Colin Jenkins

Releasing Javascript engines as stand-alone executables

Post by op12no2 »

Historically I have observed that users and testers can get confused and frustrated using the Node route to get Javascript engines up and running. Or simply do not wish to install Node, which of course is fair enough.

I have tried various ways of supplying Lozza as an executable engine, but all were a bit hit-and-miss or ultra-fiddly; until I tried a Node module called pkg:-

https://github.com/vercel/pkg

If your Javascript engine is Node-friendly, which it probably is if using UCI/XBoard and traditional UIs, the simple use of:-

Code: Select all

pkg lozza.js
will package the latest version of Node (not the one you have installed) together with lozza.js into executables for Windows, Linux and Mac.

You can also target specific Node versions, platforms and architectures. For example Windows 7 does not run the latest Node versions, so you can do something like:-

Code: Select all

pkg -t node10-win-x64 -o w7lozza.exe lozza.js


The executables that I've tried (Windows and Linux) seem to work perfectly.
op12no2
Posts: 547
Joined: Tue Feb 04, 2014 12:25 pm
Location: Gower, Wales
Full name: Colin Jenkins

Re: Releasing Javascript engines as stand-alone executables

Post by op12no2 »

Reading that back, it's a little unclear.

What you get is a stand-alone engine, not something that will unpack Node and your engine on invocation.

So in a UI target you can put "myengine.exe" as opposed to "node.exe myengine.js"
KhepriChess
Posts: 93
Joined: Sun Aug 08, 2021 9:14 pm
Full name: Kurt Peters

Re: Releasing Javascript engines as stand-alone executables

Post by KhepriChess »

I tried this early on with my JS engine, and actually decided not to release an actual executable because I found it performed noticeably worse than just the JS file by itself. I have no idea why that would be though, and perhaps I should test it again.
Puffin: Github
KhepriChess: Github
op12no2
Posts: 547
Joined: Tue Feb 04, 2014 12:25 pm
Location: Gower, Wales
Full name: Colin Jenkins

Re: Releasing Javascript engines as stand-alone executables

Post by op12no2 »

KhepriChess wrote: Wed Jan 26, 2022 7:09 pm I tried this early on with my JS engine, and actually decided not to release an actual executable because I found it performed noticeably worse than just the JS file by itself. I have no idea why that would be though, and perhaps I should test it again.
Hmm, I have to admit my test was a little informal. I will do 20k games. I'm willing to lose a few ELO for the benefit of users' ease of use.
op12no2
Posts: 547
Joined: Tue Feb 04, 2014 12:25 pm
Location: Gower, Wales
Full name: Colin Jenkins

Re: Releasing Javascript engines as stand-alone executables

Post by op12no2 »

So far so good...

coalfacebin is the exe. Both Node v17. TC 10 + 0.1. Win 11.

Code: Select all

Score of coalface vs coalfacebin: 1709 - 1741 - 2620  [0.497] 6070                                                                                                             
...      coalface playing White: 867 - 887 - 1281  [0.497] 3035                                                                                                                
...      coalface playing Black: 842 - 854 - 1339  [0.498] 3035                                                                                                                
...      White vs Black: 1721 - 1729 - 2620  [0.499] 6070                                                                                                                      
Elo difference: -1.8 +/- 6.6, LOS: 29.3 %, DrawRatio: 43.2 % 
Will try longer TC as well when this finishes...
op12no2
Posts: 547
Joined: Tue Feb 04, 2014 12:25 pm
Location: Gower, Wales
Full name: Colin Jenkins

Re: Releasing Javascript engines as stand-alone executables

Post by op12no2 »

Idiot that I am, I accidently killed it but was good WRT the exe. Will start a longer TC test now.

Code: Select all

Score of coalface vs coalfacebin: 1920 - 1987 - 2962  [0.495] 6869                                                                                                             
...      coalface playing White: 971 - 1015 - 1449  [0.494] 3435                                                                                                               
...      coalface playing Black: 949 - 972 - 1513  [0.497] 3434                                                                                                                
...      White vs Black: 1943 - 1964 - 2962  [0.498] 6869                                                                                                                      
Elo difference: -3.4 +/- 6.2, LOS: 14.2 %, DrawRatio: 43.1 % 
op12no2
Posts: 547
Joined: Tue Feb 04, 2014 12:25 pm
Location: Gower, Wales
Full name: Colin Jenkins

Re: Releasing Javascript engines as stand-alone executables

Post by op12no2 »

60s + 0.6s - equal so far.

Code: Select all

Score of coalface vs coalfacebin: 690 - 697 - 1523  [0.499] 2910                            
...      coalface playing White: 361 - 341 - 753  [0.507] 1455                              
...      coalface playing Black: 329 - 356 - 770  [0.491] 1455                              
...      White vs Black: 717 - 670 - 1523  [0.508] 2910                                     
Elo difference: -0.8 +/- 8.7, LOS: 42.5 %, DrawRatio: 52.3 % 
op12no2
Posts: 547
Joined: Tue Feb 04, 2014 12:25 pm
Location: Gower, Wales
Full name: Colin Jenkins

Re: Releasing Javascript engines as stand-alone executables

Post by op12no2 »

Code: Select all

core of coalface vs coalfacebin: 1049 - 1084 - 2337  [0.496] 4470                                      
...      coalface playing White: 554 - 535 - 1146  [0.504] 2235                                         
...      coalface playing Black: 495 - 549 - 1191  [0.488] 2235                                         
...      White vs Black: 1103 - 1030 - 2337  [0.508] 4470                                               
Elo difference: -2.7 +/- 7.0, LOS: 22.4 %, DrawRatio: 52.3 %
Calling it a day - need the PC for something else. Seem to be the same. At worst the exe will lose by 4-5 ELO which i can live with.