Handling UCI protocol and Stockfish / Glaurung behavior

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

Moderators: hgm, Rebel, chrisw

UncombedCoconut
Posts: 319
Joined: Fri Dec 18, 2009 11:40 am
Location: Naperville, IL

Re: Handling UCI protocol and Stockfish / Glaurung behavior

Post by UncombedCoconut »

Eelco de Groot wrote:Had not much luck with the patch utility, I probably best stick to trying to insert code manually. That forces me to look at the new code better and that would not be wasted time anyway. I tried to install Gnu's patch but strangely in the Start menu I can find the documentation but not the executable. I can just place the utility in the file with the sources but I figure then I still have to run it from the commandline in a DOS box, and the command line can't seem to find my E: partition where I would like to run the patch utility. I can do a DIR E: that works but not CD E: Maybe it is some sort of security issue in Windows XP or I forgot the proper commands. At that point I stopped, it can wait till later.

Thanks!
Eelco
I haven't used DOS in a while, but you could try...

Code: Select all

E:
cd \path\to\stockfish-1.62
patch -p0 < patchfile
(The path should be the path to the folder which contains the "src" folder, and should omit the "E:" part.)
User avatar
Eelco de Groot
Posts: 4563
Joined: Sun Mar 12, 2006 2:40 am
Full name:   

Re: Handling UCI protocol and Stockfish / Glaurung behavior

Post by Eelco de Groot »

UncombedCoconut wrote:
Eelco de Groot wrote:Had not much luck with the patch utility, I probably best stick to trying to insert code manually. That forces me to look at the new code better and that would not be wasted time anyway. I tried to install Gnu's patch but strangely in the Start menu I can find the documentation but not the executable. I can just place the utility in the file with the sources but I figure then I still have to run it from the commandline in a DOS box, and the command line can't seem to find my E: partition where I would like to run the patch utility. I can do a DIR E: that works but not CD E: Maybe it is some sort of security issue in Windows XP or I forgot the proper commands. At that point I stopped, it can wait till later.

Thanks!
Eelco
I haven't used DOS in a while, but you could try...

Code: Select all

E&#58;
cd \path\to\stockfish-1.62
patch -p0 < patchfile
(The path should be the path to the folder which contains the "src" folder, and should omit the "E:" part.)
Thanks Justin! I'll try later. A few weeks ago, I found I had bought years ago in well known second hand bookstore "De Slegte" a mighty tome called "Working with MS-Dos 6.2" It was still in its brown paper wrappings. Finally opened it and was very pleased! 900 pages of very valuable lessons and documentation. Durable plastic lined cover, it is obviously meant for heavy use. You have to keep up with the times I figured when I bought it. But then I forgot all about it. Should come in handy in case I want to switch to Linux :)

Eelco
Debugging is twice as hard as writing the code in the first
place. Therefore, if you write the code as cleverly as possible, you
are, by definition, not smart enough to debug it.
-- Brian W. Kernighan
pgeorges

Re: Handling UCI protocol and Stockfish / Glaurung behavior

Post by pgeorges »

Hi Marco,

The patch solves part of the problem but if you simply launch Stockfish from command line and enter

Code: Select all

uci
position fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
go infinite
=> SF outputs info, using 2 threads at 100% (in my case, because I have 2 cores).

Then enter "stop" and no "bestmove" is printed (there is no output at all). Note that SF uses no longer 2 threads at 100% but only 1 at 100% while you wait for a "bestmove".

Pascal Georges
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Handling UCI protocol and Stockfish / Glaurung behavior

Post by mcostalba »

pgeorges wrote: Then enter "stop" and no "bestmove" is printed
Yes is true.

It means you are the first (only?) to have applied the patch. I was waiting to see _when_ this issue would have been reported. ;-)

You need the following above the previously posted patch:

Code: Select all

638f3d31cc9a61ce3df2b685fef96f15e0afb940
 src/search.cpp |    2 +-
 1 files changed, 1 insertions&#40;+), 1 deletions&#40;-)

diff --git a/src/search.cpp b/src/search.cpp
index 3dbcb52..ea9240e 100644
--- a/src/search.cpp
+++ b/src/search.cpp
@@ -844,7 +844,7 @@ namespace &#123;
 
     // If we are pondering or in infinite search, we shouldn't print the
     // best move before we are told to do so.
