|
|
|
@ -715,7 +715,6 @@ my ($pval, $called_player, $reason) = @_; # Arguments: (Value of all pieces of $ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub PROGRAM { |
|
|
|
|
my $sessid = $_[2]{'id'}; |
|
|
|
|
$user_mode = 0; |
|
|
|
|
# if (!defined($user_mode)) { |
|
|
|
|
# print 'Please input your side:', "\n"; |
|
|
|
@ -757,12 +756,12 @@ $user_mode = 0; |
|
|
|
|
($xrc, $yrc) = split //, $_[1]; |
|
|
|
|
$_[1] = join '.', $pxr{$xrc}, ($yrc-1); |
|
|
|
|
print $_[0], ' ', $_[1], "\n"; |
|
|
|
|
($prio, @id[0, 1], $selection, $ice, $n_o_selections) = &MOVEMENT_TREE($player, $depth, undef, undef, undef, undef, undef, $_[0], $_[1], $sessid); |
|
|
|
|
($prio, @id[0, 1], $selection, $ice, $n_o_selections) = &MOVEMENT_TREE($player, $depth, undef, undef, undef, undef, undef, $_[0], $_[1], $_[2]); |
|
|
|
|
print 'w ', $id[0], ' ', $id[1], "\n"; |
|
|
|
|
} else { |
|
|
|
|
$depth = 2; # Usually about 20^$depth possibilities (but ten times as much iterates for including no movement). |
|
|
|
|
($prio, @id[0, 1], $selection, $ice, $n_o_selections) = &MOVEMENT_TREE($player, $depth, undef, undef, undef, undef, undef, undef, undef, $sessid); |
|
|
|
|
$sth10->execute($sessid, @id[0, 1]); |
|
|
|
|
($prio, @id[0, 1], $selection, $ice, $n_o_selections) = &MOVEMENT_TREE($player, $depth, undef, undef, undef, undef, undef, undef, undef, $_[2]); |
|
|
|
|
$sth10->execute($_[2], @id[0, 1]); |
|
|
|
|
print 'b ', $id[0], ' ', $id[1], "\n"; |
|
|
|
|
} |
|
|
|
|
# print 'keys: ', scalar keys %key_list_by_value, "\n"; |
|
|
|
@ -934,7 +933,7 @@ get '/board/init' => sub { |
|
|
|
|
|
|
|
|
|
get '/move/:src/:dst' => sub { |
|
|
|
|
#if (session('init')) { |
|
|
|
|
my %diff = &PROGRAM(route_parameters->get('src'), route_parameters->get('dst'), session); # Includes player input. |
|
|
|
|
my %diff = &PROGRAM(route_parameters->get('src'), route_parameters->get('dst'), session->id); # Includes player input. |
|
|
|
|
encode_json(\%diff); |
|
|
|
|
#} |
|
|
|
|
}; |
|
|
|
@ -945,8 +944,6 @@ get '/' => sub { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#any ['get', 'post'] => '/' => sub { |
|
|
|
|
# my $session = session; # TODO: I only want %{session}{'id'}. |
|
|
|
|
# $session = %{$session}{'id'}; |
|
|
|
|
# $sth11->execute($session); |
|
|
|
|
#print $session, "\n"; |
|
|
|
|
# my @sth11 = $sth11->fetchrow_array(); |
|
|
|
|