From d23f4ebefc632ac47cca67de29166cf3571c3c4b Mon Sep 17 00:00:00 2001 From: Anthony <bouillant.anthony@gmail.com> Date: Fri, 4 Apr 2025 12:08:03 +0200 Subject: [PATCH] Function comments update: column index correction --- src/computer/computer.c | 4 ++-- src/computer/computer.h | 3 ++- src/game/game.h | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/computer/computer.c b/src/computer/computer.c index 1fd838a..2455012 100644 --- a/src/computer/computer.c +++ b/src/computer/computer.c @@ -57,9 +57,9 @@ int select_random_column(int number_of_columns, int number_of_rows, int** board) return robot_selected_column; } -bool is_column_full(int x, int rows, int** board) { +bool is_column_full(int col, int rows, int** board) { for (int i = 0; i < rows; i++) { - if (board[i][x] == EMPTY) { + if (board[i][col] == EMPTY) { return false; } } diff --git a/src/computer/computer.h b/src/computer/computer.h index 8d130c1..424c220 100644 --- a/src/computer/computer.h +++ b/src/computer/computer.h @@ -32,10 +32,11 @@ int select_smart_column(int number_of_columns, int number_of_rows, int** board); /** * @brief Checks whether a column is full (i.e., no empty slots). * - * @param col The column index to check. + * @param col The column index to check. starting from 0. * @param rows The number of rows in the board. * @param board The current game board. * @return true if the column is full, false otherwise. */ bool is_column_full(int col, int rows, int** board); + #endif diff --git a/src/game/game.h b/src/game/game.h index 4aed42d..41b0786 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -52,7 +52,7 @@ void place_token(int player, struct coordinate coordinate, int** board); /** * @brief Checks if the given column index is valid for the board. * - * @param column The column index to check: indexed from 1. + * @param column The column index to check. starting from 0. * @param col_count The total number of columns in the board. * @return true if the column index is valid, false otherwise. */ @@ -101,7 +101,7 @@ bool is_human_turn(enum GAME_MODE game_mode, int current_turn); int get_ai_move(enum GAME_MODE game_mode, int col_count, int row_count, int** board); /** - * @brief Gets column input from the player. + * @brief Gets column input from the player and adjusts for 0-based indexing. * * @return The column number entered by the player. */ -- GitLab