UCCI2WB

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: UCCI2WB

Post by hgm »

The adapter could of course translate any of this to the omnipotent WB protocol. But nothing in the quoted text by Evert refers to WB protocol in any way, nor was any of it influenced by WB protocol, or has WinBoard played any role in its development. The only connection with WB protocol is that it also is a protocol for communication between a GUI and an AI pluging for a board game.

WinBoard tries to stay away from this mess as far as possible. This is why we use adapters to clean things up, so that WinBoard only has to deal with a neat and cwell-maintained protocol.
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: UCCI2WB

Post by JoshPettus »

Well he did quote you ;), just Evert's wall of text took up most of the page. Either way, I have no idea what he means.

It's nice that that CECP only has one current developer as part of a dedicated project, where as UCI has been very much a free for all molded to the needs of anyone who wanted to use it.
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: UCCI2WB

Post by JoshPettus »

Anyway how do I know UCI2WB is indeed sending quit before it does in UCCI mode?

[EDIT]

Code: Select all

52178 <first &#58; 
GameEnds&#40;29, xboard exit, 2&#41;
Interrupting first
52928 >first &#58; result * &#123;xboard exit&#125;
53988 >first &#58; quit
weird, looks like it works..
perhaps you do have to say "bye" first?
Last edited by JoshPettus on Wed Oct 29, 2014 6:29 pm, edited 1 time in total.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: UCCI2WB

Post by hgm »

You could add a printf statement in the last line of GUI2Engine(), like:

Code: Select all

	else if&#40;!strcmp&#40;command, "quit"))   fprintf&#40;toE, "quit\n"), fflush&#40;toE&#41;, printf&#40;"# quit sent\n"), exit&#40;0&#41;;
This should show up in the XBoard debug file. (At least, I hope that XBoard still keeps reading from the pipe to the engine until it breaks because the engine process exits.)
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: UCCI2WB

Post by JoshPettus »

Code: Select all

	GUI2Engine&#40;);
   else if&#40;!strcmp&#40;command, "quit"))   fprintf&#40;toE, "quit\n"), fflush&#40;toE&#41;, printf&#40;"# quit sent\n"), exit&#40;0&#41;;
&#125;
Correct?

I get

Code: Select all

./UCI2WB.c&#58;612&#58;4&#58; error&#58; expected expression
   else if&#40;!strcmp&#40;command, "quit"))   fprintf&#40;toE, "quit\n"), fflush&#40;to...
   ^
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: UCCI2WB

Post by hgm »

No, it should replace a very similar line (line 495 in my source).
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: UCCI2WB

Post by JoshPettus »

Sorry was confused by the second GUI2Engine()

Yah still the same in xboard.debug

Code: Select all

27108 <first &#58; 
GameEnds&#40;29, xboard exit, 2&#41;
Interrupting first
28495 >first &#58; result * &#123;xboard exit&#125;
29555 >first &#58; quit
I don't see "quit sent"
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: UCCI2WB

Post by hgm »

I guess XBoard just stops listening to the 'engine' as soon as it sends 'quit'.

Then the only thing to make sure is to let UCI2WB create its own debug file.

Like just abuve Engine2GUI declare a FILE, and open it in Engine2GUI():

Code: Select all

FILE *dbg;

void *
Engine2GUI&#40;)
&#123;
    char line&#91;1024&#93;, command&#91;256&#93;;

    dbg = fopen&#40;"uci.debug", "w");
(you might want to use some suitable pathname in stead of just uci.debug).

You can then in GUI2engine(), just before the test for "new", write to the file what command was received:

Code: Select all

        fprintf&#40;dbg, "command read&#58; %s\n", line&#41;;

        if&#40;!strcmp&#40;command, "new")) &#123;
In the "quit" line we altered before we now write

Code: Select all

        else if&#40;!strcmp&#40;command, "quit"))   fprintf&#40;toE, "quit\n"), fflush&#40;toE&#41;, fprintf&#40;dbg, "quit sent\n"), fflush&#40;dbg&#41;, exit&#40;0&#41;;
That should then make a log of everything UCI2WB received.
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: UCCI2WB

Post by JoshPettus »

Grr it generates the file at /Users/myself/UCI.debug but then quits in xboard. So nothing is there.

I tried opening it up and doing it manually ./UCI2WB debug -x ./dir/eleeye and it seems to work fine outputting my sent commands and saying quit sent
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: UCCI2WB

Post by hgm »

Hmm, perhaps it was a bad idea to open the file in Engine2GUI, but print on it from GUI2Engine. As they are executed by different threads, it could write before the file was opened (which probably causes the crash).

Move the 'fopen' line from the top of Engine2GUI to the top of GUI2Engine (just before the "while(1) line)", and try again.