Merge branch 'master' into test3
[pachi/nmclean.git] / pattern_spatial_show.pl
blob306518097423586b027be9e5bf21e6abdd786e61
1 #!/usr/bin/perl
2 # pattern_spatial_show: Show given spatial dictionary entry on board
4 my $f = "patterns.spat";
5 my $id = $ARGV[0];
7 my @ofs = ();
9 open D, "$f" or die "$f: $!";
10 while (<D>) {
11 chomp;
12 if (s/^# Point order: d=(\d+) //) {
13 my $d = $1; next if ($d < 1);
14 # XXX: Distances must be in proper order!
15 s/ *$//;
16 push @ofs, map { [ split(/,/, $_) ] } split(/ /, $_);
17 # print "#### $_\n";
18 # print "[$d] ($#ofs) " . join(' ', map { $_->[0].",".$_->[1] } @ofs) . "\n";
19 next;
21 /^#/ and next;
22 my ($lid, $d, $pat, @hashes) = split (/\s+/, $_);
23 if ($id == $lid) {
24 print "$d $pat\n";
25 my @b;
26 my @pc = split (//, $pat);
27 for my $i (0 .. $#pc) {
28 # print "$i: $pc[$i] -> $ofs[$i][1],$ofs[$i][0]\n";
29 $b[$d + $ofs[$i][1]][$d + $ofs[$i][0]] = $pc[$i];
31 $b[$d][$d] = '_';
32 for my $y (0 .. 2 * $d) {
33 for my $x (0 .. 2 * $d) {
34 print $b[2 * $d - $y][$x] || ' ';
36 print "\n";