blob: 65355adcd372d649ab5b98a3f5722ab67fc06367 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#!/usr/bin/perl
# Yes, I never wrote real code to parse EPD files. This script converts
# "normal" style EPDs into what typhoon wants to eat.
#
# SUPERSEDED: the engine now parses raw EPD directly -- `epd <file>`
# (see ParseEpdRecord in fen.c, EpdCommand in script.c) -- so this
# preprocessing step shouldn't be needed anymore. Left here rather than
# deleted since some workflow may still shell out to it, but it has a
# known bug: the bm/am regex's `[^b]+` filler between the board and
# "bm" breaks on every Black-to-move record (the side-to-move field is
# literally the character "b"), and $fen/$id/$solution are unscoped
# globals, so a failed match on one line silently carries the
# *previous* line's fen/solution forward instead of erroring. Prefer
# `epd` for any new suite.
while(<>) {
@lines = split(/;/);
for $line(@lines) {
$id = $1 if ($line =~ /^\s*(id.*)$/);
if ($line =~ /^([pnbrqk\-\d\/]+\s[^b]+)bm\s([^;]+)/i) {
$fen = $1;
$solution = "solution $2";
} elsif ($line =~ /^([pnbrqk\-\d\/]+\s[^b]+)am\s([^;]+)/i) {
$fen = $1;
$solution = "avoid $2";
}
}
if ($#lines > 0) {
print "setboard $fen\n$id\n$solution\ngo\n";
}
}
|