Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Are there free programs that do the following tasks(about book)

Author: Tim Foden

Date: 23:51:40 05/25/03

Go up one level in this thread


On May 25, 2003 at 16:26:28, Matthew White wrote:

>Here's a quick perl snippet that I wrote which cuts the original strings into
>output readable by the pgn utilities:
>open (IN, 'test.pgn');
>
>while (<IN>) {
>
>chomp;
>print "[]\n";
>$length = length($_);
>for ($count=0; $count < $length / 4; $count +=4) {
>	$cutstr = substr $_, $count, 4;
>	print "$cutstr "
>}
>print "\n";
>}
>
>close(IN);
>
>Regards,
>Matt

Unfortunately it can't be quite as simple as this, as even though it is an
opening book, you may have to cater for promotions, which will make the move 5
charaters long.  The most difficult would be the promotions to B as the letter B
is also used in the coordinate notation.  I guess you'd have to use a pattern
and also match the following token, which is either the end of the line, or a
coordinate letter.

I'm not sure of the syntax in perl, but maybe something like:
([a-hA-H][1-8][a-hA-H][1-8][bnrqBNRQ]?)($|[a-hA-H])

Cheers, Tim.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.