A logging facility

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: A logging facility

Post by hgm »

Why let an engine keep a log when the GUI can do it for you?

When you run a UCI engine under UCI2WB, the engine options presented to you in the Engine Settings dialog are augmented with an option "UCI2WB debug output". You can toggle this option any time you like, and it controls whether everything the engine outputs is sent to the GUI as comment, so it will appear in the GUI log ('winboard.debug').

No need to modify the UCI engine in any way...
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: A logging facility

Post by Daniel Shawul »

Agreed. Some more reasons why you may want to have a custom printf :

-different outputs to gui and log file. Some protocols will not work if you print everything to the gui (winboard needs # for comments f.i, others may simply break down)
-stylized printing with headers [processor 0] or [time 3434] , coloring as you mentioned, or simply skipping some prints for a better formatted output etc..
-printing to a socket to another process or a remote machine following a certain protocol as in the case of ICS etc..
-thread safe printing

This can all be wrapped in a cutstom stream class that can be passed around if that simplifies the design of the program. I have even seen information exchange between processors to do parallel processing through an overloaded ">>" operator. Took me some time to figure that out... For chess, it is probably wise to think about this carefully if you are designing a GUI IMO.
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: A logging facility

Post by Daniel Shawul »

Hey guy in the milk way :) You forgot to mention "Java guys bashing C++", "C# guys bashing C++", "PHP guys bashing C++", "Somebody's mom bashing C++". Seriously though sometimes C++ could be a pain specially when what you want is to get something done quickly and not waste your time figuring out the intricacies of the language. You want to spend more time working on the real problem. There are very simple languages that do more power full things in a short time even for a layman, why not take advantage of that unless you are a fool who does everything in one language? Real C++ libraries usually take some time to use them. I sometimes wonder if it is worth it after going through a bit using them. No chess engine has real c++ here anyway...
bhlangonijr
Posts: 482
Joined: Thu Oct 16, 2008 4:23 am
Location: Milky Way

Re: A logging facility

Post by bhlangonijr »

Daniel Shawul wrote:Hey guy in the milk way :) You forgot to mention "Java guys bashing C++", "C# guys bashing C++", "PHP guys bashing C++", "Somebody's mom bashing C++". Seriously though sometimes C++ could be a pain specially when what you want is to get something done quickly and not waste your time figuring out the intricacies of the language. You want to spend more time working on the real problem. There are very simple languages that do more power full things in a short time even for a layman, why not take advantage of that unless you are a fool who does everything in one language? Real C++ libraries usually take some time to use them. I sometimes wonder if it is worth it after going through a bit using them.
fully agree.
No chess engine has real c++ here anyway...
If you mean by that one's program must be baptized by Bjarne Stroustrup to be considered a real C++ then I would agree with you. :)

Although I am not a C/C++ expert nor religious follower, I think the code base of Bobcat (on github) may fit a lot in what one should consider a real C++ program.

Stockfish has a very nice source code, but with a lot of C and C++ all mixed altogether. That is completely fine to me.
diep
Posts: 1822
Joined: Thu Mar 09, 2006 11:54 pm
Location: The Netherlands

Re: A logging facility

Post by diep »

hgm wrote:Why let an engine keep a log when the GUI can do it for you?
Because from testers you get back reports your engine loses everything, at which point you praise the soil under your shoes that you have a logfile that tells you they made yet another beginnersmistake.

Now in your case you might not care about losing, in which case it's fine that they turned off pondering for your engine, run it at 8 cores while the box has other software eating a ton of systemtime reducing it effectively to 6 available, and effectively manage to get its hashtable put at 1 MB as they run your proggie under Fritz which gives non-chessbase native UCI engines a 1MB hashtable. If you don't observe anything of that, your engine WILL get dicked and you'll lose.

Testing is a special expertise, very few know how to do it. From those few even less are amongst the 'known testers' posting here.

For example i'm 100% convinced that Stockfish would be higher rated in the ratinglists if it wouldn't have the neat YBW that Tord wrote; it's a reasonable SMP that it's using, yet if it loses a core out of 8 as something else runs, it slows down factor 1000. Whereas Rybka & most clones and derivatives such as houdini, they use a crappy SMP algorithm that easily can lose a core for a while; it doesn't slowdown factor 1000 then, sometimes it doesn't even notice it, if it's for a short while.

