[Solved] My UCI only works if called directly

Programming Topics (Computer Chess) and technical aspects as test techniques, book building, program tuning etc

Moderator: Andres Valverde

[Solved] My UCI only works if called directly

Postby purefan » 08 Jul 2018, 20:38

Hello!

I've come up with a bridge, its a really simple program that connects to a real UCI engine. If I call my program from the console it takes input through stdin and I can speak UCI to it, it then relays the commands to the real UCI engine and outputs to stdout whatever the UCI engine says. I have tried to load my program (lets call it fakeUCI) into Arena and Scid and it just doesn't work, I added some logging and am certain that fakeUCI is not being loaded, but have no clue why since when I run it myself it does work.

I know this is pretty vague but maybe someone has run into something like this and can shed some light?

Thanks!
Last edited by purefan on 03 Aug 2018, 08:40, edited 1 time in total.
purefan
 
Posts: 5
Joined: 08 Jul 2018, 10:21

Re: My UCI only works if called directly

Postby H.G.Muller » 10 Jul 2018, 02:30

Hard to say, when you don't even mention if this is under Windows, Linux or Mac. The most common reason why things work differently under Windows when run from the console or from a GUI (i.e. through a pipe) is that they use the wrong call when peeking for input (which in Windows needs to be different for the two cases). Best approach is to debug by splattering the entire program with print statements to the log file (and be sure to flush them), so you can be sure of exactly what it does (and thus of what it does wrong).
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: My UCI only works if called directly

Postby purefan » 21 Jul 2018, 15:14

Hi Muller,

I've been trying to debug this even further without any success. Im working under linux and adding logs didn't help, the very first instruction is "write to this log file", if I run my program directly from terminal the file does get populated fine, if I load it on Scid I only get the error message (within Scid) and the file does not get the line appended.

I downloaded Scid and found the error phrase, it's in this block of code:
Code: Select all
        if { $exit_status != 0 } {
            logEngineNote $n {Engine terminated with exit code $exit_status: "\"$standard_error\""}
            tk_messageBox -type ok -icon info -parent . -title "Scid" \
                          -message "The analysis engine terminated with exit code $exit_status: \"$standard_error\""
        } else {
            logEngineNote $n {Engine terminated without exit code: "\"$standard_error\""}
            tk_messageBox -type ok -icon info -parent . -title "Scid" \
                          -message "The analysis engine terminated without exit code: \"$standard_error\""
        }


(Theres a similar string but the other one has a typo exit != exist)
This is in tcl/tools/analysis.tcl:2304

I'm afraid not experienced enough to debug this further within scid (to figure out why is my binary failing to load)
purefan
 
Posts: 5
Joined: 08 Jul 2018, 10:21

Re: My UCI only works if called directly

Postby purefan » 21 Jul 2018, 17:54

In another try I loaded my program into Arena for linux and it does trigger the first line of debugging (it does get appended to my log file), nothing further after that but the behavior is at least different
purefan
 
Posts: 5
Joined: 08 Jul 2018, 10:21

Re: My UCI only works if called directly

Postby purefan » 21 Jul 2018, 18:30

And a bit more progress with Arena for linux, I was able to debug (by appending to a file) that all the declarations seem ok, I suspect the problem is when reading from stdin because that event doesn't fire (or doesn't log at least)
purefan
 
Posts: 5
Joined: 08 Jul 2018, 10:21

Re: My UCI only works if called directly

Postby H.G.Muller » 02 Aug 2018, 19:13

Are you flushing the debug output every time you print some? If it would get buffered you would not see it.
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: My UCI only works if called directly

Postby purefan » 03 Aug 2018, 08:39

Thanks for the follow up H.G.Muller

I came to the conclusion that it was a compiler error, the websockets libraries behave different when compiled, I switched to long polling and it is working now, I have no clue yet why it worked better in Arena than in Scid but it seems to be working now, it even worked on chessbase so I guess its safe to close this thread.

Thanks again!
purefan
 
Posts: 5
Joined: 08 Jul 2018, 10:21


Return to Programming and Technical Discussions

Who is online

Users browsing this forum: No registered users and 6 guests