gvreuls / cutechess

This Cute Chess fork is meant as a backend for the TCEC web interface.
GNU General Public License v3.0
3 stars 3 forks source link

-debug option feature request #2

Closed hero2017 closed 6 years ago

hero2017 commented 6 years ago

It doesn't appear to be possible to save the engine log for the tournament to a file. I'm only able to send output to DOS screen. Could you please give us the option to specify a filename after -debug so that we could send it to a file with path instead of output to screen?

I tried to redirect to a file but then I get no output on screen such as result, game start/finished (-debug > C:\cutechess\logfile.txt)

gvreuls commented 6 years ago

I have no way to test this on Windows (I normally work on Linux and don't have any Windows chess engines to test with), but the -debug info is written to stderr, so you have to redirect stderr to stdout if you want to redirect the debug output, e.g.: -debug > C:\cutechess\logfile.txt 2>&1 (note the 2>&1)

hero2017 commented 6 years ago

Thanks but I've already tried this. While this works (I get the logfile.txt), there is no output to screen as to any results of the games, or even if games are being played or have finished playing. So if I wanted to stop the tournament after a game has finished I wouldn't know when to press CTRL-C before resuming the tournament.

gvreuls commented 6 years ago

I misunderstood your post, sorry. I will take this feature request into consideration even though it's more of an upstream issue, but I need to implement other features first so this will take some time.

You basically need a Unix tee command that copies its stdin to stdout and a specified file. Windows PowerShell has Tee-Object (help Tee-Object), perhaps you could use that as a stop gap?

hero2017 commented 6 years ago

I just tried using tee-object. Best I could do is have everything show on screen and also copy to a file. Unfortunately we can't have both otherwise I won't be able to see when a game has finished and what result it had. We need the normal cutechess-cli output of results etc but have -debug output only to file.

I realize you have other features to implement so if you could at least point me in the direction of what I'd need to change in the source files I'd be happy to do it myself.

gvreuls commented 6 years ago

You need to edit

  1. https://github.com/gvreuls/cutechess/blob/59562e9f412d80aa7849519c75651aa534725a70/projects/cli/src/enginematch.h#L32 add a QFile member for the debug file to the EngineMatch class, and define a setDebugFile helper method for opening the file by passing its file name.

  2. https://github.com/gvreuls/cutechess/blob/59562e9f412d80aa7849519c75651aa534725a70/projects/cli/src/enginematch.cpp#L738 change the print method to write to the QFile member, implement the setDebugFile helper method to open the QFile member, don't forget to close the QFile member in the destructor.

  3. https://github.com/gvreuls/cutechess/blob/59562e9f412d80aa7849519c75651aa534725a70/projects/cli/src/main.cpp#L294 change the parseMatch function so it accepts a debugfile command line option and passes it to the setDebugFile method of the match object (like the debug option).

hero2017 commented 6 years ago

Thanks. This isn't quite what I expected. But I had someone help me to modify the code so that redirect works now but doesn't print to screen either.

hero2017 commented 6 years ago

I have two more questions:

1) How can I force the winning games to play until checkmate and not adjudicate by TB? I've already tried not enabling -tb or setting the game score to something like 45000 for 100 moves. I've also tried not specifying -resign 2) Is there a bug with the -wait 60000 (ms) option? My next games start immediately after a game is finished instead of waiting 1 min.

gvreuls commented 6 years ago

I've just checked the -tb and -wait options and they work as advertised, no bugs there.

Please note that these options have no effect when you use the -resume option because they are loaded from the .json file you specified with the -tournamentfile option (.json files are just text files, so you can inspect them with a text editor like notepad to find out what's stored and what not, the options are stored in the tournamentSettings object).

gvreuls commented 6 years ago

I presumably have some spare time in the coming few days, so I'm going look into this if @hero2017 can convince me that the stderr= engine option (see cutechess-cli -help) doesn't already do what he wants.

hero2017 commented 6 years ago

For some reason when I use -tb and -wait they don't work. I've inspected the tournament file and it's set to what I want.

As for stderr= engine option, I don't know what you're expecting I still provide. I think I've already shown that there is no way without modifying the code to properly export to a log file AND to also continue getting game results on screen.

It'd sure be nice for this to work properly so if you have some time that'd be great.

gvreuls commented 6 years ago

So if you do a -wait 60000, cutechess-cli doesn't wait a minute before it starts a game? That's very strange because it works fine in my tests.

The -tb path is interpreted like a C string, so you can't simply use backslashes '\' in it because that's the C escape character. Either use forward slashes '/' (yes under Windows too) or use double backslashes '\\' (so C:/Syzygy/ or C:\\Syzygy\\ would both work)

stderr= is a sub-option of the -engine option that saves the engine's debug output to a file: -engine name=Stockfish proto=uci cmd=C:/Stockfish/stockfish.exe stderr=C:/Stockfish/errors.txt would send the Stockfish debug/error output to the C:\Stockfish\errors.txt file

hero2017 commented 6 years ago

I will test the -wait function when I get the chance again. For now I'm not running any tournaments due to other priorities.

Thanks for explaining -tb. Will multi paths work such as: C:/3-4-5;C:/6-DTZ;C:/6-WDL ?

I think I tested stderr in that format but that only produced errors and not engine output but I can't recall now and would need to test it again. Or has this been added/fixed since I first reported it?

gvreuls commented 6 years ago

Multi path -tb doesn't work yet, that's an upstream feature request: https://github.com/cutechess/cutechess/issues/370

What's written to the file depends 100% on the engine, so I think saving the debug output is really what you need. I'll start implementing your feature request in the coming weekend (provided no calamities happen at TCEC and I don't have to fix critical bugs ASAP).

gvreuls commented 6 years ago

I have implemented your feature request: https://github.com/gvreuls/cutechess/commit/ea4a1a72efac920309fd8c65b2af63f3bd4f6df7

hero2017 commented 6 years ago

Excellent! Thank you very much! I'll be sure to use it for my next tournaments. That was more code change than I expected. I hope it didn't take too much of your time.

As for -tb I guess for full Syzygy to work I have to mix all 3 folders in one until this is fixed.

gvreuls commented 6 years ago

Great, I'll close this issue.

Mixing the tb files in a single directory isn't a big issue in practice because it's easy to split the tb files if you copy/move them from the console based on their file name length: move ????.rtb? C:\destination\ moves al 3-men files, move ?????.rtb? C:\destination\ moves al 4-men files, etc.