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