2 # Convert SGF file to a sequence of GTP games, one game per each variation
3 # that ends with /GOOD/ comment.
11 my $pt = $sgf->getAddress();
15 my ($b, $w) = ($sgf->property('B'), $sgf->property('W'));
16 if ($b) { push @moves, ['b', $_] foreach @
$b; }
17 if ($w) { push @moves, ['w', $_] foreach @
$w; }
18 } while ($sgf->prev());
20 print "boardsize 19\nclear_board\n";
21 for my $move (reverse @moves) {
22 my ($sx, $sy) = @
{$move->[1]};
23 my @abcd = split(//, "abcdefghjklmnopqrstuvwxyz");
24 my $x = $sy + 1; my $y = $abcd[18 - $sx];
25 if ("$y$x" eq "z20") {
28 print "play ".$move->[0]." $y$x\n";
37 my $c = $sgf->property('C');
38 if ($c and $c->[0] =~ /GOOD/) {
41 for (0 .. $sgf->branches()-1) {
49 my $sgf = new Games
::SGF
::Go
;
51 $sgf->readFile($ARGV[0]);