board_undo: define QUICK_BOARD_CODE to get compiler error with forbidden fields.
[pachi.git] / tools / board_print_to_tunit
blob6280cd0376ad19e23c13cac6ddae0e211967e7cf
1 #!/usr/bin/perl
2 # Convert ascii board diagrams from board_print() to t-unit board format.
3 # (remove borders and just keep the stones basically)
4 # Usage: ./board_print_to_tunit > foo.t
5 # copy paste the diagram, ^D
7 use utf8;
8 binmode STDIN, ":utf8";
9 binmode STDOUT, ":utf8";
11 my $size = 0;
12 foreach my $s (<STDIN>)
14 $s =~ s/ยท/./g;
15 # Remove current move mark
16 $s =~ s/([OX.])\)/$1 /;
17 if ($s =~ m/^ [ 1][0-9] \| (([.OX] )+)\|/ ||
18 $s =~ m/^[ 1][0-9] *(([.OX] )+) /)
20 my $s = $1;
21 if ($size == 0)
23 $size = split("", $s) / 2;
24 print "boardsize $size\n";
26 $s =~ s/ *$//;
27 print "$s\n";