ntvl.pl/LPST.pm - refactored the test board to be in notational evaluator. Added accessors for enums. wrote some functions for reading notation and determining whose move it is

This commit is contained in:
gashapwn 2021-04-07 14:40:39 +00:00
parent 2001529ded
commit 001ebf5c6d
2 changed files with 119 additions and 16 deletions

60
LPST.pm
View File

@ -727,6 +727,66 @@ sub new {
return bless $self, $class;
}
sub P1 {
return $P1;
}
sub P2 {
return $P2;
}
sub MG_A {
return $MG_A;
}
sub MG_I{
return $MG_I;
}
sub MG_N{
return $MG_N;
}
sub MG_IT{
return $MG_I;
}
sub MG_H{
return $MG_H;
}
sub MG_S{
return $MG_S;
}
sub MG_RC{
return $MG_RO;
}
sub MG_HS{
return $MG_H;
}
sub MG_RO{
return $MG_RC;
}
sub MG_B{
return $MG_B;
}
sub MG_P{
return $MG_P;
}
sub MG_IM{
return $MG_I;
}
sub MG_F{
return $MG_F;
}
sub MG_QS{
return $MG_QS;
}
sub MG_AU{
return $MG_A;
}
sub MG_SY{
return $MG_SY;
}
sub MG_Q{
return $MG_Q;
}
binmode(STDOUT, ":utf8");
return 1;

73
ntvl.pl
View File

@ -10,23 +10,66 @@ use LPST;
my $b;
# my $m1 = "F7";
# my $m1 = "C10";
# my $m2 = "B3";
# my $c1 = $MG_SY;
# my $c2 = $MG_A;
# Move types
my $SUMMON = 0b00000001;
my $MOVE = 0b00000010;
my $CAPTURE = 0b00000100;
my $SACRIFICE = 0b00001000;
# my $SPELL = 0b10000000;
my $DRAW = 0b01000000;
sub mt1($$){
my ($s0, $tc) = (shift, shift);
return $SUMMON if $s0 =~ /\*/;
return $MOVE if $s0 =~ /([A-Za-z]{1,2}[0-9]{1,2}){2}/;
return $CAPTURE if $s0 =~ /\~/;
return $SACRIFICE if $s0 =~ /([A-Za-z]{1,2}[0-9]{1,2}' ?){2}/;
return $DRAW if $tc <= 1;
}
sub f2($$$){
my ($s0, $tc, $apl) = (shift, shift, shift);
my $mt0;
$mt0 = mt1($s0, $tc);
}
sub f1($){
my $ns0 = shift;
my $apl;
my $tc;
$apl = LPST->P1;
$tc = 0;
for my $s0 (split(/\n/, $ns0)){
$apl = f2($s0, $tc, $apl);
# printf(">>%s\n", $s0);
$tc++;
}
}
my $ns0;
$ns0 = "";
$ns0 .= "A I It Au\n";
$ns0 .= "H S Im Im\n";
f1($ns0);
my $m1 = "C10";
my $m2 = "B3";
my $c1 = LPST->MG_SY;
my $c2 = LPST->MG_A;
# $b = LPST->new();
# $board{$m1} = $P1.$DIV.$c1;
# $board{$m2} = $P2.$DIV.$c2;
# for my $el (get_block_cell($P1)){
# printf("%s\n", $el);
# }
# shade_all_mvmt($P1);
# disp_board();
$b = LPST->new();
# $b->shade_all_p1_mvmt();
$b->disp_board();
# $b->disp_board();