Skip to content
Snippets Groups Projects
Commit 6e212a84 authored by remi.greub's avatar remi.greub
Browse files

dernieres corrections sur smartbot

parent fc0c4e1a
No related branches found
No related tags found
No related merge requests found
......@@ -358,6 +358,7 @@ int Launch_puissance4_smartBot(int seed){
int SmartBot(){
int pos=0;
int chfr1 = -1, chfr2 = -1;
for(int chfr=0; chfr<game.width; chfr++){
//verifie que le coup est jouable
if((pos = put_free_cell(chfr, game.players[game.curr_player].symbol))>=0){
......@@ -366,20 +367,26 @@ int SmartBot(){
if (Find_winner(game.cells, game.cells[chfr][pos]) == game.players[game.curr_player].symbol){
//1er cas : a trouvé le bon coup à jouer pour gagner
tempCell->symbol = EMPTY;
return chfr;
chfr1 = chfr;
}
//tente de chercher si l'autre joueur a un coup gagnant
tempCell->symbol = game.players[game.curr_player^1].symbol;
if (Find_winner(game.cells, game.cells[chfr][pos]) == game.players[game.curr_player^1].symbol){
//2e cas : joue le coup gagnant de l'autre joueur pour le bloquer
tempCell->symbol = EMPTY;
return chfr;
chfr2 = chfr;
}
tempCell->symbol = EMPTY;
}
}
//3e cas : joue un coup au hasard
return rand()%game.width;
if(chfr1 != -1){
return chfr1;
}else if(chfr2 != -1){
return chfr2;
}else{
//3e cas : joue un coup au hasard
return rand()%game.width;
}
}
bool Is_Grid_full(){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment