From 5dc9fe02aefc1e68f77140d0cf2200200eb950f6 Mon Sep 17 00:00:00 2001 From: "remi.greub" <remi.greub@hes-so.ch> Date: Mon, 31 Mar 2025 00:32:44 +0200 Subject: [PATCH] =?UTF-8?q?am=C3=A9lioration=20du=20smartbot=20en=20cas=20?= =?UTF-8?q?random=20+=20colonne=20pleine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- puissance4_GRB/puissance4.c | 11 +++++------ puissance4_GRB/puissance4.h | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/puissance4_GRB/puissance4.c b/puissance4_GRB/puissance4.c index 7f88800..2b77a4b 100644 --- a/puissance4_GRB/puissance4.c +++ b/puissance4_GRB/puissance4.c @@ -20,7 +20,6 @@ struct cell **Create_grid2D(){ //initialise les positions et les valeurs de base for(int i = 0; i<game.width; i++){ for(int j=0; j<game.height; j++){ - cells[i][j].pressed = false; cells[i][j].symbol = EMPTY; cells[i][j].i_pos = i; cells[i][j].j_pos = j; @@ -68,10 +67,6 @@ int kill_game(){ return EXIT_SUCCESS; } -/*void Show_grid(struct cell** cell){ - //return 0; -}*/ - int put_free_cell(int j_p, symbol_t symbol){ int i=0; @@ -314,7 +309,11 @@ int SmartBot(){ return chfr2; }else{ //3e cas : joue un coup au hasard - return rand()%game.width; + int randomchfr=0; + do{ + randomchfr = rand()%game.width; + }while((is_cell_free(randomchfr, 0, game.players[game.curr_player].symbol))<0); + return randomchfr; } } diff --git a/puissance4_GRB/puissance4.h b/puissance4_GRB/puissance4.h index 6ceb1a6..3f1ebe9 100644 --- a/puissance4_GRB/puissance4.h +++ b/puissance4_GRB/puissance4.h @@ -13,7 +13,6 @@ typedef enum{ }symbol_t; struct cell{ - bool pressed; symbol_t symbol; int i_pos; int j_pos; -- GitLab