-    if &#40;PonderSearch || InfiniteSearch&#41;
+    if (!AbortSearch && &#40;PonderSearch || InfiniteSearch&#41;)
         wait_for_stop_or_ponderhit&#40;);
     else
         // Print final search statistics
sockmonkey
Posts: 588
Joined: Sun Nov 23, 2008 11:16 pm
Location: Berlin, Germany

Re: Handling UCI protocol and Stockfish / Glaurung behavior

Post by sockmonkey »

Neither the Mac nor the JA distribution seem to accept the patch:

Code: Select all

> patch -p1 < p1.txt 
patching file src/benchmark.cpp
Hunk #1 FAILED at 155.
1 out of 1 hunk FAILED -- saving rejects to file src/benchmark.cpp.rej
patching file src/search.cpp
Hunk #1 FAILED at 227.
Hunk #2 FAILED at 369.
Hunk #3 FAILED at 387.
Hunk #4 FAILED at 467.
Hunk #5 FAILED at 780.
Hunk #6 FAILED at 833.
Hunk #7 FAILED at 2649.
Hunk #8 FAILED at 2664.
8 out of 8 hunks FAILED -- saving rejects to file src/search.cpp.rej
Is there a preferred distro I should be patching against? The line numbers don't look right to me in the source I have, but maybe I'm overlooking something.

Thanks
Jeremy
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Handling UCI protocol and Stockfish / Glaurung behavior

Post by mcostalba »

sockmonkey wrote:Neither the Mac nor the JA distribution seem to accept the patch:

Code: Select all

> patch -p1 < p1.txt 
patching file src/benchmark.cpp
Hunk #1 FAILED at 155.
1 out of 1 hunk FAILED -- saving rejects to file src/benchmark.cpp.rej
patching file src/search.cpp
Hunk #1 FAILED at 227.
Hunk #2 FAILED at 369.
Hunk #3 FAILED at 387.
Hunk #4 FAILED at 467.
Hunk #5 FAILED at 780.
Hunk #6 FAILED at 833.
Hunk #7 FAILED at 2649.
Hunk #8 FAILED at 2664.
8 out of 8 hunks FAILED -- saving rejects to file src/search.cpp.rej
Is there a preferred distro I should be patching against? The line numbers don't look right to me in the source I have, but maybe I'm overlooking something.

Thanks
Jeremy
Could you post the rejected part in src/benchmark.cpp.rej ?

Should be small enough to allow a post.
pgeorges

Re: Handling UCI protocol and Stockfish / Glaurung behavior

Post by pgeorges »

Marco, I managed to apply both patches to Stockfish 1.6.2 but still have problems under Scid : half the time when moving in a game SF does not work as expected. Maybe some code review regarding UCI handling would fix things.
It is possible that the problem comes from Scid, but it usually works well with UCI engines.

Pascal Georges
sockmonkey
Posts: 588
Joined: Sun Nov 23, 2008 11:16 pm
Location: Berlin, Germany

Re: Handling UCI protocol and Stockfish / Glaurung behavior

Post by sockmonkey »

mcostalba wrote:
sockmonkey wrote:Neither the Mac nor the JA distribution seem to accept the patch:

Code: Select all

> patch -p1 < p1.txt 
patching file src/benchmark.cpp
Hunk #1 FAILED at 155.
1 out of 1 hunk FAILED -- saving rejects to file src/benchmark.cpp.rej
patching file src/search.cpp
Hunk #1 FAILED at 227.
Hunk #2 FAILED at 369.
Hunk #3 FAILED at 387.
Hunk #4 FAILED at 467.
Hunk #5 FAILED at 780.
Hunk #6 FAILED at 833.
Hunk #7 FAILED at 2649.
Hunk #8 FAILED at 2664.
8 out of 8 hunks FAILED -- saving rejects to file src/search.cpp.rej
Is there a preferred distro I should be patching against? The line numbers don't look right to me in the source I have, but maybe I'm overlooking something.

Thanks
Jeremy
Could you post the rejected part in src/benchmark.cpp.rej ?

Should be small enough to allow a post.

Code: Select all

***************
*** 155,161 ****
        cerr << "\nBench position&#58; " << cnt << '/' << positions.size&#40;) << endl << endl; 
        if &#40;limitType == "perft") 
            totalNodes += perft&#40;pos, maxDepth * OnePly&#41;; 
-       else if (!think&#40;pos, true, false, 0, dummy, dummy, 0, maxDepth, maxNodes, secsPerPos, moves&#41;) 
            break; 
        totalNodes += nodes_searched&#40;); 
    &#125; 
--- 155,161 ----
        cerr << "\nBench position&#58; " << cnt << '/' << positions.size&#40;) << endl << endl; 
        if &#40;limitType == "perft") 
            totalNodes += perft&#40;pos, maxDepth * OnePly&#41;; 
+       else if (!think&#40;pos, false, false, 0, dummy, dummy, 0, maxDepth, maxNodes, secsPerPos, moves&#41;) 
            break; 
        totalNodes += nodes_searched&#40;); 
    &#125; 
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Handling UCI protocol and Stockfish / Glaurung behavior

Post by mcostalba »

pgeorges wrote:Marco, I managed to apply both patches to Stockfish 1.6.2 but still have problems under Scid : half the time when moving in a game SF does not work as expected. Maybe some code review regarding UCI handling would fix things.
It is possible that the problem comes from Scid, but it usually works well with UCI engines.

Pascal Georges
hmmmm, have you applied this ?

http://www.talkchess.com/forum/viewtopi ... 43&t=31443
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Handling UCI protocol and Stockfish / Glaurung behavior

Post by mcostalba »

sockmonkey wrote:

Code: Select all

***************
*** 155,161 ****
        cerr << "\nBench position&#58; " << cnt << '/' << positions.size&#40;) << endl << endl; 
        if &#40;limitType == "perft") 
            totalNodes += perft&#40;pos, maxDepth * OnePly&#41;; 
-       else if (!think&#40;pos, true, false, 0, dummy, dummy, 0, maxDepth, maxNodes, secsPerPos, moves&#41;) 
            break; 
        totalNodes += nodes_searched&#40;); 
    &#125; 
--- 155,161 ----
        cerr << "\nBench position&#58; " << cnt << '/' << positions.size&#40;) << endl << endl; 
        if &#40;limitType == "perft") 
            totalNodes += perft&#40;pos, maxDepth * OnePly&#41;; 
+       else if (!think&#40;pos, false, false, 0, dummy, dummy, 0, maxDepth, maxNodes, secsPerPos, moves&#41;) 
            break; 
        totalNodes += nodes_searched&#40;); 
    &#125; 
It seems correct to me. Perhaps is the patch file, try to save the file with Linux (/n) line endings and not Windows (/cr/lf) and then apply again using -l or --ignore-whitespace option.