So what SF is doing is all 100% ok except that 99% of the testers has no clue what junk runs on their box which sometimes eats a full core of it for sometiems longer periods of time.

The average screenshot of testers already confirms you this. Just look bottomright it has like 13 spyware applications running there that do everything except eat 0% system time.
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: A logging facility

Post by Daniel Shawul »

If you mean by that one's program must be baptized by Bjarne Stroustrup to be considered a real C++ then I would agree with you.

Although I am not a C/C++ expert nor religious follower, I think the code base of Bobcat (on github) may fit a lot in what one should consider a real C++ program.

Stockfish has a very nice source code, but with a lot of C and C++ all mixed altogether. That is completely fine to me.
Just for the record my engine is also C++ but I don't consider it a work of art. For chess engines where speed matters in both search and eval, I don't see many places left to apply fancy c++ features IMO. Take for example this C++ package that has been developed for more than 30 years. It started as one of those c++ projects to decrown fortran as the major scientific programming language. As c++ evolved the software has also evolved with it and probably contributed some to it as well like STL,Blitz++ and now Boost did. But the learning curve for that software is very high which puts of many people from using it. The main idea behind it was to formulate and solve pdes very easily as depicted in the wiki article. It may have achieved that goal through metaprograming and operator overloading but not so many people use it because of its complexity. Take a look at the source code here and tell me if that is not baptized by bjarne himself :)
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: A logging facility

Post by bob »

bhlangonijr wrote:
bob wrote:And there is less risk of using features that are not exactly conducive to efficiency. Templates come to mind. AKA "code bloat". It's a matter of personal taste.
oh my... don't you guys get tired of this kind of language wars? :)
This is a very known pattern:

Assembly guys bashing C language -->
C guys bashing C++ (vide Linus Torvalds vs some random c++ dude famous thread in the internet) -->
C++ guys bashing Java -->
Java guys bashing Scala, Python, Erlang, ....

I'd very much prefer get my ass off the couch and try learning something new..

But I'd say this:

Code: Select all

x = std::abs(y);
is definitely much better than

Code: Select all

 
x = labs(y); // or
x = cabs(y); // or
x = labs(y); // whatever ....
...
This is not a matter of "personal taste". I suppose this is the natural evolution of computer languages. ;-)
So you like overloaded operators. many do. I personally want more control when speed is critical. I'm not bashing C++ at all, having used it for a LONG time. But I don't use it for chess programming. I have seen several that do, and when you look at their code, you begin to see all the static stuff to avoid creation/destruction overhead and such, and significant parts of the language are bypassed in doing so...

I can quote at least a couple of dozen languages I have used / taught in years past. Each of which had its strong points and weaknesses. And hardly any of which I would have chosen to use for a chess program...
User avatar
hgm
Posts: 27809
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: A logging facility

Post by hgm »

diep wrote:
hgm wrote:Because from testers you get back reports your engine loses everything, at which point you praise the soil under your shoes that you have a logfile that tells you they made yet another beginnersmistake.
Except that they would of course not have made the log file, don't know where to find it, etc.

Fighting user incompetence is a losing battle. Why bother at all..
User avatar
hgm
Posts: 27809
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: A logging facility

Post by hgm »

This gives me an idea:

Currently in WinBoard there are only two modes of logging, on or off (controlled by the -debug option, or with Ctrl+Alt+F12 or Ctrl+D). And when switched on, it always overwrites a previous winbaord.debug file.

Would it be useful to introduces some more levels of logging? E.g. where the user can select whether:

1) debug files are overwritten or appended
2) communication with the first engine is included
3) debug output (starting with #) of the first engine is included
4) communication with the second engine is included
5) debug output (starting with #) of the second engine is included
6) WinBoard debugging output is more verbose

Some checkboxes could be added to the Save Game Options dialog could control this.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: A logging facility

Post by mcostalba »

Daniel Shawul wrote:No chess engine has real c++ here anyway...

Code: Select all

C++ != "C with objects" ^ C

What most of people think is object oriented it is just name mangling, but there is more than name mangling in OO. And I can add that using classes to achieve name mangling is something I am not interested in.

Anyhow, as usual, "People that know do, people that don't know teach":-) (old Italian saying, no offense for anybody, take it as a joke).