diff --git a/src/computer/computer.c b/src/computer/computer.c index 1fd838a96cff5e6123331ef5bb224a05c6db39a1..24550123ab97351b574b293e07b2d9a0397e6309 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 8d130c1c83614ce9836db00eac8c95030267ee20..424c22002889fc6c65045093b8d6296d2c88bd18 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 4aed42d9cf368a82676b5cb00aacbf9bdd991960..41b0786c46d4ce838ff50411a2896bb345cd4d64 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. */