c-chess-cli: experimental windows support

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

mar
Posts: 2559
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: c-chess-cli: experimental windows support

Post by mar »

I've uploaded the "fixed" win version (binary only) here: http://www.crabaware.com/Test/c-chess-cli-win.zip
will let you know if I experience some more problems, looks good so far though
Martin Sedlak
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: c-chess-cli: experimental windows support

Post by lucasart »

mar wrote: Tue Jun 22, 2021 12:00 pm ok, I'm running a first real test with c-chess-cli, seems to work so far!
had to change "re" to "rt" in openings.c (actually "r" would work probably - never heard of "e" though), somehow microsoft CRT doesn't like "re" and fails with an error
EDIT: actually had to replace all "re" with "r", "we" with "w" and "ae" with "a", now everything seems to work fine
Thanks. I'll fix that.

The "e" is because, on Linux, I want all file descriptors to atomically close on exec (to avoid a race during the parallel fork phase). That's why I use pipe2() instead of pipe(). It makes parralel start of many processes much faster. Unfortunately Mac OS doesn't have it, so I use slow POSIX compliant method of closing all fd…

Windows does this differently. In fact, I would say that the windows way is much better here. You just tell CreateProcessA() that you don't want them inherited. BTW the copy/pasted code I used sets the inheritance flag to TRUE, which is wrong, I think.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
mar
Posts: 2559
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: c-chess-cli: experimental windows support

Post by mar »

okay, I played a 10k game regression test and I got the expected result (1.4 elo difference, but I had to switch the books because I was still using the old 8moves_gm one, so I switched to noob's 4 move epd book) and I have to say I'm impressed. no problems, no time losses.

I'll need to do some more tests but so far I can say that the Windows version of c-chess-cli works really well - can be definitely used for engine testing.
perhaps I'll switch sooner rather than later - still I'm grateful for cutechess-cli, having played millions of games with it
Martin Sedlak
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: c-chess-cli: experimental windows support

Post by Ferdy »

It seems like it does not support properly the epd format for -openings option.

For example I have a file containing an epd with ce opcode.

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk - ce 29;
To convert this to fen, just take the first 4 fields (piece_locations stm castle_rights ep_square),

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk -
then add " 0 1" to become a fen.

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk - 0 1
where:
0 is the half-move clock or hmvc
1 is the full-move number or fmvn

If an epd has no hmvc use 0, if no fmvn use 1.

If an epd contains hmvc and fmvn opcodes like the following,

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk - ce 29; hmvc 40; fmvn 12; c0 "white has doubled pawn";
its fen will be the first 4 fields with hmvc and fmvn values.

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk - 40 12
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: c-chess-cli: experimental windows support

Post by lucasart »

Ferdy wrote: Tue Jun 22, 2021 10:43 pm It seems like it does not support properly the epd format for -openings option.

For example I have a file containing an epd with ce opcode.

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk - ce 29;
To convert this to fen, just take the first 4 fields (piece_locations stm castle_rights ep_square),

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk -
then add " 0 1" to become a fen.

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk - 0 1
where:
0 is the half-move clock or hmvc
1 is the full-move number or fmvn

If an epd has no hmvc use 0, if no fmvn use 1.

If an epd contains hmvc and fmvn opcodes like the following,

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk - ce 29; hmvc 40; fmvn 12; c0 "white has doubled pawn";
its fen will be the first 4 fields with hmvc and fmvn values.

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk - 40 12
The expected format is

Code: Select all

fen;garbage
I just send the fen to the engine, and discard the garbage.

So you're saying that EPD allows this?

Code: Select all

fen+garbage;more garbage
This is just wrong design. The whole point of using a delimiter, is that it delimits fields... I am not keen to support that EPD bug.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
mar
Posts: 2559
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: c-chess-cli: experimental windows support

Post by mar »

Ferdy wrote: Tue Jun 22, 2021 10:43 pm If an epd contains hmvc and fmvn opcodes like the following,

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk - ce 29; hmvc 40; fmvn 12; c0 "white has doubled pawn";
wow, I always thought that an EPD record starts with a FEN, but this doesn't seem to be the case...
what's the reasoning behind this silliness? was EPD designed before FEN or is there another reason? the opcodes seem to start with an identifier (which shouldn't start with a number)
so parsing two extra numbers should be no problem at all
Martin Sedlak
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: c-chess-cli: experimental windows support

Post by lucasart »

