|
|
@ -222,10 +222,11 @@ enum bool valid_move(const struct move_t move, const struct move_t previous_move |
|
|
|
j = 0; |
|
|
|
do { |
|
|
|
if((dest = move_calculation(move.start_pos, j)) != -1) { |
|
|
|
printf("%d → %d (j=%d) ?\n", move.start_pos, move_calculation(move.start_pos,j),j); |
|
|
|
printf("%d → %d (j=%d) ?\n", move.start_pos, dest, j); |
|
|
|
switch(((dest == move.end_pos)?1:0)+((game.board[dest] == none)?2:0)) { |
|
|
|
case 0: /*on veut pas y aller mais la place est occupée. peut etre qu'on veut faire le saut */ |
|
|
|
if((dest2 = move_calculation(dest,j)) != -1) { |
|
|
|
printf("%d → %d (j=%d) ?\n", dest, dest2, j); |
|
|
|
switch(((dest2 == move.end_pos)?1:0)+((game.board[dest2] == none)?2:0)) { |
|
|
|
case 1: /* on veut y aller mais la place est occupée */ return false; |
|
|
|
case 3: /* on veut y aller et la place est libre */ return true; |
|
|
@ -397,7 +398,7 @@ int main(int argc, char** argv) { |
|
|
|
#endif |
|
|
|
/* on effectue le mouvement */ |
|
|
|
printf("(GUI) Moving pawn %d → hole %d\n", movement.start_pos, movement.end_pos); |
|
|
|
display_animove_pawn(gui_res, game_state, player_state[i].branch, movement.start_pos, movement.end_pos); |
|
|
|
display_animove_pawn(gui_res, game_state_copy, player_state[i].branch, movement.start_pos, movement.end_pos); |
|
|
|
game_state_copy.board[movement.start_pos]=none; |
|
|
|
game_state_copy.board[movement.end_pos]=player_state[i].branch; |
|
|
|
if(next_move) |
|
|
@ -405,7 +406,7 @@ int main(int argc, char** argv) { |
|
|
|
else { |
|
|
|
game_state=game_state_copy; /* commit */ |
|
|
|
if(winner(player_state[i], start_position, game_state)) { |
|
|
|
nb_player_end=nb_player-1 /* la partie se termine */; |
|
|
|
nb_player_end=nb_player /* la partie se termine */; |
|
|
|
puts("le joueur a gagné"); |
|
|
|
ia_call_function(player_state[i], ia_end_game, NULL); |
|
|
|
} |
|
|
@ -439,7 +440,7 @@ int main(int argc, char** argv) { |
|
|
|
/* pour les joueurs qui n'ont pas perdu */ |
|
|
|
for (i=0; i < nb_player ; i++) |
|
|
|
if(player_state[i].error < 3) |
|
|
|
ia_call_function(player_state[((++i)%nb_player)], ia_end_game, NULL); |
|
|
|
ia_call_function(player_state[i], ia_end_game, NULL); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|