Hey guys, I don't know if this is the right forum for questions like this, but I hope so.
I am trying to find a script to allow me to batch analyze EPD files with a UCI engine, preferably on a mac. So something like a bash or perl script that will take a search depth or time as an argument, an engine name, and an EPD file name, and will store the CE value back into the file for each position.
I'm looking to use it with the program CPT, which is basically a free version of bookup that doesn't do positional evaluations in the program.
Does anyone have something like that or would anyone be able to point me in the right direction to get started trying to build it?
Help with EPD script?
Moderators: hgm, Rebel, chrisw
-
- Posts: 128
- Joined: Sat Sep 23, 2006 7:10 pm
- Location: Prague
Re: Help with EPD script?
I am not quite sure what do you want exactly but maybe something like this?
arguments:
[t|d] [time in msec|depth] engine_path epdfile_path
example:
t 880 "C:/Program Files (x86)/Arena/Engines/critter/Critter_1.0_64bit.exe" "E:/work/chessprog/DATABASE/testy/LAPUCE2.EPD"
arguments:
[t|d] [time in msec|depth] engine_path epdfile_path
example:
t 880 "C:/Program Files (x86)/Arena/Engines/critter/Critter_1.0_64bit.exe" "E:/work/chessprog/DATABASE/testy/LAPUCE2.EPD"
Code: Select all
#!/usr/bin/perl
use IPC::Open2;
$engine = $ARGV[2];
$epdfile = $ARGV[3];
if ($ARGV[0] eq 't') { $limit = 'movetime' }
elsif ($ARGV[0] eq 'd') { $limit = 'depth' }
else { die ("bad argument: $ARGV[0]") }
die ("bad argument: $ARGV[1]") unless ($ARGV[1] =~ /^\d+$/);
$limit = $limit.' '.$ARGV[1];
$output = ">output.txt";
$engine = open2(*FROMENG, *TOENG, $engine);
TOENG->autoflush(1);
FROMENG->autoflush(1);
$| = 1;
open EPDFILE, $epdfile or die ("can't open $epdfile!!!");
open OUTPUT, $output or die ("can't open $output!!!");
print TOENG "uci\n";
while (<EPDFILE>)
{
if ( m§(?:(?:[1-8KkQqRrBbNnPp]+/){7}[1-8KkQqRrBbNnPp]+) (?:[wb]) (?:-|K?Q?k?q?) (?:-|[a-h][1-8])§o )
{
print TOENG "position fen $&\ngo $limit\n";
my $line = <FROMENG>;
my $score = '???';
my $ismate;
while ($line !~ /bestmove/)
{
if ($line =~ /score (cp|mate) (-?\d+) /)
{
$score = $2;
$ismate = $1;
}
$line = <FROMENG>;
}
chomp;
print OUTPUT "$_ ".($ismate eq 'mate' ? 'mate ' : '').$score."\n";
}
}
print TOENG "quit\n";
close EPDFILE;
close TOENG;
close FROMENG;
close OUTPUT;
-
- Posts: 5106
- Joined: Tue Apr 29, 2008 4:27 pm
Re: Help with EPD script?
I wrote a script called "plumbing" long ago which let's you "script" uci commands. Since UCI is a synchronous protocol, you cannot normally just pipe commands to it, but my script allows this. It essentially feeds the commands you send to the engine but deals with the asynchronous parts, such as waiting for the results of the "go" command which normally blocks execution of other commands that might be sent. It's about 20 lines of tcl code. Same things could easily be done in perl, ruby, lua, etc.Kingpatzer wrote:Hey guys, I don't know if this is the right forum for questions like this, but I hope so.
I am trying to find a script to allow me to batch analyze EPD files with a UCI engine, preferably on a mac. So something like a bash or perl script that will take a search depth or time as an argument, an engine name, and an EPD file name, and will store the CE value back into the file for each position.
I'm looking to use it with the program CPT, which is basically a free version of bookup that doesn't do positional evaluations in the program.
Does anyone have something like that or would anyone be able to point me in the right direction to get started trying to build it?
The Unix philosophy is simple tools that connect and enhance each other, so it's easy to use this tool in pipeline with other simple scripts to do cool things.
However, what you actually want is polyglot, which I believe supports exactly what you are asking for. It has an EPD test mode and lot of ways to configure it.
Don
-
- Posts: 5106
- Joined: Tue Apr 29, 2008 4:27 pm
Re: Help with EPD script?
I just saw the script by Filip which is probably just as good for what you need too.
Don
Don
Don wrote:I wrote a script called "plumbing" long ago which let's you "script" uci commands. Since UCI is a synchronous protocol, you cannot normally just pipe commands to it, but my script allows this. It essentially feeds the commands you send to the engine but deals with the asynchronous parts, such as waiting for the results of the "go" command which normally blocks execution of other commands that might be sent. It's about 20 lines of tcl code. Same things could easily be done in perl, ruby, lua, etc.Kingpatzer wrote:Hey guys, I don't know if this is the right forum for questions like this, but I hope so.
I am trying to find a script to allow me to batch analyze EPD files with a UCI engine, preferably on a mac. So something like a bash or perl script that will take a search depth or time as an argument, an engine name, and an EPD file name, and will store the CE value back into the file for each position.
I'm looking to use it with the program CPT, which is basically a free version of bookup that doesn't do positional evaluations in the program.
Does anyone have something like that or would anyone be able to point me in the right direction to get started trying to build it?
The Unix philosophy is simple tools that connect and enhance each other, so it's easy to use this tool in pipeline with other simple scripts to do cool things.
However, what you actually want is polyglot, which I believe supports exactly what you are asking for. It has an EPD test mode and lot of ways to configure it.
Don