lpst.pl - shade_cell handles movement patterns exceeding the bounds of the board

This commit is contained in:
gashapwn 2021-04-04 20:51:47 +00:00
parent d05f746d64
commit 9e89588b7a

32
lpst.pl
View File

@ -173,7 +173,10 @@ my %MOVE = (
[ 0,-4], [ 0,-3], [ 0, 3], [ 0, 4], [ 0,-4], [ 0,-3], [ 0, 3], [ 0, 4],
[ 1, 2], [ 3,-2], [ 3,-3], [ 4,-4] [ 1, 2], [ 3,-2], [ 3,-3], [ 4,-4]
] ]
); );
my %BLOCK = (
);
# Special cells # Special cells
my $EMPTY_CELL = "_"; my $EMPTY_CELL = "_";
@ -191,6 +194,8 @@ my %SHADE = (
$EMPTY_ENUM => [$HEX_1, $HEX_2, $HEX_3] $EMPTY_ENUM => [$HEX_1, $HEX_2, $HEX_3]
); );
my $ERR_C_1 = -1;
my %sc = (); my %sc = ();
my %board; my %board;
@ -457,7 +462,8 @@ sub apply_shift($$){
$r0 += $my_shift->[0]; $r0 += $my_shift->[0];
$c0 += $my_shift->[1]; $c0 += $my_shift->[1];
die "cell index [$r0, $c0]: out of bound exception" if $r0 > 11 or $c0 > 11 or $r0 < 1 or $c0 < 1; # die "cell index [$r0, $c0]: out of bound exception" if $r0 > 11 or $c0 > 11 or $r0 < 1 or $c0 < 1;
return $ERR_C_1 if $r0 > 11 or $c0 > 11 or $r0 < 1 or $c0 < 1;
return cell_index_rev($r0, $c0); return cell_index_rev($r0, $c0);
} }
@ -498,18 +504,23 @@ sub calc_move($$){
sub shade_move($){ sub shade_move($){
my $not = shift; my $not = shift;
my $c1; my $c1;
my @mv1;
my @mv2;
$c1 = cell_pi($not); $c1 = cell_pi($not);
for my $mv (@{$MOVE{$c1}}){
shade_cell(calc_move($not, $mv), $SHADE_1_ENUM); @mv1 = @{$MOVE{$c1}};
@mv2 = grep {
$_ ne $ERR_C_1
} map {
calc_move($not, $_)
} @mv1;
for my $mv (@mv2){
shade_cell($mv, $SHADE_1_ENUM);
} }
} }
# sub shade_block(){
# }
# Main starts here! # Main starts here!
binmode(STDOUT, ":utf8"); binmode(STDOUT, ":utf8");
@ -525,7 +536,8 @@ binmode(STDOUT, ":utf8");
$AXIS_RV{$_} $AXIS_RV{$_}
}(1...11); }(1...11);
my $m1 = "F7"; # my $m1 = "F7";
my $m1 = "A1";
my $c1 = $MG_QS; my $c1 = $MG_QS;
$board{$m1} = $P1.$DIV.$c1; $board{$m1} = $P1.$DIV.$c1;