From be74b9b64ff712b14e135e1c363fb1e03a080c8f Mon Sep 17 00:00:00 2001 From: fdai7775 Date: Fri, 2 Feb 2024 13:11:16 +0000 Subject: [PATCH] refactoring: reset_board --- src/main/c/GameTic_Tac_Toe/tictactoe.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/c/GameTic_Tac_Toe/tictactoe.c b/src/main/c/GameTic_Tac_Toe/tictactoe.c index 84a2430..e367101 100644 --- a/src/main/c/GameTic_Tac_Toe/tictactoe.c +++ b/src/main/c/GameTic_Tac_Toe/tictactoe.c @@ -9,9 +9,11 @@ const char PLAYER_X = 'X'; const char PLAYER_O = 'O'; void reset_board(){ - board[3][3] = {{'1', '2', '3'}, - {'4', '5', '6'}, - {'7', '8', '9'}}; + for(int i = 0; i < BOARD_SIZE; i++){ + for(int j = 0; j < BOARD_SIZE; y++){ + board[i][j] = j * BOARD_SIZE + i + 1; + } + } } // Funktionen zur Anzeige des Spielbretts