From 128bfa21d26b2a424935637176d2be39bac6d918 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:19:55 +0100 Subject: [PATCH 01/45] Importiere wichtige Bibliotheken --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/main/c/VierGewinnt.c diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c new file mode 100644 index 0000000..cf058e3 --- /dev/null +++ b/src/main/c/VierGewinnt.c @@ -0,0 +1,3 @@ +//Importiere wichtige Bibliotheken +#include +#include From 0f92499ece4dfe239b70bface7b5477d33b8f222 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:20:41 +0100 Subject: [PATCH 02/45] =?UTF-8?q?Definiere=20Feldgr=C3=B6=C3=9Fe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index cf058e3..661ea87 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -1,3 +1,7 @@ //Importiere wichtige Bibliotheken #include #include + +//Definiere Feldgröße +#define ROWS 6 +#define COLS 7 From bf61a009911977c0148c6ec6d50b14de3011355e Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:21:21 +0100 Subject: [PATCH 03/45] Definiere Farben --- src/main/c/VierGewinnt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 661ea87..5d0a497 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -5,3 +5,14 @@ //Definiere Feldgröße #define ROWS 6 #define COLS 7 + +// Definiere Farben +#define RESET_COLOR "\033[0m" +#define BLACK "\033[0;30m" +#define RED "\033[0;31m" +#define GREEN "\033[0;32m" +#define YELLOW "\033[0;33m" +#define BLUE "\033[0;34m" +#define MAGENTA "\033[0;35m" +#define CYAN "\033[0;36m" +#define WHITE "\033[0;37m" From 107475af8f4a011a6093d1d55cbbac77ab42f1d9 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:22:18 +0100 Subject: [PATCH 04/45] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20initialize?= =?UTF-8?q?Board?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 5d0a497..d07efff 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -16,3 +16,7 @@ #define MAGENTA "\033[0;35m" #define CYAN "\033[0;36m" #define WHITE "\033[0;37m" + + +//Funktionsprototyp für initializeBoard +void initializeBoard(char board[ROWS][COLS]); From 7fe15fcedca072ba8e556e196c8351fc3d023198 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:23:13 +0100 Subject: [PATCH 05/45] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20printBoard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index d07efff..5a6ddb2 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -20,3 +20,6 @@ //Funktionsprototyp für initializeBoard void initializeBoard(char board[ROWS][COLS]); + +//Funktionsprototyp für printBoard +void printBoard(char board[ROWS][COLS]); From 99373604d53b7ee0b9ada1fad7fb325c05120ee8 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:24:00 +0100 Subject: [PATCH 06/45] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20clearScree?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 5a6ddb2..e4a5031 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -23,3 +23,6 @@ void initializeBoard(char board[ROWS][COLS]); //Funktionsprototyp für printBoard void printBoard(char board[ROWS][COLS]); + +// Funktionsprototyp für clearScreen +void clearScreen(); From f166bb60ff691bf47508fd569f667c07707c78ee Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:24:55 +0100 Subject: [PATCH 07/45] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20isColumnFu?= =?UTF-8?q?ll?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index e4a5031..bc8d922 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -26,3 +26,6 @@ void printBoard(char board[ROWS][COLS]); // Funktionsprototyp für clearScreen void clearScreen(); + +//Funktionsprototyp für isColumnFull +int isColumnFull(char board[ROWS][COLS], int col); From 4898e38878c5b0ab2aa8a6e0a3b150a48a2903bf Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:25:38 +0100 Subject: [PATCH 08/45] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20dropPiece?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index bc8d922..edcbe34 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -29,3 +29,7 @@ void clearScreen(); //Funktionsprototyp für isColumnFull int isColumnFull(char board[ROWS][COLS], int col); + +//Funktionsprototyp für dropPiece +int dropPiece(char board[ROWS][COLS], int col, char player); + From 399950a81b1e3632825e3bc19b761dcc349f0fd4 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:26:24 +0100 Subject: [PATCH 09/45] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20checkWin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index edcbe34..7139b27 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -32,4 +32,6 @@ int isColumnFull(char board[ROWS][COLS], int col); //Funktionsprototyp für dropPiece int dropPiece(char board[ROWS][COLS], int col, char player); +//Funktionsprototyp für checkWin +int checkWin(char board[ROWS][COLS], char player); From 8cd86a70242fde344826d673093bd2757905737a Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:27:10 +0100 Subject: [PATCH 10/45] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20checkHoriz?= =?UTF-8?q?ontal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 7139b27..3e60a29 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -34,4 +34,6 @@ int isColumnFull(char board[ROWS][COLS], int col); int dropPiece(char board[ROWS][COLS], int col, char player); //Funktionsprototyp für checkWin int checkWin(char board[ROWS][COLS], char player); +// Funktionsprototyp für checkHorizontal +int checkHorizontal(char board[ROWS][COLS], char player); From 9f9046af94507448f70496949d08a7670c128296 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:27:57 +0100 Subject: [PATCH 11/45] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20checkVerti?= =?UTF-8?q?cal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 3e60a29..dcb003d 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -37,3 +37,6 @@ int checkWin(char board[ROWS][COLS], char player); // Funktionsprototyp für checkHorizontal int checkHorizontal(char board[ROWS][COLS], char player); +// Funktionsprototyp für checkVertical +int checkVertical(char board[ROWS][COLS], char player); + From f3f300a91694b7abd02ff62442ab8a0248d1b312 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:29:00 +0100 Subject: [PATCH 12/45] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20checkDiago?= =?UTF-8?q?nalLR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index dcb003d..939c436 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -40,3 +40,6 @@ int checkHorizontal(char board[ROWS][COLS], char player); // Funktionsprototyp für checkVertical int checkVertical(char board[ROWS][COLS], char player); +// Funktionsprototyp für checkDiagonalLR +int checkDiagonalLR(char board[ROWS][COLS], char player); + From 1b3477fd2da316cfc538f874be2f5c90ef0d1709 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:30:22 +0100 Subject: [PATCH 13/45] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20checkDiago?= =?UTF-8?q?nalRL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 939c436..77795f7 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -43,3 +43,6 @@ int checkVertical(char board[ROWS][COLS], char player); // Funktionsprototyp für checkDiagonalLR int checkDiagonalLR(char board[ROWS][COLS], char player); +// Funktionsprototyp für checkDiagonalRL +int checkDiagonalRL(char board[ROWS][COLS], char player); + From 1e33053766e4e1d671672b625dde2147b9d0e979 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:31:02 +0100 Subject: [PATCH 14/45] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20showMessag?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 77795f7..4fdd8c3 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -46,3 +46,6 @@ int checkDiagonalLR(char board[ROWS][COLS], char player); // Funktionsprototyp für checkDiagonalRL int checkDiagonalRL(char board[ROWS][COLS], char player); +// Funktionsprototyp für showMessage +void showMessage(const char* messageColor, const char* message); + From 20b97fe1eaf62fc9c3a2c06d31a34b0e741a1f75 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:31:44 +0100 Subject: [PATCH 15/45] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20showInvali?= =?UTF-8?q?dInputMessage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 4fdd8c3..2a68a6e 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -48,4 +48,5 @@ int checkDiagonalRL(char board[ROWS][COLS], char player); // Funktionsprototyp für showMessage void showMessage(const char* messageColor, const char* message); - +//Funktionsprototyp für showInvalidInputMessage +void showInvalidInputMessage(); From 04ca12eff98fcff5aeae8a1616c259dbc71c7ed3 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:32:48 +0100 Subject: [PATCH 16/45] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20showColumn?= =?UTF-8?q?FullMessage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 2a68a6e..f77c5da 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -50,3 +50,6 @@ int checkDiagonalRL(char board[ROWS][COLS], char player); void showMessage(const char* messageColor, const char* message); //Funktionsprototyp für showInvalidInputMessage void showInvalidInputMessage(); + +//Funktionsprototyp für showColumnFullMessage +void showColumnFullMessage(); From fd012eff4f61d664856afb9cd3e983085915d300 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:33:37 +0100 Subject: [PATCH 17/45] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20showWinMes?= =?UTF-8?q?sage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index f77c5da..b1b9d51 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -53,3 +53,6 @@ void showInvalidInputMessage(); //Funktionsprototyp für showColumnFullMessage void showColumnFullMessage(); + +//Funktionsprototyp für showWinMessage +void showWinMessage(int player); From 1b57cd1dba5593247014c405ff77c7385a4cb26f Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:34:40 +0100 Subject: [PATCH 18/45] Write starter function --- src/main/c/VierGewinnt.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index b1b9d51..9108a58 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -56,3 +56,44 @@ void showColumnFullMessage(); //Funktionsprototyp für showWinMessage void showWinMessage(int player); + + +//Write starter function +int main_function() { + char board[ROWS][COLS]; + int currentPlayer = 1; // Spieler 1 beginnt + + initializeBoard(board); + printBoard(board); + + int column; + while (1) { + printf(YELLOW"Spieler %d, wähle eine Spalte (1-7): "RESET_COLOR, currentPlayer); + + scanf("%d", &column); + if (column < 1 || column > 7) { + showInvalidInputMessage(); + continue; + } + + column--; + + if (isColumnFull(board, column)) { + showColumnFullMessage(); + continue; + } + + if (dropPiece(board, column, (currentPlayer == 1) ? 'X' : 'O')) { + printBoard(board); + if (checkWin(board, (currentPlayer == 1) ? 'X' : 'O')) { + showWinMessage(currentPlayer); + break; + } + + currentPlayer = (currentPlayer == 1) ? 2 : 1; + } + } + + return 0; +} + From e5a065d12a668302ed7c0b3c214d8b77637e1cb5 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:35:23 +0100 Subject: [PATCH 19/45] Write initializeBoard function --- src/main/c/VierGewinnt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 9108a58..0b7b0c1 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -96,4 +96,11 @@ int main_function() { return 0; } - +// Write initializeBoard function +void initializeBoard(char board[ROWS][COLS]) { + for (int i = 0; i < ROWS; i++) { + for (int j = 0; j < COLS; j++) { + board[i][j] = ' '; + } + } +} From 177bf0211d8eb297697dbfb6c3b3fa79bf90b905 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:36:25 +0100 Subject: [PATCH 20/45] Write printBoard function --- src/main/c/VierGewinnt.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 0b7b0c1..7fde45c 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -104,3 +104,25 @@ void initializeBoard(char board[ROWS][COLS]) { } } } + + +// Write printBoard function +void printBoard(char board[ROWS][COLS]) { + clearScreen(); + printf("\n"); + + for (int i = 0; i < ROWS; i++) { + for (int j = 0; j < COLS; j++) { + printf("| %c ", board[i][j]); + } + printf("|\n"); + + for (int j = 0; j < COLS; j++) { + printf("----"); + } + printf("-\n"); + } + + printf(" 1 2 3 4 5 6 7\n\n"); +} + From e5e445ec0faa798ee505f7bcf35986a3b5f4785f Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:37:13 +0100 Subject: [PATCH 21/45] Write clearScreen function --- src/main/c/VierGewinnt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 7fde45c..043054e 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -125,4 +125,11 @@ void printBoard(char board[ROWS][COLS]) { printf(" 1 2 3 4 5 6 7\n\n"); } - +// Write clearScreen function +void clearScreen() { +#ifdef _WIN32 + system("cls"); +#else + system("clear"); +#endif +} From 7640258c05046740d35146998eeed2a8e3a883d7 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:37:48 +0100 Subject: [PATCH 22/45] Write isColumnFull function --- src/main/c/VierGewinnt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 043054e..000a60e 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -133,3 +133,8 @@ void clearScreen() { system("clear"); #endif } + +// Write isColumnFull function +int isColumnFull(char board[ROWS][COLS], int col) { + return (board[0][col] != ' '); +} From d796abbae3c3c296f25aaebe3d027a76fa341241 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:38:30 +0100 Subject: [PATCH 23/45] Write dropPiece function --- src/main/c/VierGewinnt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 000a60e..5959d98 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -138,3 +138,15 @@ void clearScreen() { int isColumnFull(char board[ROWS][COLS], int col) { return (board[0][col] != ' '); } + +//Write dropPiece function +int dropPiece(char board[ROWS][COLS], int col, char player) { + for (int i = ROWS - 1; i >= 0; i--) { + if (board[i][col] == ' ') { + board[i][col] = player; + return 1; + } + } + + return 0; // Column is full +} From 1e1e37b79180d2a17a6759aa9d6b2daae9542e04 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:39:09 +0100 Subject: [PATCH 24/45] Write checkHorizontal function --- src/main/c/VierGewinnt.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 5959d98..2ae4fc6 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -150,3 +150,19 @@ int dropPiece(char board[ROWS][COLS], int col, char player) { return 0; // Column is full } + + +// Write checkHorizontal function +int checkHorizontal(char board[ROWS][COLS], char player) { + for (int row = 0; row < ROWS; row++) { + for (int col = 0; col <= COLS - 4; col++) { + if (board[row][col] == player && + board[row][col + 1] == player && + board[row][col + 2] == player && + board[row][col + 3] == player) { + return 1; // Gewonnen + } + } + } + return 0; +} From 46f3cb93c69cfc7630e1ce3d8ce7fdf998a3af96 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:39:53 +0100 Subject: [PATCH 25/45] Write checkVertical function --- src/main/c/VierGewinnt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 2ae4fc6..9bcbac0 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -166,3 +166,18 @@ int checkHorizontal(char board[ROWS][COLS], char player) { } return 0; } + +//Write checkVertical function +int checkVertical(char board[ROWS][COLS], char player) { + for (int col = 0; col < COLS; col++) { + for (int row = 0; row <= ROWS - 4; row++) { + if (board[row][col] == player && + board[row + 1][col] == player && + board[row + 2][col] == player && + board[row + 3][col] == player) { + return 1; // Gewonnen + } + } + } + return 0; +} From 234b2bf10390c9fe6477f39d423d9ec6f514d46e Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:40:29 +0100 Subject: [PATCH 26/45] Write checkDiagonalLR function --- src/main/c/VierGewinnt.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 9bcbac0..fd18639 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -181,3 +181,27 @@ int checkVertical(char board[ROWS][COLS], char player) { } return 0; } + + + +// Write checkDiagonalLR function +int checkDiagonalLR(char board[ROWS][COLS], char player) { + for (int row = 0; row <= ROWS - 4; row++) { + for (int col = 0; col <= COLS - 4; col++) { + if (board[row][col] == player && + board[row + 1][col + 1] == player && + board[row + 2][col + 2] == player && + board[row + 3][col + 3] == player) { + return 1; // Gewonnen + } + } + } + return 0; +} + + + + + + + From 79e09720038332773849c206aafa833cc0e33bd7 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:41:14 +0100 Subject: [PATCH 27/45] Write checkDiagonalRL function --- src/main/c/VierGewinnt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index fd18639..d54a6bf 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -202,6 +202,21 @@ int checkDiagonalLR(char board[ROWS][COLS], char player) { +// Write checkDiagonalRL function +int checkDiagonalRL(char board[ROWS][COLS], char player) { + for (int row = 0; row <= ROWS - 4; row++) { + for (int col = 3; col < COLS; col++) { + if (board[row][col] == player && + board[row + 1][col - 1] == player && + board[row + 2][col - 2] == player && + board[row + 3][col - 3] == player) { + return 1; // Gewonnen + } + } + } + return 0; +} + From 095a9188c2b00c5e2ee91467825ce66a1e5ed21c Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:41:49 +0100 Subject: [PATCH 28/45] Write checkWin function --- src/main/c/VierGewinnt.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index d54a6bf..13b8674 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -215,6 +215,15 @@ int checkDiagonalRL(char board[ROWS][COLS], char player) { } } return 0; + +} + +// Write checkWin function +int checkWin(char board[ROWS][COLS], char player) { + return checkHorizontal(board, player) || + checkVertical(board, player) || + checkDiagonalLR(board, player) || + checkDiagonalRL(board, player); } From 20a83ac492fcc3713cc32cab71db4a3ef29059ea Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:42:23 +0100 Subject: [PATCH 29/45] Write showMessage function --- src/main/c/VierGewinnt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 13b8674..a1e92e3 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -227,5 +227,8 @@ int checkWin(char board[ROWS][COLS], char player) { } - +// Write showMessage function +void showMessage(const char* messageColor, const char* message) { + printf("%s%s"RESET_COLOR, messageColor, message); +} From 949cce4dc8ca1f0807bbd3d97af74c147ca815ec Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:43:04 +0100 Subject: [PATCH 30/45] Write showInvalidInputMessage function --- src/main/c/VierGewinnt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index a1e92e3..d9261e8 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -232,3 +232,7 @@ void showMessage(const char* messageColor, const char* message) { printf("%s%s"RESET_COLOR, messageColor, message); } +// Write showInvalidInputMessage function +void showInvalidInputMessage() { + showMessage(RED, "Ungültige Eingabe. Bitte wähle eine Spalte zwischen 1 und 7.\n"); +} From b3e4f6284788eb82c518a1d69708c9dce06c4d3b Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:43:42 +0100 Subject: [PATCH 31/45] Write showColumnFullMessage function --- src/main/c/VierGewinnt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index d9261e8..37d49cc 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -236,3 +236,14 @@ void showMessage(const char* messageColor, const char* message) { void showInvalidInputMessage() { showMessage(RED, "Ungültige Eingabe. Bitte wähle eine Spalte zwischen 1 und 7.\n"); } + + + + +// Write showColumnFullMessage function +void showColumnFullMessage() { + showMessage(RED, "Die Spalte ist voll. Bitte wähle eine andere.\n"); +} + + + From 8cf7073811eabff1b121d9b5e4dc0ca455fa2237 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:44:31 +0100 Subject: [PATCH 32/45] Write showWinMessage function} --- src/main/c/VierGewinnt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 37d49cc..c4d1419 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -247,3 +247,10 @@ void showColumnFullMessage() { +// Write showWinMessage function +void showWinMessage(int player) { + printf("Spieler %d hat gewonnen!\n", player); +} + + + From d7ea58f33a9145995d6b7e63e418759a63029313 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:46:40 +0100 Subject: [PATCH 33/45] add constants --- src/main/c/VierGewinnt.h | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/main/c/VierGewinnt.h diff --git a/src/main/c/VierGewinnt.h b/src/main/c/VierGewinnt.h new file mode 100644 index 0000000..6ec2043 --- /dev/null +++ b/src/main/c/VierGewinnt.h @@ -0,0 +1,5 @@ +#ifndef VIERGEWINNT_H +#define VIERGEWINNT_H + +#define ROWS 6 +#define COLS 7 From 4b61913ed74468c25733390daf6f5b2dc4a15542 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:47:16 +0100 Subject: [PATCH 34/45] define function --- src/main/c/VierGewinnt.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/c/VierGewinnt.h b/src/main/c/VierGewinnt.h index 6ec2043..a52d6cd 100644 --- a/src/main/c/VierGewinnt.h +++ b/src/main/c/VierGewinnt.h @@ -3,3 +3,17 @@ #define ROWS 6 #define COLS 7 + +void initializeBoard(char board[ROWS][COLS]); +void printBoard(char board[ROWS][COLS]); +int isColumnFull(char board[ROWS][COLS], int col); +int dropPiece(char board[ROWS][COLS], int col, char player); +int checkWin(char board[ROWS][COLS], char player); +int checkHorizontal(char board[ROWS][COLS], char player); +int checkVertical(char board[ROWS][COLS], char player); +int checkDiagonalLR(char board[ROWS][COLS], char player); +int checkDiagonalRL(char board[ROWS][COLS], char player); +void showMessage(const char* messageColor, const char* message); +void showInvalidInputMessage(); +void showColumnFullMessage(); +void showWinMessage(int player); From 7dd63bde307f30f32a705194115fcd611bb1c517 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:47:52 +0100 Subject: [PATCH 35/45] define function --- src/main/c/VierGewinnt.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/c/VierGewinnt.h b/src/main/c/VierGewinnt.h index a52d6cd..689034c 100644 --- a/src/main/c/VierGewinnt.h +++ b/src/main/c/VierGewinnt.h @@ -17,3 +17,4 @@ void showMessage(const char* messageColor, const char* message); void showInvalidInputMessage(); void showColumnFullMessage(); void showWinMessage(int player); +#endif From 7292f053a2be6851c30652da4819c29655afdba5 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:55:52 +0100 Subject: [PATCH 36/45] test_dropPiece_ValidMove --- src/test/c/test_VierGewinnt.c | 17 +++++++++++++++++ src/test/c/test_test.c | 28 ---------------------------- 2 files changed, 17 insertions(+), 28 deletions(-) create mode 100644 src/test/c/test_VierGewinnt.c delete mode 100644 src/test/c/test_test.c diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c new file mode 100644 index 0000000..4690b45 --- /dev/null +++ b/src/test/c/test_VierGewinnt.c @@ -0,0 +1,17 @@ +#include "unity.h" +#include "VierGewinnt.h" + +void setUp(void) { +} + +void tearDown(void) { +} + + +void test_dropPiece_ValidMove(void) { + char board[6][7]; + initializeBoard(board); + + TEST_ASSERT_EQUAL_INT(1, dropPiece(board, 3, 'X')); +} + diff --git a/src/test/c/test_test.c b/src/test/c/test_test.c deleted file mode 100644 index 4f61ea7..0000000 --- a/src/test/c/test_test.c +++ /dev/null @@ -1,28 +0,0 @@ -#ifdef TEST - -#include "unity.h" - -#include "test.h" - -void setUp(void) -{ -} - -void tearDown(void) -{ -} - -void test_test__return_5(void) -{ - /* arrange */ - int expected = 5; - int actual; - - /* act */ - actual = return_5(); - - /* assert */ - TEST_ASSERT_EQUAL_INT(expected, actual); -} - -#endif // TEST From 2824ad7a74355cb1b245558ab4d2691b3a2a2fc7 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:57:30 +0100 Subject: [PATCH 37/45] test_dropPiece_FullColum --- src/test/c/test_VierGewinnt.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index 4690b45..91bfaff 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -15,3 +15,16 @@ void test_dropPiece_ValidMove(void) { TEST_ASSERT_EQUAL_INT(1, dropPiece(board, 3, 'X')); } + +void test_dropPiece_FullColumn(void) { + char board[6][7] = { + {'X', 'O', 'X', 'O', 'X', 'O', 'X'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'}, + {'X', 'O', 'X', 'O', 'X', 'O', 'X'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'}, + {'X', 'O', 'X', 'O', 'X', 'O', 'X'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'} + }; + + TEST_ASSERT_EQUAL_INT(0, dropPiece(board, 3, 'X')); // Spalte ist voll, sollte 0 zurückgeben +} From 0b85b5496c1c8ad4f189b39e27223e6d253fb0a3 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:59:00 +0100 Subject: [PATCH 38/45] test_checkWin_Horizontal_X --- src/test/c/test_VierGewinnt.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index 91bfaff..8ad593b 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -28,3 +28,38 @@ void test_dropPiece_FullColumn(void) { TEST_ASSERT_EQUAL_INT(0, dropPiece(board, 3, 'X')); // Spalte ist voll, sollte 0 zurückgeben } + + +void test_checkWin_Horizontal_X(void) { + char board[6][7] = { + {'X', 'X', ' ', ' ', ' ', ' ', ' '}, + {'O', 'O', 'O', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', 'X', 'X', 'X', 'X', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '} + }; + + TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'X')); // Horizontale Gewinnsituation für 'X' +} + + + + + + + + + + + + + + + + + + + + + From 389ca705ed111104f02495bb9145727ff6bad3f4 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 01:00:24 +0100 Subject: [PATCH 39/45] test_checkWin_Horizontal_O --- src/test/c/test_VierGewinnt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index 8ad593b..f487364 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -43,7 +43,18 @@ void test_checkWin_Horizontal_X(void) { TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'X')); // Horizontale Gewinnsituation für 'X' } +void test_checkWin_Horizontal_O(void) { + char board[6][7] = { + {'X', 'X', ' ', ' ', ' ', ' ', ' '}, + {'O', 'O', 'O', 'O', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', 'X', 'X', ' ', 'X', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '} + }; + TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'O')); // Horizontale Gewinnsituation für 'X' +} From 3209502194d434c378be157aadc21d6e23703811 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 01:02:32 +0100 Subject: [PATCH 40/45] test_checkWin_Diagonal_X --- src/test/c/test_VierGewinnt.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index f487364..73f89e0 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -56,6 +56,19 @@ void test_checkWin_Horizontal_O(void) { TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'O')); // Horizontale Gewinnsituation für 'X' } +void test_checkWin_Diagonal_X(void) { + char board[6][7] = { + {'X', 'X', ' ', ' ', ' ', ' ', ' '}, + {'O', 'O', 'O', 'X', ' ', ' ', ' '}, + {' ', 'X', ' ', ' ', ' ', ' ', ' '}, + {' ', 'X', 'X', 'X', 'X', ' ', ' '}, + {' ', ' ', ' ','X', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', 'X', ' '} + }; + + TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'X')); // Horizontale Gewinnsituation für 'X' +} + From fe1df3e2224f7c86bdbc02576a17661fc9cbf3da Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 01:04:02 +0100 Subject: [PATCH 41/45] test_checkWin_Diagonal_O --- src/test/c/test_VierGewinnt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index 73f89e0..9681ea7 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -73,7 +73,18 @@ void test_checkWin_Diagonal_X(void) { +void test_checkWin_Diagonal_O(void) { + char board[6][7] = { + {'X', 'X', ' ', ' ', ' ', ' ', ' '}, + {'O', 'O', 'O', 'X', ' ', ' ', ' '}, + {' ', 'O', ' ', ' ', ' ', ' ', ' '}, + {' ', 'X', 'O', 'X', 'X', ' ', ' '}, + {' ', ' ', ' ','O', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', 'X', ' '} + }; + TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'O')); // Horizontale Gewinnsituation für 'X' +} From 8fa684587d69292a79be5d69aa0f03d20811e156 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 01:05:34 +0100 Subject: [PATCH 42/45] test_checkWin_Vertical_X --- src/test/c/test_VierGewinnt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index 9681ea7..6896efe 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -92,7 +92,18 @@ void test_checkWin_Diagonal_O(void) { +void test_checkWin_Vertical_X(void) { + char board[6][7] = { + {'X', 'O', ' ', ' ', ' ', ' ', ' '}, + {'X', 'O', ' ', ' ', ' ', ' ', ' '}, + {'X', 'O', ' ', ' ', ' ', ' ', ' '}, + {'X', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '} + }; + TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'X')); // Vertikale Gewinnsituation für 'X' +} From 00da72c029afbda55cd5631e055d797bb16a7ff2 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 01:07:26 +0100 Subject: [PATCH 43/45] test_checkWin_Vertical_O --- src/test/c/test_VierGewinnt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index 6896efe..6569d15 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -107,5 +107,16 @@ void test_checkWin_Vertical_X(void) { +void test_checkWin_Vertical_O(void) { + char board[6][7] = { + {'X', 'O', ' ', ' ', ' ', ' ', ' '}, + {'X', 'O', ' ', ' ', ' ', ' ', ' '}, + {'X', 'O', ' ', ' ', ' ', ' ', ' '}, + {' ', 'O', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '} + }; + TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'O')); // Vertikale Gewinnsituation für 'X' +} From 30327565fe7dc0ac2eb2463d9e9db1693f8c7061 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 01:12:14 +0100 Subject: [PATCH 44/45] test_checkWin_NoWinner --- src/test/c/test_VierGewinnt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index 6569d15..efe7a13 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -119,4 +119,19 @@ void test_checkWin_Vertical_O(void) { TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'O')); // Vertikale Gewinnsituation für 'X' } +void test_checkWin_NoWinner(void) { +char board[6][7] = { + {'X', 'O', 'X', 'O', 'X', 'O', 'X'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'}, + {'X', 'O', 'X', 'O', 'X', 'O', 'X'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'} + }; + + + + TEST_ASSERT_EQUAL_INT(0, checkWin(board, 'X')); // Kein Gewinner, horizontale Reihe ist voll + TEST_ASSERT_EQUAL_INT(0, checkWin(board, 'O')); // Kein Gewinner, horizontale Reihe ist voll +} From 46ae979f08ff3c39ead782c4187b01db9989c6c2 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 15:23:03 +0100 Subject: [PATCH 45/45] test_isColumnFull --- src/test/c/test_VierGewinnt.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index efe7a13..1f14b9f 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -135,3 +135,17 @@ char board[6][7] = { TEST_ASSERT_EQUAL_INT(0, checkWin(board, 'X')); // Kein Gewinner, horizontale Reihe ist voll TEST_ASSERT_EQUAL_INT(0, checkWin(board, 'O')); // Kein Gewinner, horizontale Reihe ist voll } + +void test_isColumnFull(void) { + char board[6][7] = { + {'X', 'O', 'X', 'O', 'X', 'O', 'X'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'}, + {'X', 'O', 'X', 'O', 'X', 'O', 'X'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'}, + {'X', 'O', 'X', 'O', 'X', 'O', 'X'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'} + }; + + TEST_ASSERT_EQUAL_INT(1, isColumnFull(board, 3)); // Column 3 is full +} +