mar wrote: Tue Jun 22, 2021 6:12 pm okay, I played a 10k game regression test and I got the expected result (1.4 elo difference, but I had to switch the books because I was still using the old 8moves_gm one, so I switched to noob's 4 move epd book) and I have to say I'm impressed. no problems, no time losses.

I'll need to do some more tests but so far I can say that the Windows version of c-chess-cli works really well - can be definitely used for engine testing.
perhaps I'll switch sooner rather than later - still I'm grateful for cutechess-cli, having played millions of games with it
I pushed some fixes:
1/ explicit "b" or "t" mode for fopen() in Windows (vs. "e" in both cases for POSIX).
2/ remove the -Wpadded pedantic warning in make.py. Heeding this when struct elements have platform-dependant sizeof() is just too annoying.
3/ do not inherit parent handled in child processes on Windows.

There is still the problem of '\' vs. '/' in Windows file system. For example, cmd=../engine.exe should work, but cmd=..\engine.exe will not (it will launch ..\engine.exe, but will not break it into its components cwd=..\ and run=engine.exe, so the engine will run from the cwd in which c-chess-cli.exe was launched).
Last edited by lucasart on Wed Jun 23, 2021 1:36 am, edited 1 time in total.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: c-chess-cli: experimental windows support

Post by Ferdy »

lucasart wrote: Wed Jun 23, 2021 12:35 am
Ferdy wrote: Tue Jun 22, 2021 10:43 pm It seems like it does not support properly the epd format for -openings option.

For example I have a file containing an epd with ce opcode.

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk - ce 29;
To convert this to fen, just take the first 4 fields (piece_locations stm castle_rights ep_square),

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk -
then add " 0 1" to become a fen.

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk - 0 1
where:
0 is the half-move clock or hmvc
1 is the full-move number or fmvn

If an epd has no hmvc use 0, if no fmvn use 1.

If an epd contains hmvc and fmvn opcodes like the following,

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk - ce 29; hmvc 40; fmvn 12; c0 "white has doubled pawn";
its fen will be the first 4 fields with hmvc and fmvn values.

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk - 40 12
The expected format is

Code: Select all

fen;garbage
I just send the fen to the engine, and discard the garbage.

So you're saying that EPD allows this?

Code: Select all

fen+garbage;more garbage
This is just wrong design. The whole point of using a delimiter, is that it delimits fields... I am not keen to support that EPD bug.
While the cli currently does not properly read the epd format, I would suggest to change your documentation to only support fen format like below.

Code: Select all

rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2
rnbqkb1r/pppp1ppp/4pn2/8/2PP4/8/PP2PPPP/RNBQKBNR w KQkq - 0 3
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: c-chess-cli: experimental windows support

Post by Ferdy »

mar wrote: Wed Jun 23, 2021 12:57 am
Ferdy wrote: Tue Jun 22, 2021 10:43 pm If an epd contains hmvc and fmvn opcodes like the following,

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk - ce 29; hmvc 40; fmvn 12; c0 "white has doubled pawn";
wow, I always thought that an EPD record starts with a FEN, but this doesn't seem to be the case...
what's the reasoning behind this silliness? was EPD designed before FEN or is there another reason? the opcodes seem to start with an identifier (which shouldn't start with a number)
so parsing two extra numbers should be no problem at all
I think fen was first. EPD is extended position description, it has some advantages of communicating info like ce=centipawn evaluation, bm=best move and other opcodes. PGN standard section 16.2.
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: c-chess-cli: experimental windows support

Post by lucasart »

Ferdy wrote: Wed Jun 23, 2021 1:36 am
mar wrote: Wed Jun 23, 2021 12:57 am
Ferdy wrote: Tue Jun 22, 2021 10:43 pm If an epd contains hmvc and fmvn opcodes like the following,

Code: Select all

1r1qkb1r/1p1bpppp/p4n2/3P4/5Q2/2N5/PP1P1PPP/R1B1K1NR b KQk - ce 29; hmvc 40; fmvn 12; c0 "white has doubled pawn";
wow, I always thought that an EPD record starts with a FEN, but this doesn't seem to be the case...
what's the reasoning behind this silliness? was EPD designed before FEN or is there another reason? the opcodes seem to start with an identifier (which shouldn't start with a number)
so parsing two extra numbers should be no problem at all
I think fen was first. EPD is extended position description, it has some advantages of communicating info like ce=centipawn evaluation, bm=best move and other opcodes. PGN standard section 16.2.
That doesn't explain why. This is plain wrong design, and delimiters are there for delimiting. To add meta data to the position, one should use ';' delimiters, not mix them into the FEN in a way that breaks compatibility with FEN standard itself.

The chess programming community is still fairly small. We can still change things, at least marginally. By purposely refusing to support such bugs, we will weed them out. So I will make a point to keep EPD in the Readme, and not support this EPD bug. I encourage others to do the same.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.