A slightly different approach.
#! perl -slw use strict; my $g = qq[PPBRB PRBBB BRRRB BRRRB BGGBB]; my $w = 5 -1; my( $o1, $o2 )= ( $w * 2, $w *2 +1 ); $g =~ s[\n]["\n" . '-+' x $w . "-\n"]eg; $g =~ s[([PRGB])(?=[PRGB])][$1|]g; $g =~ s[(?<=([PRGB]))\|(?=\1)] [ ]g; $g =~ s[(?<=(.).{$o2})[-](?=.{$o2}\1)] [ ]gs; $g =~ s[(?<= .{$o1}[-])\+(?=[-].{$o1} )] [-]gs; $g =~ s[(?<= .{$o1}[ -])\+(?=[ -].{$o1} )][ ]gs; $g =~ s[(?<=\|.{$o1} )\+(?= .{$o1}\|)] [|]gs; print $g; __END__ P:\test>345780 P P|B|R|B +-+ +-+ P|R|B B B -+ +---+ B|R R R|B | | B|R R R|B +---+-+ B|G G|B B
In reply to Re: Map grid to boundary conversion algorithm
by BrowserUk
in thread Map grid to boundary conversion algorithm
by Willard B. Trophy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |