Browse Source

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

master
gashapwn 3 years ago
parent
commit
9e89588b7a
1 changed files with 22 additions and 10 deletions
  1. +22
    -10
      lpst.pl

+ 22
- 10
lpst.pl View File

@@ -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,17 +504,22 @@ 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);
}
}

# sub shade_block(){
@mv1 = @{$MOVE{$c1}};
@mv2 = grep {
$_ ne $ERR_C_1
} map {
calc_move($not, $_)
} @mv1;
# }

for my $mv (@mv2){
shade_cell($mv, $SHADE_1_ENUM);
}
}

# 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…
Cancel
Save