|
|
@ -22,7 +22,7 @@ enum api_function_t {ia_lib_init, ia_start_match, ia_start_game, ia_end_game , i |
|
|
|
|
|
|
|
|
|
|
|
struct player_t { |
|
|
|
char *name; |
|
|
|
char name[50]; |
|
|
|
enum hole_t branch; |
|
|
|
unsigned int error; |
|
|
|
void *ia_lib_p; /* NULL si le joueur n'est pas une stratégie */ |
|
|
@ -302,7 +302,7 @@ int main(int argc, char** argv) { |
|
|
|
struct move_t movement, previous_movement; |
|
|
|
int first_move, next_move; |
|
|
|
int nb_game, nb_player, nb_game_end, nb_player_end; |
|
|
|
int i, j, k; |
|
|
|
int i, j; |
|
|
|
char *error; |
|
|
|
|
|
|
|
/* heure de début du match et tableaux pour stocker les gagnants et la durée des parties */ |
|
|
@ -338,12 +338,7 @@ int main(int argc, char** argv) { |
|
|
|
j = 3; |
|
|
|
for( i = 0; i < nb_player ; i++ ) { |
|
|
|
/* on prépare pour le nom */ |
|
|
|
if( (player_state[i].name = (char*) malloc(50*sizeof(char))) == NULL) { |
|
|
|
#ifdef debug |
|
|
|
fputs("malloc error\n", stderr); |
|
|
|
#endif |
|
|
|
return 6; |
|
|
|
} |
|
|
|
player_state[i].name[49] = '\0'; |
|
|
|
/* on choisit de placer un joueur réel ou une stratégie */ |
|
|
|
if( (rand()%(nb_player-i)) < (argc-j) ) { |
|
|
|
/* on ajoute une stratégie */ |
|
|
@ -359,7 +354,6 @@ int main(int argc, char** argv) { |
|
|
|
for( j=0 ; j<i ; j++ ) |
|
|
|
if( player_state[j].ia_lib_p ) |
|
|
|
dlclose(player_state[j].ia_lib_p); |
|
|
|
free(player_state[j].name); |
|
|
|
return 5; |
|
|
|
} else |
|
|
|
/* on initialise la bibliothèque */ |
|
|
@ -373,14 +367,12 @@ int main(int argc, char** argv) { |
|
|
|
player_state[i].ia_lib_p = NULL; |
|
|
|
} |
|
|
|
/* on vérifie le nom */ |
|
|
|
for(k = 0; k<50 && (player_state[i].name)[k] != '\0';k++); |
|
|
|
if(k==50) { |
|
|
|
if(player_state[i].name[49] != '\0') { |
|
|
|
#ifdef debug |
|
|
|
fprintf(stderr,"warning : the length of the player's name %d must be to 50 characters maximum.\n", i); |
|
|
|
fprintf(stderr,"warning : the length of the player's name %d must be to 49 characters maximum.\n", i); |
|
|
|
#endif |
|
|
|
(player_state[i].name)[49]='\0'; |
|
|
|
} else |
|
|
|
player_state[i].name = realloc(player_state[i].name, k+1); |
|
|
|
player_state[i].name[49] = '\0'; |
|
|
|
} |
|
|
|
|
|
|
|
#ifdef debug |
|
|
@ -539,7 +531,6 @@ int main(int argc, char** argv) { |
|
|
|
/* on décharge toutes les stratégies */ |
|
|
|
dlclose(player_state[i].ia_lib_p); |
|
|
|
} |
|
|
|
free(player_state[i].name); |
|
|
|
} |
|
|
|
|
|
|
|
/* on enregistre le résultat du jeu dans le fichier */ |
|
|
|