2 # Convert ascii board diagrams from board_print() to gtp.
3 # Usage: ./board_print_to_gtp > foo.gtp
4 # copy paste the diagram, ^D
5 # tweak foo.gtp: script doesn't pay attention to last
6 # move currently so always sets black to play.
9 binmode STDIN
, ":utf8";
10 binmode STDOUT
, ":utf8";
12 my $asdf = "abcdefghjklmnopqrstuvwxyz";
18 return substr($asdf, $x-1, 1) . $y;
24 foreach my $s (<STDIN
>)
27 # remove current move mark
28 $s =~ s/([OX.])\)/$1 /;
29 if ($s =~ m/^ ([ 1][0-9]) \| (([.OX] )+)\|/ ||
30 $s =~ m/^([ 1][0-9]) *(([.OX] )+) /)
32 my ($l, $s) = ($1, $2);
34 my @t = split("", $s);
37 for (my $i = 0; $i < @t; $i++)
39 if ($t[$i] ne "X") { next; }
40 $ab .= sprintf("play b %s\n", coord2gtp
($i+1, $l));
43 for (my $i = 0; $i < @t; $i++)
45 if ($t[$i] ne "O") { next; }
46 $aw .= sprintf("play w %s\n", coord2gtp
($i+1, $l));
51 print "boardsize $size\n";
52 print "clear_board\n";