Browse Source

Fix

master
Bastien 8 years ago
committed by Squiz
parent
commit
604f36930e
1 changed files with 17 additions and 5 deletions
  1. +17
    -5
      main.c

+ 17
- 5
main.c View File

@ -13,6 +13,7 @@ enum api_function_t {ia_lib_init, ia_start_match, ia_start_game, ia_end_game , i
struct player_state_t {
enum bool play;
unsigned int error;
void *ia_lib_p;
size_t pawn[10];
};
@ -76,7 +77,7 @@ void ia_call_function(const struct player_state_t player_state, enum api_functio
/* pour associer une branche de l'étoile à un joueur */
size_t star_branch(unsigned int nb_player, size_t index) {
return (nb_player>=2 && nb_player<=4 && index >= nb_player/2)?index-(nb_player>3?2:1)+3:index;
return ((nb_player%2 && index > nb_player/2) || (!(nb_player%2) && index >= nb_player/2) )?index-nb_player+(nb_player>3?nb_player>=6?2:1:0)+4:index;
}
int main(int argc, char** argv) {
@ -174,6 +175,7 @@ int main(int argc, char** argv) {
/* initialisation : on place les pions */
for( i=0 ; i < nb_player ; i++ ) {
player_state[i].play = true;
player_state[i].error = 0;
branch = star_branch(nb_player, i);
for( j=0 ; j < 10 ; j++ ) {
player_state[i].pawn[j] = start_position[branch][j];
@ -181,12 +183,22 @@ int main(int argc, char** argv) {
}
}
for(i=0;i<121; i++)
if(game_state.board[i])
printf("%d %d\n",i, game_state.board[i]);
for(i=0;i<121; i++)
if(game_state.board[i])
printf("%d %d\n",i, game_state.board[i]);
/* chaque joueur joue */
win = false;
i=0;
while(!win) {
++i;
i%=nb_player;
/* on demande un mouvement */
// TODO
/* on vérifie si le mouvement est valide */
/* on effectue le déplacement */
}
}


Loading…
Cancel
Save