Page 2 of 11

Re: c-chess-cli

Posted: Wed May 20, 2020 2:42 pm
by lucasart
Joerg Oster wrote: Tue May 19, 2020 10:08 pm I tried fixed depth, tournament tc and Fischer bonus time.
Fixed tournament tc: forgot to add the base time, after movestogo wraps aroung zero. what a dumbass...

Fixed Fischer clock as well. Rule says increment must be added before the move. Most chess UI do it wrong, adding the increment after the move, potentially after having flagged the engine. As a result, engine programmers conservatively assume that the GUI has this bug, and base their time management assumptions on it.

https://old.fide.com/fide/handbook.html ... ew=article
increment: 6.1. An amount of time (from 2 to 60 seconds) added from the start before each move for the player. This can be in either delay or cumulative mode

Re: c-chess-cli

Posted: Wed May 20, 2020 2:53 pm
by Joerg Oster
lucasart wrote: Wed May 20, 2020 2:42 pm
Joerg Oster wrote: Tue May 19, 2020 10:08 pm I tried fixed depth, tournament tc and Fischer bonus time.
Fixed tournament tc: forgot to add the base time, after movestogo wraps aroung zero. what a dumbass...

Fixed Fischer clock as well. Rule says increment must be added before the move. Most chess UI do it wrong, adding the increment after the move, potentially after having flagged the engine. As a result, engine programmers conservatively assume that the GUI has this bug, and base their time management assumptions on it.

https://old.fide.com/fide/handbook.html ... ew=article
increment: 6.1. An amount of time (from 2 to 60 seconds) added from the start before each move for the player. This can be in either delay or cumulative mode
Great!
I also noticed you are sending a "isready" after "ucinewgame" which seems to be mandatory.
Most UIs don't.

Looking forward to the things to come.

Re: c-chess-cli

Posted: Wed May 20, 2020 4:04 pm
by Ras
I'd suggest to add the following line at the top of each source text file (.c and .h):

Code: Select all

/* SPDX-License-Identifier: GPL-3.0-or-later */
That makes it easy e.g. for Linux distros to automatically determine package licences.

CppCheck flags out a lot of portability issues because "Passing NULL after the last typed argument to a variadic function leads to undefined behaviour." That's a problem with all these str_xxx defines.

Re: c-chess-cli

Posted: Thu May 21, 2020 1:03 am
by lucasart
Ras wrote: Wed May 20, 2020 4:04 pm CppCheck flags out a lot of portability issues because "Passing NULL after the last typed argument to a variadic function leads to undefined behaviour." That's a problem with all these str_xxx defines.
I want to write, for example, str_delete(&s1, ..., &sn), for arbitrary n >= 1. The "..." argument in C was designed for things like printf(), which have a format string. It's by parsing the format string, that the function discovers how many arguments there are, and of what type. Here there is no format string, we know the argument type (str_t *) but we don't know how many there are. The va_list itself doesn't know its own length. So the only way I found was to add a null pointer at the end.

How would you solve this problem ? (without C++11, just C99)

The C standard seems to suggest doing str_delete(n, &s1, ..., &sn). But it just sucks that the calling code has to supply the n, plus this could easily lead to unobvious errors, as code gets edited (you add/remove strings in the list, and forget to update n).

Re: c-chess-cli

Posted: Thu May 21, 2020 1:19 am
by Ras
lucasart wrote: Thu May 21, 2020 1:03 amSo the only way I found was to add a null pointer at the end.
I think the portability problem is that NULL is not necessarily defined as pointer in ((void *) 0) style, though it is under POSIX - but not guaranteed as per the C standard (that may be an integer 0 as well). If the arguments are passed on the stack, and the caller pushes an integer (e.g. 32 bit) while the callee expects a pointer (e.g. 64 bit), that might go wrong. With ordinary functions, this isn't an issue because of argument casting, but that requires typed function prototypes - variadic functions are pretty much an edge case.

An easy solution would be to replace NULL with (const char *) NULL in this context.

Re: c-chess-cli

Posted: Fri May 22, 2020 5:39 am
by lucasart
Joerg Oster wrote: Tue May 19, 2020 10:08 pm A summary of the result at the end would be nice. :D
Done. Total WLD and score% shown after each game.

