Browse Source

Robustesse pour les appels aux fonctions de la stratégie

master
Bastien 8 years ago
committed by Squiz
parent
commit
961fb47ac4
1 changed files with 7 additions and 6 deletions
  1. +7
    -6
      main.c

+ 7
- 6
main.c View File

@ -237,11 +237,10 @@ int main(int argc, char **argv) {
dlsym(NULL,"");
dlerror();
for( i=0 ; i < nb_player ; i++ ) {
for( i=0 ; i < nb_player ; i++ )
/* appel de start_match pour les joueurs présents */
if( player_state[i].ia_lib_p )
ia_call_function(player_state[i], ia_start_match, NULL, nb_player, player_state[i].branch);
}
/* on note l'heure du début du jeu */
time_start_match = time(NULL);
@ -297,7 +296,7 @@ int main(int argc, char **argv) {
start_pos_first_move = -1;
game_state_ia_copy = game_state_copy;
/* si on a une stratégie */
if(player_state[i].ia_lib_p)
if( player_state[i].ia_lib_p )
ia_call_function(player_state[i], ia_next_move, &next_move, &game_state_ia_copy, first_move, &movement);
else
/* on a un joueur réel */
@ -341,7 +340,8 @@ int main(int argc, char **argv) {
k++;
}
} while(++j < 121 && k < 10);
ia_call_function(player_state[i], ia_end_game, NULL);
if( player_state[i].ia_lib_p )
ia_call_function(player_state[i], ia_end_game, NULL);
}
}
if(validation_movement == jump || validation_movement == neighbour_valid) {
@ -363,7 +363,8 @@ int main(int argc, char **argv) {
nb_player_end=nb_player /* la partie se termine */;
puts("le joueur a gagné");
winner_games[nb_game_end] = i;
ia_call_function(player_state[i], ia_end_game, NULL);
if( player_state[i].ia_lib_p )
ia_call_function(player_state[i], ia_end_game, NULL);
}
}
first_move=0;
@ -384,7 +385,7 @@ int main(int argc, char **argv) {
display_animsg(&gui_res, &game_state, player_state[i].branch, "Manche terminée", 1200);
/* pour les joueurs qui n'ont pas perdu */
for (i=0; i < nb_player ; i++)
if(player_state[i].error < 3)
if( player_state[i].error < 3 && player_state[i].ia_lib_p )
ia_call_function(player_state[i], ia_end_game, NULL);
duration_games[nb_game_end] = time(NULL) - duration_games[nb_game_end];


Loading…
Cancel
Save