Setup a javascript engine in a GUI

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

Moderator: Ras

Ferdy
Posts: 4845
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Setup a javascript engine in a GUI

Post by Ferdy »

Guenther wrote: Thu Dec 24, 2020 1:07 pm
hgm wrote: Thu Dec 24, 2020 12:41 pm
Ferdy wrote: Thu Dec 24, 2020 10:54 amThis is what I tried so far without success.

wukong.js and uci.js are in F:\Tmp folder.
You should let WinBoard worry about the quoting, and you should not put any command-line arguments in the text entry meant for the executable. The latter should go into the 'command-line parameters' entry. The .exe entry is only for the executable; if there are any spaces in there, WinBoard will assume it is an executable name with spaces in it. Writing quotes in there yourself will just confuse WinBoard; when you use the 'browse' button to point out the .exe it wouldn't provide any quotes either.

So the .exe field should just contain

C:/Program Files/blabla/nodes.exe

and the command-line parameter should be

uci.js

This should result in a line in the engine list

"nodes.exe uci.js" -fd "C:/Program Files/blabla"

If you don't want the engine to run in the nodes.exe folder (e.g. because it cannot find its book files from there), you should explicitly provide the directory (there also is a browse button for that), and WinBoard will use that as -fd argument, and refrain from spliiting off the path from the engine command. In that case it should produce a line in the engine list like

'"C:/Program Files/blabla/nodes.exe" uci.js' -fd "whatever"
In WB now w/o Polyglot - Wukong10JS-64 is just a renamed node
The debug is not very helpful - it doesn't work, neither in CuteChess nor from cmd with Polyglot (for logging) nor with WB so far
(seems a problem with node - crashing/not responsive)

Code: Select all

recognized 'normal' (-1) as variant normal
recognized 'normal' (-1) as variant normal
shuffleOpenings = 0
Version: WinBoard 4.9.1 + Wukong10JS-64
Reset(1, 0) from gameMode 0
recognized 'normal' (-1) as variant normal
GameEnds(0, (null), 2)
shuffleOpenings = 0
StartChildProcess (dir="") UCI2WB Wukong10JS-64 uci.js C:\Engines\UCIJS\Wukong_10JS-64
nice engine proc to 10
1200 >first : xboard
protover 2
1230 <first : Wukong10JS-64: No error
Terminating process 4176, result=0
GameEnds(29, xboard exit, 2)
EDIT:
BTW can we change the title of the original header to Wukong JS instead of general JS engines ?
Other JS engines never had these problems and the current title will confuse other users
There is a bug in uci.js, it does not send uciok. I will try to setup it up again in winboard, it already worked in cutechess GUI.
Ferdy
Posts: 4845
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Setup a javascript engine in a GUI

Post by Ferdy »

hgm wrote: Thu Dec 24, 2020 12:41 pm
Ferdy wrote: Thu Dec 24, 2020 10:54 amThis is what I tried so far without success.

wukong.js and uci.js are in F:\Tmp folder.
You should let WinBoard worry about the quoting, and you should not put any command-line arguments in the text entry meant for the executable. The latter should go into the 'command-line parameters' entry. The .exe entry is only for the executable; if there are any spaces in there, WinBoard will assume it is an executable name with spaces in it. Writing quotes in there yourself will just confuse WinBoard; when you use the 'browse' button to point out the .exe it wouldn't provide any quotes either.

So the .exe field should just contain

C:/Program Files/blabla/nodes.exe

and the command-line parameter should be

uci.js

This should result in a line in the engine list

"nodes.exe uci.js" -fd "C:/Program Files/blabla"

If you don't want the engine to run in the nodes.exe folder (e.g. because it cannot find its book files from there), you should explicitly provide the directory (there also is a browse button for that), and WinBoard will use that as -fd argument, and refrain from spliiting off the path from the engine command. In that case it should produce a line in the engine list like

'"C:/Program Files/blabla/nodes.exe" uci.js' -fd "whatever"
Tried it again and still it did not work.

Setup
Image


Error message

Image


Debug

Code: Select all

StartChildProcess (dir=".") UCI2WB debug -nice 10 -kill 1 -c ""C:\Program Files\nodejs\node.exe" uci.js" "F:\Tmp"
nice engine proc to 10
73060 >first : xboard
protover 2
73064 <first : C:\Program: No error
Terminating process 10780, result=0
GameEnds(30, xboard exit, 2)
Why it sends xboard? Note UCI was already pre-selected.

