Detect faulty tsumego

   

Below is a script to print a list of files in a directory where the final move is played by a different colour than the first move. This can be useful since some tsumego collections have problems which cannot be solved using some software (eg gogrinder)

use File::Slurp;

my $path = shift;

my @files = read_dir($path, prefix => 1);

for my $file (sort @files) {

 print "$file\n" if comparefirstandlastmove(read_file($file));

}

sub comparefirstandlastmove {

 my $sgf = shift;
 if ($sgf =~ /;([BW])\[/) {
   my $firstmove = $1;
   if ($sgf =~ /;([BW])\[..\]\)$/) {
     my $lastmove = $1;
     return 1 if $firstmove ne $lastmove
   }
 }
 return 0

}


This is a copy of the living page "Detect faulty tsumego" at Sensei's Library.
(OC) 2023 the Authors, published under the OpenContent License V1.0.
[Welcome to Sensei's Library!]
StartingPoints
ReferenceSection
About