#!/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 ` # (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"; } }