uci.js used has a fixed for not sending uciok which can be found here.
tmokonen
Posts: 1344
Joined: Sun Mar 12, 2006 6:46 pm
Location: Kelowna
Full name: Tony Mokonen

Re: Setup a javascript engine in a GUI

Post by tmokonen »

Ferdy wrote: Fri Dec 25, 2020 4:28 am There is a bug in uci.js, the engine does not send uciok as last message after receiving uci command.

Fixing it and the following would work.

Image
Ah OK, thanks for letting me know, Ferdy.
User avatar
hgm
Posts: 28322
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Setup a javascript engine in a GUI

Post by hgm »

Ferdy wrote: Fri Dec 25, 2020 5:24 amTried it again and still it did not work.
OK, I see what te problem is. Because the engine is UCI, and the adapter command is defined with quotes around the engine name, there is a duplicate set of double quoting: around the engine pathname (node.exe) as well as around the this name + the argument. When Windows interprets the resulting command for launching the adapter (UCI2WB ""executable" argument") it of course parses this differently, not like they are nested.

I guess WinBoard should quote space-containing executable names with single quotes when the engine is UCI, to prepare for the total engine command being enclosed in another set of double quotes when it gets passed to the adapter. But then the adapter would see as its 'engine' argument the string

'executable' argument

and I am not sure if passing that to the Windows CreateProcess function would understand single quotes. So I guess I would have to add some code in UCI2WB to replace single quotes by double quotes before launching the engine.
User avatar
maksimKorzh
Posts: 775
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Setup a javascript engine in a GUI

Post by maksimKorzh »

Ferdy wrote: Fri Dec 25, 2020 4:28 am
tmokonen wrote: Thu Dec 24, 2020 8:56 am In the CuteChess GUI, I put the program name, with full path, and command line parameters all together in the Command: section of the Configure Engine screen. You might need quotes around the program path or javascript file path if there are spaces. It's the same format as you would use from a command prompt. For example:

C:\Games\NoSpaces\NoQuotesRequired\node.exe C:\jsengines\coolengine.js

"C:\path with spaces\node.exe" C:\jsengines\wukong.js

C:\Games\NoSpaces\NoQuotesRequired\node.exe "C:\jsengines\This time I have spaces.js"
There is a bug in uci.js, the engine does not send uciok as last message after receiving uci command.

Fixing it and the following would work.

Image
uciok has been added in a recent version.
can you run it via nodejs in command line?
let me know if now it works.
User avatar
maksimKorzh
Posts: 775
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Setup a javascript engine in a GUI

Post by maksimKorzh »

For the future: feel free to open issues on github so the author knows about it) I saw one on uciok - not sure if it's yours. If I knew it's so critical I would fix it faster. I've noticed current thread only today - it would happen earlier if you ping me in release thread.
Ferdy
Posts: 4845
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Setup a javascript engine in a GUI

Post by Ferdy »

maksimKorzh wrote: Sat Dec 26, 2020 8:50 am For the future: feel free to open issues on github so the author knows about it) I saw one on uciok - not sure if it's yours.
Yes it was me.
Ferdy
Posts: 4845
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Setup a javascript engine in a GUI

Post by Ferdy »

maksimKorzh wrote: Sat Dec 26, 2020 8:43 am
Ferdy wrote: Fri Dec 25, 2020 4:28 am
tmokonen wrote: Thu Dec 24, 2020 8:56 am In the CuteChess GUI, I put the program name, with full path, and command line parameters all together in the Command: section of the Configure Engine screen. You might need quotes around the program path or javascript file path if there are spaces. It's the same format as you would use from a command prompt. For example:

C:\Games\NoSpaces\NoQuotesRequired\node.exe C:\jsengines\coolengine.js

"C:\path with spaces\node.exe" C:\jsengines\wukong.js

C:\Games\NoSpaces\NoQuotesRequired\node.exe "C:\jsengines\This time I have spaces.js"
There is a bug in uci.js, the engine does not send uciok as last message after receiving uci command.

Fixing it and the following would work.

Image
uciok has been added in a recent version.
can you run it via nodejs in command line?
let me know if now it works.
It worked.
User avatar
maksimKorzh
Posts: 775
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Setup a javascript engine in a GUI

Post by maksimKorzh »

Ferdy wrote: Sat Dec 26, 2020 9:17 am
maksimKorzh wrote: Sat Dec 26, 2020 8:50 am For the future: feel free to open issues on github so the author knows about it) I saw one on uciok - not sure if it's yours.
Yes it was me.
Thanks for giving nice hint on timing on github issues.
Will fix soon.
I just need to fight some search bugs for now.