lpst.pl - refactored whitespace. fixed col, row swap bug. time for bed

This commit is contained in:
gashapwn 2021-04-04 06:07:03 +00:00
parent 72d58c9d8a
commit 00b7fc7b84

130
lpst.pl
View File

@ -95,132 +95,66 @@ my %AXIS_RV = map {
my %MOVE = ( my %MOVE = (
$MG_A => [ $MG_A => [
[-1, 1], [-1, 1], [ 0, 1]
[ 0, 1]
], ],
$MG_Q => [ $MG_Q => [
[ 0, 1], [ 0, 1], [ 1, 0], [-1, 0], [ 0,-1],
[ 1, 0],
[-1, 0],
[ 0,-1],
], ],
$MG_I => [ $MG_I => [
[0,0] [0,0]
], ],
$MG_IT => [ $MG_IT => [
[ 0,-1], [ 0,-1], [ 1,-1]
[ 1,-1]
], ],
$MG_N => [ $MG_N => [
[-1, 2], [-1, 2],
[ 1,-2] [ 1,-2]
], ],
$MG_H => [ $MG_H => [
[-3, 2], [-3, 2], [-1,-2], [ 1, 2], [ 3,-2]
[-1,-2],
[ 1, 2],
[ 3,-2]
], ],
$MG_RC => [ $MG_RC => [
[-1, 0], [-1, 0], [-2, 0], [ 0, 1], [ 0, 2]
[-2, 0],
[ 0, 1],
[ 0, 2]
], ],
$MG_S => [ $MG_S => [
[-1, 1], [-1, 1], [-2, 2], [ 0, 1], [ 0, 2],
[-2, 2], [ 0,-1], [ 0,-2], [ 1,-1], [ 2,-2],
[ 0, 1],
[ 0, 2],
[ 0,-1],
[ 0,-2],
[ 1,-1],
[ 2,-2],
], ],
$MG_HS => [ $MG_HS => [
[-3, 1], [-3, 1], [-2,-1], [ 2, 1], [ 3,-1]
[-2,-1],
[ 2, 1],
[ 3,-1]
], ],
$MG_RO => [ $MG_RO => [
[-1, 1], [-1, 1], [ 0, 1], [ 1, 1], [ 1,-2]
[ 0, 1],
[ 1, 1],
[ 1,-2]
], ],
$MG_B => [ $MG_B => [
[-1, 1], [-1, 1], [ 0, 1], [ 0,-2], [ 1,-2]
[ 0, 1],
[ 0,-2],
[ 1,-2]
], ],
$MG_P => [ $MG_P => [
[-4, 2], [-4, 2], [-2, 1], [-2,-2], [-1,-1],
[-2, 1], [ 1, 1], [ 2,-1], [ 2, 2], [ 4,-2]
[-2,-2],
[-1,-1],
[ 1, 1],
[ 2,-1],
[ 2, 2],
[ 4,-2]
], ],
$MG_IM => [ $MG_IM => [
[-2, 1], [-2, 1], [-1,-1], [-1, 2], [ 1, 1],
[-1,-1], [ 1,-1], [ 1,-2], [ 2,-1]
[-1, 2],
[ 1, 1],
[ 1,-1],
[ 1,-2],
[ 2,-1]
], ],
$MG_F => [ $MG_F => [
[-1, 0], [-1, 0], [-1, 1], [ 0, 1], [ 0,-1],
[-1, 1], [ 1, 0], [ 1,-1]
[ 0, 1],
[ 0,-1],
[ 1, 0],
[ 1,-1]
], ],
$MG_QS => [ $MG_QS => [
[-3, 3], [-3, 3], [-2, 2], [-2, 0], [-1, 0],
[-2, 2], [-1, 1], [ 0, 1], [ 0, 2], [ 0, 3],
[-2, 0], [ 0,-1], [ 0,-2], [ 0,-3], [ 1, 0],
[-1, 0], [ 1,-1], [ 2, 0], [ 2,-2], [ 3,-3],
[-1, 1],
[ 0, 1],
[ 0, 2],
[ 0, 3],
[ 0,-1],
[ 0,-2],
[ 0,-3],
[ 1, 0],
[ 1,-1],
[ 2, 0],
[ 2,-2],
[ 3,-3],
], ],
$MG_AU => [ $MG_AU => [
[-1, 0], [-1, 0], [-1, 1], [ 0, 1], [ 0,-1],
[-1, 1], [ 1, 0], [ 1,-1]
[ 0, 1],
[ 0,-1],
[ 1, 0],
[ 1,-1]
], ],
$MG_SY => [ $MG_SY => [
[-4, 4], [-4, 4], [-3, 3], [-3, 2], [-1,-2],
[-3, 3], [ 0,-2], [ 0,-3], [ 0, 3], [ 0, 4],
[-3, 2], [ 1, 2], [ 3,-2], [ 3,-3], [ 4,-4]
[-1,-2],
[ 0,-2],
[ 0,-3],
[ 0, 3],
[ 0, 4],
[ 1, 2],
[ 3,-2],
[ 3,-3],
[ 4,-4]
] ]
); );
@ -459,20 +393,18 @@ sub calc_move($$){
my $n0; my $n0;
my $ni; my $ni;
($r0, $c0) = cell_index($not); ($c0, $r0) = cell_index($not);
# Calc y_shift # get y_shift
$y_shift = $mov->[1]; $y_shift = $mov->[1];
# Calc x_shift # get x_shift
$x_shift = $mov->[0]; $x_shift = $mov->[0];
# make adjustment # make x_shift adjustment
$ni = $y_shift != 0 ? ($y_shift / ($y_shift * -1)) : -1; $ni = $y_shift != 0 ? ($y_shift / ($y_shift * -1)) : -1;
$ni *= -1; $ni *= -1;
$n0 = ($r0 + 1) % 2; $n0 = ($r0 + 1) % 2;
$x_shift += int(($y_shift + ($n0 * $ni)) / 2); $x_shift += int(($y_shift + ($n0 * $ni)) / 2);
return apply_shift($not, [$x_shift, $y_shift]); return apply_shift($not, [$x_shift, $y_shift]);
@ -494,8 +426,8 @@ binmode(STDOUT, ":utf8");
$AXIS_RV{$_} $AXIS_RV{$_}
}(1...11); }(1...11);
my $m1 = "F4"; my $m1 = "E6";
my $c1 = $MG_QS; my $c1 = $MG_A;
$board{$m1} = $P1.$DIV.$c1; $board{$m1} = $P1.$DIV.$c1;