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


Detect faulty tsumego last edited by on April 16, 2014 - 15:40
RecentChanges · StartingPoints · About
Edit page ·Search · Related · Page info · Latest diff
[Welcome to Sensei's Library!]
Search position
Page history
Latest page diff
Partner sites:
Go Teaching Ladder
Login / Prefs
Sensei's Library