c-chess-cli: generating training data for NN eval

Posted: Wed Aug 19, 2020 2:51 pm
by lucasart
Just added a sampling feature to generate training data (= position + search result), fast and scalably (concurrency supported). This can be used to to teach a neural network to evaluate chess positions.
https://github.com/lucasart/c-chess-cli/#sampling

Hopefully some people will be interested in designing and training their own NN eval, rather than copy/pasting NNUE into their engine.

Re: c-chess-cli

Posted: Fri Aug 21, 2020 9:39 am
by Roland Chastain
Very interesting project.

I have just made a first quick test. One engine doesn't find its opening book, and this results in the following problem:

Code: Select all

SlowChess Blitz Classic 2.1 <- ucinewgame
deadline set: SlowChess Blitz Classic 2.1 must respond by 55389187
SlowChess Blitz Classic 2.1 <- isready
SlowChess Blitz Classic 2.1 -> Error Error Loading Book openingBook/TestBook.scbreadyok
deadline passed: SlowChess Blitz Classic 2.1 responded at 55388281, 906ms before the deadline.
deadline passed: SlowChess Blitz Classic 2.1 responded at 55388381, 806ms before the deadline.
deadline passed: SlowChess Blitz Classic 2.1 responded at 55388481, 706ms before the deadline.
I wonder why "readyok" is stuck to the error message.

But the first problem (I believe) is that c-chess-cli doesn't seem to change current directory. Am I wrong?

Re: c-chess-cli

Posted: Fri Aug 21, 2020 3:03 pm
by lucasart
Roland Chastain wrote: Fri Aug 21, 2020 9:39 am Very interesting project.

I have just made a first quick test. One engine doesn't find its opening book, and this results in the following problem:

Code: Select all

SlowChess Blitz Classic 2.1 <- ucinewgame
deadline set: SlowChess Blitz Classic 2.1 must respond by 55389187
SlowChess Blitz Classic 2.1 <- isready
SlowChess Blitz Classic 2.1 -> Error Error Loading Book openingBook/TestBook.scbreadyok
deadline passed: SlowChess Blitz Classic 2.1 responded at 55388281, 906ms before the deadline.
deadline passed: SlowChess Blitz Classic 2.1 responded at 55388381, 806ms before the deadline.
deadline passed: SlowChess Blitz Classic 2.1 responded at 55388481, 706ms before the deadline.
I wonder why "readyok" is stuck to the error message.

But the first problem (I believe) is that c-chess-cli doesn't seem to change current directory. Am I wrong?
Indeed, it doesn't change the current directory. So the path you give "openingBook/TestBook.scb" has to be either absolute, or relative to the current directory. I could make engine engine use their own directory as current directory, which is probably what users expect.

The fact that readyok is stuck to the error msg is not related to c-chess-cli, but rather SlowChessBlitz, which forgot to write a '\n' there.

The "deadline passed" is probably a poor choice of words. It's "passed" as in "pass/fail". Maybe "deadline ok" is better.

Re: c-chess-cli

Posted: Fri Aug 21, 2020 4:23 pm
by Roland Chastain
lucasart wrote: Fri Aug 21, 2020 3:03 pm Indeed, it doesn't change the current directory. So the path you give "openingBook/TestBook.scb" has to be either absolute, or relative to the current directory. I could make engine engine use their own directory as current directory, which is probably what users expect.
Thank you for your answer. To be perfectly clear, I didn't give the path: it's the engine itself who searches automatically its book. I believe that many engines search books or other files like that, so IMHO it would be a good idea to do what you say (make engine use their own directory as current directory).
lucasart wrote: Fri Aug 21, 2020 3:03 pm The fact that readyok is stuck to the error msg is not related to c-chess-cli, but rather SlowChessBlitz, which forgot to write a '\n' there.
Yes, it was also my impression. I should report the bug to the author of SlowChess. Done.
lucasart wrote: Fri Aug 21, 2020 3:03 pm The "deadline passed" is probably a poor choice of words. It's "passed" as in "pass/fail". Maybe "deadline ok" is better.
No opinion about that: I don't know well english. :)