lpst.pl - shade_cell handles movement patterns exceeding the bounds of the board
This commit is contained in:
parent
d05f746d64
commit
9e89588b7a
32
lpst.pl
32
lpst.pl
@ -173,7 +173,10 @@ my %MOVE = (
|
||||
[ 0,-4], [ 0,-3], [ 0, 3], [ 0, 4],
|
||||
[ 1, 2], [ 3,-2], [ 3,-3], [ 4,-4]
|
||||
]
|
||||
);
|
||||
);
|
||||
|
||||
my %BLOCK = (
|
||||
);
|
||||
|
||||
# Special cells
|
||||
my $EMPTY_CELL = "_";
|
||||
@ -191,6 +194,8 @@ my %SHADE = (
|
||||
$EMPTY_ENUM => [$HEX_1, $HEX_2, $HEX_3]
|
||||
);
|
||||
|
||||
my $ERR_C_1 = -1;
|
||||
|
||||
my %sc = ();
|
||||
my %board;
|
||||
|
||||
@ -457,7 +462,8 @@ sub apply_shift($$){
|
||||
|
||||
$r0 += $my_shift->[0];
|
||||
$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);
|
||||
}
|
||||
|
||||
@ -498,18 +504,23 @@ sub calc_move($$){
|
||||
sub shade_move($){
|
||||
my $not = shift;
|
||||
my $c1;
|
||||
my @mv1;
|
||||
my @mv2;
|
||||
|
||||
$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!
|
||||
binmode(STDOUT, ":utf8");
|
||||
|
||||
@ -525,7 +536,8 @@ binmode(STDOUT, ":utf8");
|
||||
$AXIS_RV{$_}
|
||||
}(1...11);
|
||||
|
||||
my $m1 = "F7";
|
||||
# my $m1 = "F7";
|
||||
my $m1 = "A1";
|
||||
my $c1 = $MG_QS;
|
||||
|
||||
$board{$m1} = $P1.$DIV.$c1;
|
||||
|
Loading…
Reference in New Issue
Block a user