From 591f48344917aaeacf21f6a6746067e270df4dbd Mon Sep 17 00:00:00 2001
From: "remi.greub" <remi.greub@hes-so.ch>
Date: Tue, 25 Mar 2025 22:56:15 +0100
Subject: [PATCH] =?UTF-8?q?am=C3=A9lioration=20utilisation=20de=20structur?=
 =?UTF-8?q?e=20globale=20pour=20la=20gestion=20du=20puissance4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 puissance4_GRB/puissance4.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/puissance4_GRB/puissance4.c b/puissance4_GRB/puissance4.c
index b15968f..e0a5a95 100644
--- a/puissance4_GRB/puissance4.c
+++ b/puissance4_GRB/puissance4.c
@@ -2,22 +2,24 @@
 #include <stdint.h>
 #include <stdio.h>
 
+grid game;
+
 /***********************************
  * function     : Create_grid2D
- * arguments    : taille de grille (ex: 3 pour 3x3)
+ * arguments    : taille de grille hauteur x largeur
  *
  * return value : cell_t** -> la grille mise à jour et allouée
  * 		initialise les valeurs de la grille
  * 		et alloue la mémoire dynamiquement
  ***********************************/
-struct cell **Create_grid2D(uint8_t height, uint8_t width){
-	struct cell** cells = malloc(height*sizeof(struct cell));
-	for(int k =0; k<height; k++){
-		cells[k] = malloc(width*sizeof(struct cell));
+struct cell **Create_grid2D(){
+	struct cell** cells = malloc(game.height*sizeof(struct cell*));
+	for(int k =0; k<game.height; k++){
+		cells[k] = malloc(game.width*sizeof(struct cell));
 	}
 	//initialise les positions et les valeurs de base
-	for(int i = 0; i<height; i++){
-		for(int j=0; j<width; j++){
+	for(int i = 0; i<game.height; i++){
+		for(int j=0; j<game.width; j++){
 			cells[i][j].pressed = false;
 			cells[i][j].symbol = EMPTY;
 			cells[i][j].i_pos = i;
-- 
GitLab