Arasan 21.1

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

Moderators: hgm, Rebel, chrisw

Dann Corbit
Posts: 12541
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Arasan 21.1

Post by Dann Corbit »

I have found that there are lots of chess engines that do not work properly under Windows with UCI or Xboard.
It is almost always due to buffering.

I add about 4 lines of code to stop buffering and then all is well.
The Windows default (full buffering) is different than the Linux default (line buffering) so people who write their engines on Linux almost never put in code to do that.

Stockfish and Cfish are examples of programs that need this change (and many others as well, I just mention them because I have to change the code so often). Now, most of the time it works fine as is. But sometimes it will get decoupled. When that happens you will see crazy things in {for instance} Arena output, such as analysis output getting associated with the wrong position.

For instance, here is how I start off main() in Cfish:

Code: Select all

int main(int argc, char **argv)
{

    if( setvbuf( stdin, NULL, _IONBF, 0 ) != 0 )
        printf( "Incorrect type or size of buffer for stdin\n" );

    if( setvbuf( stdout, NULL, _IONBF, 0 ) != 0 )
        printf( "Incorrect type or size of buffer for stdout\n" );

    if( setvbuf( stderr, NULL, _IONBF, 0 ) != 0 )
        printf( "Incorrect type or size of buffer for stderr\n" );

    print_engine_info(0);

    int i = _flushall();
Line buffering would work as well as no buffering, but I do long time analysis so that there is no harm in using no buffering in my case.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: Arasan 21.1

Post by MikeB »

Gabor Szots wrote: Wed Oct 03, 2018 8:04 pm Thank you Jon. It's good to see you never run out of ideas.

May I ask you what value you recommend for syzygy probe depth if I use the full 6-man set and have them on SSD?

On an SSD drive , a setting of "1" should be fine. Assuming the higher setting delays the probing which is usually the case. If you notice too much of a decrease in nps, increase the setting.
Image
User avatar
Zerbinati
Posts: 122
Joined: Mon Aug 18, 2014 7:12 pm
Location: Trento (Italy)

Re: Arasan 21.1

Post by Zerbinati »

Dann Corbit wrote: Fri Oct 05, 2018 12:21 am I have found that there are lots of chess engines that do not work properly under Windows with UCI or Xboard.
It is almost always due to buffering.

I add about 4 lines of code to stop buffering and then all is well.
The Windows default (full buffering) is different than the Linux default (line buffering) so people who write their engines on Linux almost never put in code to do that.

Stockfish and Cfish are examples of programs that need this change (and many others as well, I just mention them because I have to change the code so often). Now, most of the time it works fine as is. But sometimes it will get decoupled. When that happens you will see crazy things in {for instance} Arena output, such as analysis output getting associated with the wrong position.
Line buffering would work as well as no buffering, but I do long time analysis so that there is no harm in using no buffering in my case.
Very helpful Dan thank you!
I will implement the code in SugaR.
Gabor Szots
Posts: 1364
Joined: Sat Jul 21, 2018 7:43 am
Location: Szentendre, Hungary
Full name: Gabor Szots

Re: Arasan 21.1

Post by Gabor Szots »

MikeB wrote: Fri Oct 05, 2018 4:36 am
Gabor Szots wrote: Wed Oct 03, 2018 8:04 pm Thank you Jon. It's good to see you never run out of ideas.

May I ask you what value you recommend for syzygy probe depth if I use the full 6-man set and have them on SSD?

On an SSD drive , a setting of "1" should be fine. Assuming the higher setting delays the probing which is usually the case. If you notice too much of a decrease in nps, increase the setting.
Thanks Mike.
Gabor Szots
CCRL testing group
jdart
Posts: 4367
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Arasan 21.1

Post by jdart »

Dann Corbit wrote: Fri Oct 05, 2018 12:21 am I have found that there are lots of chess engines that do not work properly under Windows with UCI or Xboard.
It is almost always due to buffering.
Is this an issue with Arasan? Arasan is C++ so it does this on startup:

Code: Select all

    setbuf(stdin,NULL);
    setbuf(stdout, NULL);
    std::cout.rdbuf()->pubsetbuf(NULL, 0);
    std::cin.rdbuf()->pubsetbuf(NULL, 0);
This hasn't changed for many versions.

--Jon
pferd
Posts: 134
Joined: Thu Jul 24, 2014 2:49 pm

Re: Arasan 21.1

Post by pferd »

I have a small problem when I use arasan manually with the Linux command line. I have to type 'quit' twice in order to close it.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Arasan 21.1

Post by Sven »

jdart wrote: Sun Oct 07, 2018 2:50 pm
Dann Corbit wrote: Fri Oct 05, 2018 12:21 am I have found that there are lots of chess engines that do not work properly under Windows with UCI or Xboard.
It is almost always due to buffering.
Is this an issue with Arasan? Arasan is C++ so it does this on startup:

Code: Select all

    setbuf(stdin,NULL);
    setbuf(stdout, NULL);
    std::cout.rdbuf()->pubsetbuf(NULL, 0);
    std::cin.rdbuf()->pubsetbuf(NULL, 0);
This hasn't changed for many versions.

--Jon
When using the second two calls (...->pubsetbuf()), the first two (setbuf(...)) are redundant IMO.

Setting standard input to unbuffered is crucial for chess engines. For standard output I restrict that to everything that is relevant for basic communication to the GUI while normal output during search (like PVs, info lines etc.) is excluded. The "basic communication" kind of output therefore is always followed by a "flush" call. In my engine this helps to reduce the penalty of frequent unbuffered search output in ultra-fast games.
Sven Schüle (engine author: Jumbo, KnockOut, Surprise)
Dann Corbit
Posts: 12541
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Arasan 21.1

Post by Dann Corbit »

jdart wrote: Sun Oct 07, 2018 2:50 pm
Dann Corbit wrote: Fri Oct 05, 2018 12:21 am I have found that there are lots of chess engines that do not work properly under Windows with UCI or Xboard.
It is almost always due to buffering.
Is this an issue with Arasan? Arasan is C++ so it does this on startup:

Code: Select all

    setbuf(stdin,NULL);
    setbuf(stdout, NULL);
    std::cout.rdbuf()->pubsetbuf(NULL, 0);
    std::cin.rdbuf()->pubsetbuf(NULL, 0);
This hasn't changed for many versions.

--Jon
No, Arasan behaves correctly.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
Dann Corbit
Posts: 12541
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Arasan 21.1

Post by Dann Corbit »

Zerbinati wrote: Sun Oct 07, 2018 1:17 pm
Dann Corbit wrote: Fri Oct 05, 2018 12:21 am I have found that there are lots of chess engines that do not work properly under Windows with UCI or Xboard.
It is almost always due to buffering.

I add about 4 lines of code to stop buffering and then all is well.
The Windows default (full buffering) is different than the Linux default (line buffering) so people who write their engines on Linux almost never put in code to do that.

Stockfish and Cfish are examples of programs that need this change (and many others as well, I just mention them because I have to change the code so often). Now, most of the time it works fine as is. But sometimes it will get decoupled. When that happens you will see crazy things in {for instance} Arena output, such as analysis output getting associated with the wrong position.
Line buffering would work as well as no buffering, but I do long time analysis so that there is no harm in using no buffering in my case.
Very helpful Dan thank you!
I will implement the code in SugaR.
For C++ programs, I also fiddle with the C++ I/O operations like this:

Code: Select all

int main(int argc, char* argv[]) {
    setvbuf( stdin, NULL, _IONBF, 0 );
    setvbuf( stdout, NULL, _IONBF, 0 );
    std::cout.setf( std::ios::unitbuf ); // For C++
    std::cin.setf( std::ios::unitbuf ); // For C++
    std::cout << engine_info() << std::endl;
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
User avatar
Zerbinati
Posts: 122
Joined: Mon Aug 18, 2014 7:12 pm
Location: Trento (Italy)

Re: Arasan 21.1

Post by Zerbinati »

Dann Corbit wrote: Mon Oct 08, 2018 9:06 pm For C++ programs, I also fiddle with the C++ I/O operations like this:

Code: Select all

int main(int argc, char* argv[]) {
    setvbuf( stdin, NULL, _IONBF, 0 );
    setvbuf( stdout, NULL, _IONBF, 0 );
    std::cout.setf( std::ios::unitbuf ); // For C++
    std::cin.setf( std::ios::unitbuf ); // For C++
    std::cout << engine_info() << std::endl;
Thx Dann!