Page 4 of 5

Re: JSUCI 1.0 - connect javascript chess engines to UCI

Posted: Mon Apr 07, 2014 12:19 am
by Edmund
op12no2 wrote:Thanks for the update. If only V8 workers could fire up sub-workers, there would be no problem.

I was wondering if the engine could listen on an event handler (like it would with browsers) without a worker, allowing the engine to fire off a worker, but jsUCI would have to poll for comms(?) and it's all a but ugly perhaps.
The worker commands onmessage and postmessage I personally emulated through programming the corresponding event handlers in C++. How I get it, workers don't exist in V8 and would have to be implemented through 3rd party plugins. Here is the response I got on my question on whether web workers were feasable: http://stackoverflow.com/questions/2277 ... ipt-engine

The same way how I programmed the event handlers one could also add a command for spawning workers, but this is obviously more complex than the commands obove.

Re: JSUCI 1.0 - connect javascript chess engines to UCI

Posted: Mon Apr 07, 2014 8:37 am
by op12no2
Ah I see - I think. I had assumed workers were part of the javascript EMCA spec. But googling, they seem to be a web thing not a JS thing - as you say; which makes everything more complicated...

Re: JSUCI 1.0 - connect javascript chess engines to UCI

Posted: Sat May 17, 2014 11:34 am
by op12no2
Hi Edmund,

node.js boasts non-blocking I/O so I'm going to have a fiddle with that as well. There are also third-party utils to convert into a single exe.

I am still currently using jsuci to test Lozza; it has been essential to allow me to test against other engines; thank you so much.

Re: JSUCI 1.0 - connect javascript chess engines to UCI

Posted: Mon May 19, 2014 9:58 am
by Edmund
op12no2 wrote:Hi Edmund,

node.js boasts non-blocking I/O so I'm going to have a fiddle with that as well. There are also third-party utils to convert into a single exe.

I am still currently using jsuci to test Lozza; it has been essential to allow me to test against other engines; thank you so much.
Hello Colin

Indeed, node.js might provide a solution. I didn't manage to set it up though. Do you think it can be used to create a similar interface such as JSUCI, with the difference of allowing for web workers?

Re: JSUCI 1.0 - connect javascript chess engines to UCI

Posted: Mon May 19, 2014 11:57 am
by op12no2
Hi Edmund,
Edmund wrote:Do you think it can be used to create a similar interface such as JSUCI, with the difference of allowing for web workers?
I think so. AIUI node.js can spawn child processes (the equiv of HTML5 web workers I guess), so while I have not tried it, it should be possible to have a root comms loop like this:-

process.stdin.setEncoding('utf8');

process.stdin.on('readable', function() {
var uciMessage = process.stdin.read();
if (uciMessage !== null) {
... handle UCI message
}
});

Which forks the engine from it, allowing other messages to arrive to control the forked processes. I guess SMP is ultimately possible too. The engine writes back to the UI with process.stdout.write().

I'll get it going single threaded - then add the fork...

Re: JSUCI 1.0 - connect javascript chess engines to UCI

Posted: Mon May 19, 2014 2:42 pm
by op12no2
I've got the single threaded version going with one anomaly. From the command line ("node lozza.js"), doing a "go depth 14" say, shows the increasing PVs etc in real time. When using a UI like Arena, that same output is not displayed until the javascript gets back to the message loop. Not really sure why it should be different between the two contexts. That doesn't happen using jsUCI...

Re: JSUCI 1.0 - connect javascript chess engines to UCI

Posted: Mon May 19, 2014 6:58 pm
by op12no2
I've given up with node.js :) - not the panacea I thought it was.

What if lastMessage was an exposed function rather than an exposed variable - would that maybe work? or are we back to the same problem?

Re: JSUCI 1.0 - connect javascript chess engines to UCI

Posted: Sat Oct 18, 2014 10:11 am
by op12no2
Hi Edmund,

jsUCI often crashes at around move 104. Possible buffer overflow?; at that point the UCI position is "position startpos" + 208*5 ish, which is > 1k. Having said that I looked at the code and could not see anything obvious (to me).

PS: I'm thinking a turning Lozza into a .exe by using the V8 C harness as a starting point but processing std in the C and forking a process with V8 and Lozza. That way the stop and ponder can be handled I think...

Re: JSUCI 1.0 - connect javascript chess engines to UCI

Posted: Sat Oct 18, 2014 4:17 pm
by Edmund
op12no2 wrote:Hi Edmund,

jsUCI often crashes at around move 104. Possible buffer overflow?; at that point the UCI position is "position startpos" + 208*5 ish, which is > 1k. Having said that I looked at the code and could not see anything obvious (to me).

PS: I'm thinking a turning Lozza into a .exe by using the V8 C harness as a starting point but processing std in the C and forking a process with V8 and Lozza. That way the stop and ponder can be handled I think...
Sorry for that bug. I just uploaded a new version with new executable (jsuci 1.2.rar) to the project website.

It was indeed a 1k string variable that I now changed to a 64k string.

Please let me know whether this solves the issue. I wish you all the best with your engine.

Re: JSUCI 1.0 - connect javascript chess engines to UCI

Posted: Sat Oct 18, 2014 4:35 pm
by op12no2
Edmund, you are a super-hero; thank you so much. I can't tell you useful it's been to be able to use jsUCI to evaluate Lozza against other engines in 200 game matches as she slowly develops; thanks again.

PS: There is a little web UI now:-

http://op12no2.me/toys/lozza/play.htm