cutechess-cli: starting from FEN

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

cutechess-cli: starting from FEN

Post by Evert »

For my normal testing setup I tend to run matches from a Perl script using XBoard. I specify the starting position from a set of opening positions with the -lpf/-lpi commandline options. This works great, but of course I get new XBoard window on my current desktop whenever a new game starts, which is annoying.

It seems that the easiest alternative would be cutechess-cli, but it seems not to have the option of starting from a particular FEN (either specified directly as a string on the commandline or from a file). Looking at the source, my impression is that it wouldn't actually be hard to add this functionality, but before I invest the time to do that I'd like to ask whether someone else has perhaps already done that or knows of some caveats that I might have overlooked?

Suggestions for alternative tools are also welcome, but I don't have the impression there is much choice here.

Note that I'm aware of the option to specify a PGN/EPD opening book. This works, of course, but I would prefer to use the starting positions that I had been using because that way I know that I can compare the new test results with the old (in an ideal world it shouldn't matter, of course, but I'd like to test that first).
User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Re: cutechess-cli: starting from FEN

Post by Rebel »

Arena converts EPD to PGN.
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: cutechess-cli: starting from FEN

Post by lucasart »

Evert wrote:For my normal testing setup I tend to run matches from a Perl script using XBoard. I specify the starting position from a set of opening positions with the -lpf/-lpi commandline options. This works great, but of course I get new XBoard window on my current desktop whenever a new game starts, which is annoying.

It seems that the easiest alternative would be cutechess-cli, but it seems not to have the option of starting from a particular FEN (either specified directly as a string on the commandline or from a file). Looking at the source, my impression is that it wouldn't actually be hard to add this functionality, but before I invest the time to do that I'd like to ask whether someone else has perhaps already done that or knows of some caveats that I might have overlooked?

Suggestions for alternative tools are also welcome, but I don't have the impression there is much choice here.

Note that I'm aware of the option to specify a PGN/EPD opening book. This works, of course, but I would prefer to use the starting positions that I had been using because that way I know that I can compare the new test results with the old (in an ideal world it shouldn't matter, of course, but I'd like to test that first).
Ilari has implemented this in the latest git source code. But you'll have to compile it. It allows to use an EPD file as input (ie. text file which is just 1 FEN per line)
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: cutechess-cli: starting from FEN

Post by Evert »

lucasart wrote:Ilari has implemented this in the latest git source code. But you'll have to compile it. It allows to use an EPD file as input (ie. text file which is just 1 FEN per line)
I did look at the latest source to see whether the option had already been added. I guess it's the "-epdin" option? The documentation provided for it isn't very clear ("use <file> as the opening book in EPD format") which to me suggested that it expected a list of EPD positions from which it would build an opening book (somehow; it would also need some sort of suggestion for a move of course).

I'm going to try it out, thanks!
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: cutechess-cli: starting from FEN

Post by Evert »

Rebel wrote:Arena converts EPD to PGN.
Wouldn't help in this case, unfortunately, since the set of starting positions are all at the same depth (ie, you can't construct a full line from the starting position using them).

Plus I'd need Windows. :P (I guess Wine would work, but I'd prefer not to).
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: cutechess-cli: starting from FEN

Post by michiguel »

Evert wrote:
Rebel wrote:Arena converts EPD to PGN.
Wouldn't help in this case, unfortunately, since the set of starting positions are all at the same depth (ie, you can't construct a full line from the starting position using them).

Plus I'd need Windows. :P (I guess Wine would work, but I'd prefer not to).
If you have ruby installed in your system
save this as fen2pgn.rb

Code: Select all

File.open ARGV&#91;0&#93;, "r" do |f|
   lines = f.readlines
   lines.each do |li|
        puts '&#91;Event "?"&#93;'
        puts '&#91;Site "?"&#93;'
        puts '&#91;Date "????.??.??"&#93;'
        puts '&#91;Round "?"&#93;'
        puts '&#91;White "?"&#93;'
        puts '&#91;Black "?"&#93;'
        puts '&#91;Result "*"&#93;'
        puts '&#91;Fen "' +li.strip+ '"&#93;'
      puts
   end
end
and then run it with
ruby fen2pgn.rb file.fen > file.pgn

You can use the file.pgn as starter positions.

A C version in this thread
http://www.open-aurec.com/wbforum/viewt ... 27#p192626

Miguel
User avatar
ilari
Posts: 750
Joined: Mon Mar 27, 2006 7:45 pm
Location: Finland

Re: cutechess-cli: starting from FEN

Post by ilari »

Evert wrote:
Rebel wrote:Arena converts EPD to PGN.
Wouldn't help in this case, unfortunately, since the set of starting positions are all at the same depth (ie, you can't construct a full line from the starting position using them).

Plus I'd need Windows. :P (I guess Wine would work, but I'd prefer not to).
The PGN standard does have the FEN tag, so you can easily put your FENs in a PGN file, see this post for clarification.
User avatar
ilari
Posts: 750
Joined: Mon Mar 27, 2006 7:45 pm
Location: Finland

Re: cutechess-cli: starting from FEN

Post by ilari »

michiguel wrote:
Evert wrote:
Rebel wrote:Arena converts EPD to PGN.
Wouldn't help in this case, unfortunately, since the set of starting positions are all at the same depth (ie, you can't construct a full line from the starting position using them).

Plus I'd need Windows. :P (I guess Wine would work, but I'd prefer not to).
If you have ruby installed in your system
save this as fen2pgn.rb

Code: Select all

File.open ARGV&#91;0&#93;, "r" do |f|
   lines = f.readlines
   lines.each do |li|
        puts '&#91;Event "?"&#93;'
        puts '&#91;Site "?"&#93;'
        puts '&#91;Date "????.??.??"&#93;'
        puts '&#91;Round "?"&#93;'
        puts '&#91;White "?"&#93;'
        puts '&#91;Black "?"&#93;'
        puts '&#91;Result "*"&#93;'
        puts '&#91;Fen "' +li.strip+ '"&#93;'
      puts
   end
end
and then run it with
ruby fen2pgn.rb file.fen > file.pgn

You can use the file.pgn as starter positions.

A C version in this thread
http://www.open-aurec.com/wbforum/viewt ... 27#p192626

Miguel
You forgot that the "FEN" tag should be in uppercase, and a termination marker (eg. "*") is needed at the end.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: cutechess-cli: starting from FEN

Post by Evert »

ilari wrote: The PGN standard does have the FEN tag, so you can easily put your FENs in a PGN file, see this post for clarification.
Interesting.

I (clearly!) wouldn't have thought of using the FEN tag in that way. I'll remember it as a possibility for future reference. Does feel like a bit of a hack though. ;)
User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Re: cutechess-cli: starting from FEN

Post by Rebel »

Evert wrote:
ilari wrote: The PGN standard does have the FEN tag, so you can easily put your FENs in a PGN file, see this post for clarification.
Interesting.

I (clearly!) wouldn't have thought of using the FEN tag in that way. I'll remember it as a possibility for future reference. Does feel like a bit of a hack though. ;)
It's how I got cutechess-cli to work for endgame testing, EPD to PGN resulting in something like:

[Event "?"]
[Site "?"]
[Date "?"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]
[SetUp "1"]
[FEN "1N2k3/5p2/p2P2p1/3Pp3/pP3b2/5P1r/P7/1K4R1 b - - 0 1 "]

*