From 0f601c53bdb1f7db864b049a98e06e6b58bf964f Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:00:46 +0100 Subject: [PATCH 001/270] =?UTF-8?q?Commit=202=20-=20func=20Protokoll=20hin?= =?UTF-8?q?zuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index e2f3360..7bcb8a3 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -3,4 +3,8 @@ #include #include #include -#include \ No newline at end of file +#include + +void protokoll(); + +void protokoll(){} \ No newline at end of file From bde4a9ddd58c970c37b037a893000956fea155ec Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:01:27 +0100 Subject: [PATCH 002/270] =?UTF-8?q?Commit=203=20-=20func=20clearscreen=20h?= =?UTF-8?q?inzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 7bcb8a3..f04044a 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -6,5 +6,14 @@ #include void protokoll(); +void clear_screen(); -void protokoll(){} \ No newline at end of file +void protokoll(){ + clear_screen(); +} + +void clear_screen() { + system("clear"); + // system("cls"); // fuer Windows + // system("clear"); // fuer UNIX/Linux +} \ No newline at end of file From 5f115df6847ac96cd437d9084a74f420eb25241b Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:02:06 +0100 Subject: [PATCH 003/270] =?UTF-8?q?Commit=204=20-=20func=20willkomen=20hin?= =?UTF-8?q?zuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index f04044a..932b123 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -7,13 +7,19 @@ void protokoll(); void clear_screen(); +void willkommen(); void protokoll(){ clear_screen(); + willkommen(); } void clear_screen() { system("clear"); // system("cls"); // fuer Windows // system("clear"); // fuer UNIX/Linux +} + +void willkommen(){ + //Druecke Enter zun fortfahren } \ No newline at end of file From 9d644608cdc208bdf6dc673ef42710e22a823bc7 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:02:51 +0100 Subject: [PATCH 004/270] Commit 5 - func willkommen funktion einbauen --- src/main/c/hangman.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 932b123..11ab69d 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -21,5 +21,8 @@ void clear_screen() { } void willkommen(){ - //Druecke Enter zun fortfahren + char ENTERtxt[] = {"-Druecke ENTER zum starten-\n"}; + + printf("%s", ENTERtxt); + getchar(); } \ No newline at end of file From 414a018ea5c33a9a8d58064405c1ed22640a2eaf Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:03:21 +0100 Subject: [PATCH 005/270] Direction; change_direction N --> E --- src/main/c/global.h | 8 ++++++++ src/main/c/labyrinth.c | 14 ++++++++++++++ src/main/c/labyrinth.h | 8 ++++++++ src/main/c/test.c | 6 ------ src/main/c/test.h | 6 ------ src/test/c/support/.invis | 0 src/test/c/test_labyrinth.c | 27 +++++++++++++++++++++++++++ src/test/c/test_test.c | 28 ---------------------------- 8 files changed, 57 insertions(+), 40 deletions(-) create mode 100644 src/main/c/global.h create mode 100644 src/main/c/labyrinth.c create mode 100644 src/main/c/labyrinth.h delete mode 100644 src/main/c/test.c delete mode 100644 src/main/c/test.h delete mode 100644 src/test/c/support/.invis create mode 100644 src/test/c/test_labyrinth.c delete mode 100644 src/test/c/test_test.c diff --git a/src/main/c/global.h b/src/main/c/global.h new file mode 100644 index 0000000..b6aa8f0 --- /dev/null +++ b/src/main/c/global.h @@ -0,0 +1,8 @@ +#ifndef GLOBAL_H +#define GLOBAL_H + +typedef enum { + N, E, S, W +} Dir; + +#endif \ No newline at end of file diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c new file mode 100644 index 0000000..8067030 --- /dev/null +++ b/src/main/c/labyrinth.c @@ -0,0 +1,14 @@ +#include "labyrinth.h" + +#include "global.h" + +#include "stdio.h" +#include "stdlib.h" + +void change_direction(Dir *direction){ + switch (*direction) { + case N: + *direction = E; + break; + } +} diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h new file mode 100644 index 0000000..0ab2124 --- /dev/null +++ b/src/main/c/labyrinth.h @@ -0,0 +1,8 @@ +#ifndef TEST_H +#define TEST_H + +#include "global.h" + +void change_direction(Dir *direction); + +#endif // TEST_H diff --git a/src/main/c/test.c b/src/main/c/test.c deleted file mode 100644 index 52489ec..0000000 --- a/src/main/c/test.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "test.h" - -int return_5(){ - return 5; -} - diff --git a/src/main/c/test.h b/src/main/c/test.h deleted file mode 100644 index 4458e13..0000000 --- a/src/main/c/test.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef TEST_H -#define TEST_H - -int return_5(); - -#endif // TEST_H diff --git a/src/test/c/support/.invis b/src/test/c/support/.invis deleted file mode 100644 index e69de29..0000000 diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c new file mode 100644 index 0000000..9426c2c --- /dev/null +++ b/src/test/c/test_labyrinth.c @@ -0,0 +1,27 @@ +#include "unity.h" + +#include "stdlib.h" + +#include "labyrinth.h" + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + +void test_change_direction_from_N_expected_E(void) +{ + /* arrange */ + Dir actual = N; + Dir expected = E; + + /* act */ + change_direction(&actual); + + /* assert */ + TEST_ASSERT_TRUE(expected == actual); +} + 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 dd520029451a273a673366f951a48113a6a3df9c Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:05:36 +0100 Subject: [PATCH 006/270] =?UTF-8?q?Commit=206=20-=20func=20namepruefen=20e?= =?UTF-8?q?inf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 11ab69d..b013cca 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -8,10 +8,12 @@ void protokoll(); void clear_screen(); void willkommen(); +int namePruefen(); void protokoll(){ clear_screen(); willkommen(); + namePruefen(); } void clear_screen() { @@ -25,4 +27,32 @@ void willkommen(){ printf("%s", ENTERtxt); getchar(); +} + +int namePruefen() { + char KonfDatei[100]; + int laengeKonfDatei = 0; + + FILE *fp = NULL; + fp = fopen("hangman.txt", "r"); + + if (fp == NULL) { + printf("Fehler beim Öffnen der Konfigurationsdatei\n"); + return 1; + } else { + fscanf(fp, "%s", KonfDatei); //Inhalt der KonfDatei wird ins Array gelesen + + while(KonfDatei[laengeKonfDatei] != 0){ //Laenge der KonfDatei wird ermittelt + laengeKonfDatei++; + } + + if(laengeKonfDatei > 14){ //mit der Laenge wird geschaut, ob ein Name gespeichert ist oder nicht + fclose(fp); + return 0; + } else { + fclose(fp); + return 0; + } + } + fclose(fp); } \ No newline at end of file From adf66c53137f92c28a0ec7284b40ab4a619d171d Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:06:39 +0100 Subject: [PATCH 007/270] =?UTF-8?q?Commit=207=20-=20func=20namewahelen=20h?= =?UTF-8?q?inzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index b013cca..1263218 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -9,6 +9,7 @@ void protokoll(); void clear_screen(); void willkommen(); int namePruefen(); +void nameWaehlen(); void protokoll(){ clear_screen(); @@ -55,4 +56,23 @@ int namePruefen() { } } fclose(fp); +} + +void nameWaehlen(){ + char name[50]; + + FILE *fp = NULL; + fp = fopen("hangman.txt", "w"); + + clear_screen(); // + printf("Geben Sie den Namen ein: "); + scanf("%s", name); + + char KonfDatei[100]; + snprintf(KonfDatei, sizeof(KonfDatei), "name:%s,level:01", name); + + fprintf(fp, "%s", KonfDatei); + fclose(fp); + + startauswahl(); } \ No newline at end of file From a1603172fefda69d14d2a77627f843e571a66e54 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:07:51 +0100 Subject: [PATCH 008/270] Commit 8 - namewaehlen einbinden --- src/main/c/hangman.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 1263218..fe020bf 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -26,6 +26,7 @@ void clear_screen() { void willkommen(){ char ENTERtxt[] = {"-Druecke ENTER zum starten-\n"}; + printf("%s", ENTERtxt); getchar(); } @@ -51,6 +52,8 @@ int namePruefen() { fclose(fp); return 0; } else { + printf("Sieht aus, als haettest du noch keinen Namen :(\n"); + nameWaehlen(); fclose(fp); return 0; } @@ -65,6 +68,7 @@ void nameWaehlen(){ fp = fopen("hangman.txt", "w"); clear_screen(); // + printf("Geben Sie den Namen ein: "); scanf("%s", name); @@ -73,6 +77,4 @@ void nameWaehlen(){ fprintf(fp, "%s", KonfDatei); fclose(fp); - - startauswahl(); } \ No newline at end of file From 8308d24c85ce1d524584c87f86a465f7621b70b0 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:08:33 +0100 Subject: [PATCH 009/270] =?UTF-8?q?Commit=209=20-=20func=20startauswahl=20?= =?UTF-8?q?hinzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index fe020bf..f17a135 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -10,11 +10,13 @@ void clear_screen(); void willkommen(); int namePruefen(); void nameWaehlen(); +void startauswahl(); void protokoll(){ clear_screen(); willkommen(); namePruefen(); + startauswahl(); } void clear_screen() { @@ -77,4 +79,9 @@ void nameWaehlen(){ fprintf(fp, "%s", KonfDatei); fclose(fp); +} + +void startauswahl() { + printf("Willkommen "); + printf("[1] Spielen\n[2] Namen aendern\n"); } \ No newline at end of file From 8b45bc51ecefd0c079c7d44ff784f614f4e28ede Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:09:07 +0100 Subject: [PATCH 010/270] Commit 10 - Func startauswahl funktion einbauen --- src/main/c/hangman.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index f17a135..61763f7 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -82,6 +82,20 @@ void nameWaehlen(){ } void startauswahl() { + int auswahl; + int modus; + + clear_screen(); // + printf("Willkommen "); printf("[1] Spielen\n[2] Namen aendern\n"); + scanf("%d", &auswahl); + + if(auswahl == 1){ + //levelauswahl + } else if (auswahl == 2){ + nameWaehlen(); + } else { + printf("Eingabe ungueltig"); + } } \ No newline at end of file From e2eb6bcab96d9c53335a25bfab2cc70aab7293b7 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:09:52 +0100 Subject: [PATCH 011/270] =?UTF-8?q?Commit=2011=20-=20func=20nameausgeben?= =?UTF-8?q?=20f=C3=BCr=20func=20startauswahl=20einbauen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 61763f7..f89cc80 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -11,6 +11,7 @@ void willkommen(); int namePruefen(); void nameWaehlen(); void startauswahl(); +void nameAusgeben(); void protokoll(){ clear_screen(); @@ -98,4 +99,35 @@ void startauswahl() { } else { printf("Eingabe ungueltig"); } +} + +void nameAusgeben(){ + char KonfDatei[100]; + char name[50]; + int i = 5; + int zaehler = 0; + int nullt; + + FILE *fp = NULL; + fp = fopen("hangman.txt", "r"); + + fscanf(fp, "%s", KonfDatei); + while(KonfDatei[i] != ','){ + zaehler++; + i++; + } + nullt = zaehler; + while(zaehler != 0){ + name[--zaehler] = KonfDatei[--i]; + } + + i = 0; + while(name[i] != 0){ + i++; + } + + name[nullt] = '\0'; + printf("%s\n", name); + + fclose(fp); } \ No newline at end of file From a7023651e87b803a87273fc88bd78e70a9149999 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:10:35 +0100 Subject: [PATCH 012/270] =?UTF-8?q?Commit=2012=20-=20func=20nameausgeben?= =?UTF-8?q?=20in=20func=20startauswahl=20einf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index f89cc80..64f828a 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -89,6 +89,7 @@ void startauswahl() { clear_screen(); // printf("Willkommen "); + nameAusgeben(); printf("[1] Spielen\n[2] Namen aendern\n"); scanf("%d", &auswahl); From eaf67504f0a7f6542dd27f31fe6cf8d107f69a57 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:11:16 +0100 Subject: [PATCH 013/270] Commit 13 - func levelauswahl erstellen --- src/main/c/hangman.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 64f828a..c5f8452 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -12,6 +12,7 @@ int namePruefen(); void nameWaehlen(); void startauswahl(); void nameAusgeben(); +void levelauswahl(); void protokoll(){ clear_screen(); @@ -87,7 +88,7 @@ void startauswahl() { int modus; clear_screen(); // - + printf("Willkommen "); nameAusgeben(); printf("[1] Spielen\n[2] Namen aendern\n"); @@ -130,5 +131,30 @@ void nameAusgeben(){ name[nullt] = '\0'; printf("%s\n", name); + fclose(fp); +} + +void levelauswahl(){ + char levelstr[3]; + char KonfDatei[100]; + int level; + int i = 0; + + clear_screen(); // + + + FILE *fp = NULL; + fp = fopen("hangman.txt", "r"); + + fscanf(fp, "%s", KonfDatei); + while(KonfDatei[i] != 0){ + i++; + } + levelstr[0] = KonfDatei[i-2]; + levelstr[1] = KonfDatei[i-1]; + levelstr[2] = '\0'; + level = atoi(levelstr); + //hauptspiel mit dem Level starten + fclose(fp); } \ No newline at end of file From 17dd3fd25486f350b25cadbaa389492b3d3fa1f5 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:12:44 +0100 Subject: [PATCH 014/270] refactoring: change_direction --- src/main/c/global.h | 2 +- src/main/c/labyrinth.c | 2 +- src/main/c/labyrinth.h | 2 +- src/test/c/test_labyrinth.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/c/global.h b/src/main/c/global.h index b6aa8f0..556a1f1 100644 --- a/src/main/c/global.h +++ b/src/main/c/global.h @@ -3,6 +3,6 @@ typedef enum { N, E, S, W -} Dir; +} Direction; #endif \ No newline at end of file diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 8067030..980b367 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -5,7 +5,7 @@ #include "stdio.h" #include "stdlib.h" -void change_direction(Dir *direction){ +void turn_direction_right(Direction *direction){ switch (*direction) { case N: *direction = E; diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index 0ab2124..4c077e9 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -3,6 +3,6 @@ #include "global.h" -void change_direction(Dir *direction); +void turn_direction_right(Direction *direction); #endif // TEST_H diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 9426c2c..a31da00 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -15,11 +15,11 @@ void tearDown(void) void test_change_direction_from_N_expected_E(void) { /* arrange */ - Dir actual = N; - Dir expected = E; + Direction actual = N; + Direction expected = E; /* act */ - change_direction(&actual); + turn_direction_right(&actual); /* assert */ TEST_ASSERT_TRUE(expected == actual); From 603769c08a68decfbb782a10bd056b803d11766e Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:14:53 +0100 Subject: [PATCH 015/270] change direction right E --> S --- src/main/c/labyrinth.c | 3 +++ src/test/c/test_labyrinth.c | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 980b367..adaaab5 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -10,5 +10,8 @@ void turn_direction_right(Direction *direction){ case N: *direction = E; break; + case E: + *direction = S; + break; } } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index a31da00..563d886 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -25,3 +25,15 @@ void test_change_direction_from_N_expected_E(void) TEST_ASSERT_TRUE(expected == actual); } +void test_turn_direction_right_from_E_expected_S(void) +{ + /* arrange */ + Direction actual = E; + Direction expected = S; + + /* act */ + turn_direction_right(&actual); + + /* assert */ + TEST_ASSERT_TRUE(expected == actual); +} From 9d4ba68d90b8769545b464d77ea290e453bf1f1f Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:16:33 +0100 Subject: [PATCH 016/270] change direction right S --> W --- src/main/c/labyrinth.c | 3 +++ src/test/c/test_labyrinth.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index adaaab5..d53c95b 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -13,5 +13,8 @@ void turn_direction_right(Direction *direction){ case E: *direction = S; break; + case S: + *direction = W; + break; } } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 563d886..555736d 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -37,3 +37,17 @@ void test_turn_direction_right_from_E_expected_S(void) /* assert */ TEST_ASSERT_TRUE(expected == actual); } + +void test_turn_direction_right_from_S_expected_W(void) +{ + /* arrange */ + Direction actual = S; + Direction expected = W; + + /* act */ + turn_direction_right(&actual); + + /* assert */ + TEST_ASSERT_TRUE(expected == actual); +} + From fad2f3430dfd7cd1bf3e049202596074a9281054 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:18:08 +0100 Subject: [PATCH 017/270] turn_direction_right W --> N --- src/main/c/labyrinth.c | 3 +++ src/test/c/test_labyrinth.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index d53c95b..a76a53b 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -16,5 +16,8 @@ void turn_direction_right(Direction *direction){ case S: *direction = W; break; + case W: + *direction = N; + break; } } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 555736d..e257b07 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -51,3 +51,16 @@ void test_turn_direction_right_from_S_expected_W(void) TEST_ASSERT_TRUE(expected == actual); } +void test_turn_direction_right_from_W_expected_N(void) +{ + /* arrange */ + Direction actual = W; + Direction expected = N; + + /* act */ + turn_direction_right(&actual); + + /* assert */ + TEST_ASSERT_TRUE(expected == actual); +} + From c8feba1040dacf97de11c14b989becc0c27448c9 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:20:32 +0100 Subject: [PATCH 018/270] move north set x 0 --- src/main/c/labyrinth.c | 10 ++++++++++ src/main/c/labyrinth.h | 1 + src/test/c/test_labyrinth.c | 17 +++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index a76a53b..89227c3 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -21,3 +21,13 @@ void turn_direction_right(Direction *direction){ break; } } + +void move(unsigned short *x, unsigned short *y, Direction direction){ + + if (direction == N){ + *x = 0; + return; + } + +} + diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index 4c077e9..402e915 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -4,5 +4,6 @@ #include "global.h" void turn_direction_right(Direction *direction); +void move(unsigned short *x, unsigned short *y, Direction direction); #endif // TEST_H diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index e257b07..5e63380 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -64,3 +64,20 @@ void test_turn_direction_right_from_W_expected_N(void) TEST_ASSERT_TRUE(expected == actual); } +void test_lab_move_from_1_1_N_expected_0_1(void) +{ + /* arrange */ + unsigned short x = 1; + unsigned short y = 1; + Direction direction = N; + + unsigned short x_expected = 0; + unsigned short y_expected = 1; + + /* act */ + move(&x, &y, direction); + + /* assert */ + TEST_ASSERT_TRUE(x == x_expected && y == y_expected); +} + From cdb61e6e7b93011fc423d3baec9f853d939e82ef Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:21:14 +0100 Subject: [PATCH 019/270] =?UTF-8?q?Commit=2014=20-=20func=20levelauswahl?= =?UTF-8?q?=20in=20func=20startauswahl=20einf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index c5f8452..6454af6 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -30,7 +30,7 @@ void clear_screen() { void willkommen(){ char ENTERtxt[] = {"-Druecke ENTER zum starten-\n"}; - + printf("%s", ENTERtxt); getchar(); } @@ -72,7 +72,7 @@ void nameWaehlen(){ fp = fopen("hangman.txt", "w"); clear_screen(); // - + printf("Geben Sie den Namen ein: "); scanf("%s", name); @@ -95,7 +95,7 @@ void startauswahl() { scanf("%d", &auswahl); if(auswahl == 1){ - //levelauswahl + levelauswahl(); } else if (auswahl == 2){ nameWaehlen(); } else { @@ -155,6 +155,5 @@ void levelauswahl(){ levelstr[2] = '\0'; level = atoi(levelstr); //hauptspiel mit dem Level starten - fclose(fp); } \ No newline at end of file From 2a4b49f8a12ec8a907dc26c1e267980f3ce8e71c Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:21:58 +0100 Subject: [PATCH 020/270] Commit 15 - func hauptspiel erstellen --- src/main/c/hangman.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 6454af6..446fa7a 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -13,6 +13,7 @@ void nameWaehlen(); void startauswahl(); void nameAusgeben(); void levelauswahl(); +void hauptSpiel(int level); void protokoll(){ clear_screen(); @@ -156,4 +157,21 @@ void levelauswahl(){ level = atoi(levelstr); //hauptspiel mit dem Level starten fclose(fp); +} + +void hauptSpiel(int level){ + char secret_word[100]; + int attempts = 0; + char guessed_letter; + char guessed_letters[100]; + char path[] = "hangman_words.txt"; + int result; + int won = 0; + //secret_word soll vergeben werden + //secret_word soll geladen werden + //path soll erstellt werden + //hangman soll gemalt werden + //Buchstaben sollen gezeigt werden + //Buchstaben sollen eingegeben werden können + //eingegeben Buchstaben sollen überprüft und dem Lösungswort hinzugefügt werden, damit Gewinn ermittelt werden kann } \ No newline at end of file From 2cb16c70024b9f2f1a30a13f46348e5f4ec9e031 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:23:00 +0100 Subject: [PATCH 021/270] =?UTF-8?q?Commit=2016=20-=20func=20hangman=20soll?= =?UTF-8?q?=20gezeichnet=20werden=20k=C3=B6nnen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 75 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 446fa7a..847a301 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -14,6 +14,7 @@ void startauswahl(); void nameAusgeben(); void levelauswahl(); void hauptSpiel(int level); +void draw_hangman(int attempts); void protokoll(){ clear_screen(); @@ -174,4 +175,78 @@ void hauptSpiel(int level){ //Buchstaben sollen gezeigt werden //Buchstaben sollen eingegeben werden können //eingegeben Buchstaben sollen überprüft und dem Lösungswort hinzugefügt werden, damit Gewinn ermittelt werden kann +} + +void draw_hangman(int attempts) { + clear_screen(); + printf("Galgenmann!\n"); + printf("v.1.0.2\n\n"); + + switch(attempts) { + case 0: + printf(" _______\n"); + printf(" | |\n"); + printf(" |\n"); + printf(" |\n"); + printf(" |\n"); + printf(" |\n"); + printf("__|_________\n\n\n\n"); + break; + case 1: + printf(" _______\n"); + printf(" | |\n"); + printf(" | O\n"); + printf(" |\n"); + printf(" |\n"); + printf(" |\n"); + printf("__|_________\n\n\n\n"); + break; + case 2: + printf(" _______\n"); + printf(" | |\n"); + printf(" | O\n"); + printf(" | |\n"); + printf(" |\n"); + printf(" |\n"); + printf("__|_________\n\n\n\n"); + break; + case 3: + printf(" _______\n"); + printf(" | |\n"); + printf(" | O\n"); + printf(" | /|\n"); + printf(" |\n"); + printf(" |\n"); + printf("__|_________\n\n\n\n"); + break; + case 4: + printf(" _______\n"); + printf(" | |\n"); + printf(" | O\n"); + printf(" | /|\\\n"); + printf(" |\n"); + printf(" |\n"); + printf("__|_________\n\n\n\n"); + break; + case 5: + printf(" _______\n"); + printf(" | |\n"); + printf(" | O\n"); + printf(" | /|\\\n"); + printf(" | /\n"); + printf(" |\n"); + printf("__|_________\n\n\n\n"); + break; + case 6: + printf(" _______\n"); + printf(" | |\n"); + printf(" | O\n"); + printf(" | /|\\\n"); + printf(" | / \\\n"); + printf(" |\n"); + printf("__|_________\n\n\n\n"); + break; + default: + break; + } } \ No newline at end of file From eef1885341c7fe5aa7fef2aa9999bed7098f6fb2 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:24:06 +0100 Subject: [PATCH 022/270] =?UTF-8?q?Commit=2017=20-=20jeder=20eingegebene?= =?UTF-8?q?=20Buchstabe=20soll=20dem=20Array=20aller=20eingegebenen=20Buch?= =?UTF-8?q?staben=20hinzugef=C3=BCgt=20werden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 847a301..4a8045d 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -15,6 +15,7 @@ void nameAusgeben(); void levelauswahl(); void hauptSpiel(int level); void draw_hangman(int attempts); +void add_guessed_letter(char* guessed_letters, char guessed_letter); void protokoll(){ clear_screen(); @@ -249,4 +250,12 @@ void draw_hangman(int attempts) { default: break; } +} + +void add_guessed_letter(char* guessed_letters, char guessed_letter){ + for (int i = 0; i < strlen(guessed_letters); i++){ + if (guessed_letters[i] == guessed_letter){ + return; + } + } } \ No newline at end of file From acff3629568741492c0ce4533fef963453f315e1 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:25:15 +0100 Subject: [PATCH 023/270] Commit 18 - Erweiterung der Funktion add_guessed_letter --- src/main/c/hangman.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 4a8045d..dd978ec 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -258,4 +258,6 @@ void add_guessed_letter(char* guessed_letters, char guessed_letter){ return; } } + guessed_letters[strlen(guessed_letters)] = guessed_letter; + guessed_letters[strlen(guessed_letters) + 1] = '\0'; } \ No newline at end of file From 1e2edfd89df4737a6bf0360c5ea3e14cd899f612 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:21:43 +0100 Subject: [PATCH 024/270] refactoring: move --> lab_move --- src/main/c/labyrinth.c | 2 +- src/main/c/labyrinth.h | 2 +- src/test/c/test_labyrinth.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 89227c3..d4cec1d 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -22,7 +22,7 @@ void turn_direction_right(Direction *direction){ } } -void move(unsigned short *x, unsigned short *y, Direction direction){ +void lab_move(unsigned short *x, unsigned short *y, Direction direction){ if (direction == N){ *x = 0; diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index 402e915..3bd9821 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -4,6 +4,6 @@ #include "global.h" void turn_direction_right(Direction *direction); -void move(unsigned short *x, unsigned short *y, Direction direction); +void lab_move(unsigned short *x, unsigned short *y, Direction direction); #endif // TEST_H diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 5e63380..5233c20 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -75,7 +75,7 @@ void test_lab_move_from_1_1_N_expected_0_1(void) unsigned short y_expected = 1; /* act */ - move(&x, &y, direction); + lab_move(&x, &y, direction); /* assert */ TEST_ASSERT_TRUE(x == x_expected && y == y_expected); From 82b77097a0a00369ed2cf86f05faa30f4829a120 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:26:26 +0100 Subject: [PATCH 025/270] =?UTF-8?q?Commit=2019=20-=20eingabe=20eines=20Buc?= =?UTF-8?q?hstaben=20in=20die=20func=20Hauptspiel=20soll=20erm=C3=B6glicht?= =?UTF-8?q?=20werden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index dd978ec..bec8f47 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -16,6 +16,7 @@ void levelauswahl(); void hauptSpiel(int level); void draw_hangman(int attempts); void add_guessed_letter(char* guessed_letters, char guessed_letter); +char eingabe_buchstabe(); void protokoll(){ clear_screen(); @@ -260,4 +261,11 @@ void add_guessed_letter(char* guessed_letters, char guessed_letter){ } guessed_letters[strlen(guessed_letters)] = guessed_letter; guessed_letters[strlen(guessed_letters) + 1] = '\0'; +} + +char eingabe_buchstabe(){ + char guess; + scanf(" %c", &guess); + guess = tolower(guess); + return guess; } \ No newline at end of file From 6bc8c8dfc5de732ba69fc167cc81d1495a3ac7fa Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:28:30 +0100 Subject: [PATCH 026/270] Commit 20 - func lade secret_word zum laden des wortes soll erstellt werden --- src/main/c/hangman.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index bec8f47..93892bb 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -17,6 +17,7 @@ void hauptSpiel(int level); void draw_hangman(int attempts); void add_guessed_letter(char* guessed_letters, char guessed_letter); char eingabe_buchstabe(); +void lade_secret_word(char* secret_word, int level, char* path); void protokoll(){ clear_screen(); @@ -268,4 +269,27 @@ char eingabe_buchstabe(){ scanf(" %c", &guess); guess = tolower(guess); return guess; +} + +void lade_secret_word(char* secret_word, int level, char* path){ + FILE *file = fopen(path, "r"); + int count = 0; + if ( file != NULL ) + { + char line[100]; /* or other suitable maximum line size */ + while (fgets(line, sizeof line, file) != NULL) /* read a line */ + { + if (count == level) + { + strcpy(secret_word, line); + secret_word[strlen(secret_word) - 1] = '\0'; + return; + } + else + { + count++; + } + } + fclose(file); + } } \ No newline at end of file From 7c440691530fa95f8c8c89c2a776664671e3baeb Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:33:10 +0100 Subject: [PATCH 027/270] lab move N --> x - 1 --- src/main/c/labyrinth.c | 2 +- src/test/c/test_labyrinth.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index d4cec1d..5b18703 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -25,7 +25,7 @@ void turn_direction_right(Direction *direction){ void lab_move(unsigned short *x, unsigned short *y, Direction direction){ if (direction == N){ - *x = 0; + *x = *x - 1; return; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 5233c20..022c2e8 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -81,3 +81,20 @@ void test_lab_move_from_1_1_N_expected_0_1(void) TEST_ASSERT_TRUE(x == x_expected && y == y_expected); } +void test_lab_move_from_5_5_N_expected_4_5(void) +{ + /* arrange */ + unsigned short x = 5; + unsigned short y = 5; + Direction direction = N; + + unsigned short x_expected = 4; + unsigned short y_expected = 5; + + /* act */ + lab_move(&x, &y, direction); + + /* assert */ + TEST_ASSERT_TRUE(x == x_expected && y == y_expected); +} + From eb2b6fc6d57a42f5baaf266e9dda4c534c175e50 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:34:30 +0100 Subject: [PATCH 028/270] lab_move direction E --> y = 2 --- src/main/c/labyrinth.c | 4 ++++ src/test/c/test_labyrinth.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 5b18703..2575180 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -28,6 +28,10 @@ void lab_move(unsigned short *x, unsigned short *y, Direction direction){ *x = *x - 1; return; } + if (direction == E){ + *y = 2; + return; + } } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 022c2e8..85ad115 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -98,3 +98,20 @@ void test_lab_move_from_5_5_N_expected_4_5(void) TEST_ASSERT_TRUE(x == x_expected && y == y_expected); } +void test_lab_move_from_1_1_E_expected_1_2(void) +{ + /* arrange */ + unsigned short x = 1; + unsigned short y = 1; + Direction direction = E; + + unsigned short x_expected = 1; + unsigned short y_expected = 2; + + /* act */ + lab_move(&x, &y, direction); + + /* assert */ + TEST_ASSERT_TRUE(x == x_expected && y == y_expected); +} + From ccf6661ffd9764ef9f26339554a782fa5cc5886d Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:35:38 +0100 Subject: [PATCH 029/270] lab_move direction East y --> y + 1 --- src/main/c/labyrinth.c | 2 +- src/test/c/test_labyrinth.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 2575180..2ac9193 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -29,7 +29,7 @@ void lab_move(unsigned short *x, unsigned short *y, Direction direction){ return; } if (direction == E){ - *y = 2; + *y = *y + 1; return; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 85ad115..9599c01 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -115,3 +115,20 @@ void test_lab_move_from_1_1_E_expected_1_2(void) TEST_ASSERT_TRUE(x == x_expected && y == y_expected); } +void test_lab_move_from_5_5_E_expected_5_6(void) +{ + /* arrange */ + unsigned short x = 5; + unsigned short y = 5; + Direction direction = E; + + unsigned short x_expected = 5; + unsigned short y_expected = 6; + + /* act */ + lab_move(&x, &y, direction); + + /* assert */ + TEST_ASSERT_TRUE(x == x_expected && y == y_expected); +} + From 091726334d0bdff1dc899653396c318b0378e805 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:37:41 +0100 Subject: [PATCH 030/270] lab_move direction S x --> 2 --- src/main/c/labyrinth.c | 4 ++++ src/test/c/test_labyrinth.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 2ac9193..ed5b973 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -32,6 +32,10 @@ void lab_move(unsigned short *x, unsigned short *y, Direction direction){ *y = *y + 1; return; } + if (direction == S){ + *x = 2; + return; + } } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 9599c01..ad8180f 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -132,3 +132,20 @@ void test_lab_move_from_5_5_E_expected_5_6(void) TEST_ASSERT_TRUE(x == x_expected && y == y_expected); } +void test_lab_move_from_1_1_S_expected_2_1(void) +{ + /* arrange */ + unsigned short x = 1; + unsigned short y = 1; + Direction direction = S; + + unsigned short x_expected = 2; + unsigned short y_expected = 1; + + /* act */ + lab_move(&x, &y, direction); + + /* assert */ + TEST_ASSERT_TRUE(x == x_expected && y == y_expected); +} + From 6a30cdf1b748448692cdcbd3e023c57358ac9f5a Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:39:17 +0100 Subject: [PATCH 031/270] lab_move direction S x --> x + 1 --- src/main/c/labyrinth.c | 2 +- src/test/c/test_labyrinth.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index ed5b973..b3d95b2 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -33,7 +33,7 @@ void lab_move(unsigned short *x, unsigned short *y, Direction direction){ return; } if (direction == S){ - *x = 2; + *x = *x + 1; return; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index ad8180f..bd2c483 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -149,3 +149,20 @@ void test_lab_move_from_1_1_S_expected_2_1(void) TEST_ASSERT_TRUE(x == x_expected && y == y_expected); } +void test_lab_move_from_5_5_S_expected_6_5(void) +{ + /* arrange */ + unsigned short x = 5; + unsigned short y = 5; + Direction direction = S; + + unsigned short x_expected = 6; + unsigned short y_expected = 5; + + /* act */ + lab_move(&x, &y, direction); + + /* assert */ + TEST_ASSERT_TRUE(x == x_expected && y == y_expected); +} + From df822f61a9a732f5b9048a548a854a577b640e22 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:40:55 +0100 Subject: [PATCH 032/270] lab_move direction W y --> 0 --- src/main/c/labyrinth.c | 4 ++++ src/test/c/test_labyrinth.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index b3d95b2..59bff17 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -36,6 +36,10 @@ void lab_move(unsigned short *x, unsigned short *y, Direction direction){ *x = *x + 1; return; } + if (direction == W){ + *y = 0; + return; + } } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index bd2c483..03b1642 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -166,3 +166,20 @@ void test_lab_move_from_5_5_S_expected_6_5(void) TEST_ASSERT_TRUE(x == x_expected && y == y_expected); } +void test_lab_move_from_1_1_W_expected_1_0(void) +{ + /* arrange */ + unsigned short x = 1; + unsigned short y = 1; + Direction direction = W; + + unsigned short x_expected = 1; + unsigned short y_expected = 0; + + /* act */ + lab_move(&x, &y, direction); + + /* assert */ + TEST_ASSERT_TRUE(x == x_expected && y == y_expected); +} + From bb1c11d4e38cf26a3bf514401065ae678e001a21 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:41:49 +0100 Subject: [PATCH 033/270] =?UTF-8?q?Commit=2021=20-=20lade=20secret=5Fword?= =?UTF-8?q?=20in=20hauptspiel=20einf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 93892bb..f10ca13 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -171,9 +171,9 @@ void hauptSpiel(int level){ char path[] = "hangman_words.txt"; int result; int won = 0; - //secret_word soll vergeben werden - //secret_word soll geladen werden - //path soll erstellt werden + + lade_secret_word(secret_word, level, path); + //hangman soll gemalt werden //Buchstaben sollen gezeigt werden //Buchstaben sollen eingegeben werden können From 356f53ef5bbec65ebb2169e9d0f23183fc014fd3 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:42:11 +0100 Subject: [PATCH 034/270] lab_move direction W y --> y - 1 --- src/main/c/labyrinth.c | 2 +- src/test/c/test_labyrinth.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 59bff17..ba08944 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -37,7 +37,7 @@ void lab_move(unsigned short *x, unsigned short *y, Direction direction){ return; } if (direction == W){ - *y = 0; + *y = *y - 1; return; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 03b1642..98d4f2f 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -183,3 +183,20 @@ void test_lab_move_from_1_1_W_expected_1_0(void) TEST_ASSERT_TRUE(x == x_expected && y == y_expected); } +void test_lab_move_from_5_5_W_expected_5_4(void) +{ + /* arrange */ + unsigned short x = 5; + unsigned short y = 5; + Direction direction = W; + + unsigned short x_expected = 5; + unsigned short y_expected = 4; + + /* act */ + lab_move(&x, &y, direction); + + /* assert */ + TEST_ASSERT_TRUE(x == x_expected && y == y_expected); +} + From 8d30fbee47d633b91afdd5c4cc466c548dc8952b Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:42:57 +0100 Subject: [PATCH 035/270] Commit 22 - Buchstaben sollen gezeigt werden --- src/main/c/hangman.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index f10ca13..6f4a00f 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -18,6 +18,7 @@ void draw_hangman(int attempts); void add_guessed_letter(char* guessed_letters, char guessed_letter); char eingabe_buchstabe(); void lade_secret_word(char* secret_word, int level, char* path); +void show_letters(char secret_word[100], char guessed_letters[100]); void protokoll(){ clear_screen(); @@ -292,4 +293,13 @@ void lade_secret_word(char* secret_word, int level, char* path){ } fclose(file); } +} + +void show_letters(char secret_word[100], char guessed_letters[100]){ + printf("Erratene Buchstaben: "); + for(int i = 0; i < strlen(secret_word); i++) { + if(strchr(guessed_letters, secret_word[i])){ + printf("%c ", secret_word[i]); + } +} } \ No newline at end of file From 5f2941c3f7d0e9d462883909e5a98c10a81f2904 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:43:15 +0100 Subject: [PATCH 036/270] set_wall at 0 0 --- src/main/c/global.h | 4 ++++ src/main/c/labyrinth.c | 4 ++++ src/main/c/labyrinth.h | 1 + src/test/c/test_labyrinth.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+) diff --git a/src/main/c/global.h b/src/main/c/global.h index 556a1f1..1dea8db 100644 --- a/src/main/c/global.h +++ b/src/main/c/global.h @@ -5,4 +5,8 @@ typedef enum { N, E, S, W } Direction; +typedef enum { + WAY, WALL, SOLUTION +} State; + #endif \ No newline at end of file diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index ba08944..7b13e6e 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -43,3 +43,7 @@ void lab_move(unsigned short *x, unsigned short *y, Direction direction){ } +void set_wall(State** field, unsigned short x, unsigned short y) { + field[0][0] = WALL; +} + diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index 3bd9821..15cd364 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -5,5 +5,6 @@ void turn_direction_right(Direction *direction); void lab_move(unsigned short *x, unsigned short *y, Direction direction); +void set_wall(State** field, unsigned short x, unsigned short y); #endif // TEST_H diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 98d4f2f..f950838 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -200,3 +200,34 @@ void test_lab_move_from_5_5_W_expected_5_4(void) TEST_ASSERT_TRUE(x == x_expected && y == y_expected); } +void test_set_wall_at_0_0_expected_WALL(void) +{ + /* arrange */ + unsigned short x = 0; + unsigned short y = 0; + + unsigned short len_x = 1, len_y = 1; + State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + + field[x][y] = WAY; + + State expected = WALL; + + /* act */ + set_wall(field, x, y); + + /* assert */ + TEST_ASSERT_TRUE(field[x][y] == expected); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} + From 273fa7c4dab5aa1c4345688a60354ce9826a0571 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:43:50 +0100 Subject: [PATCH 037/270] Commit 23 - func show_letters um else Bedingung erweitern --- src/main/c/hangman.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 6f4a00f..1be3268 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -301,5 +301,9 @@ void show_letters(char secret_word[100], char guessed_letters[100]){ if(strchr(guessed_letters, secret_word[i])){ printf("%c ", secret_word[i]); } -} + else{ + printf("_ "); + } + } + printf("\n"); } \ No newline at end of file From 81eddf4ec227f1cf1a88fd1d0e79ce5530f15701 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:44:46 +0100 Subject: [PATCH 038/270] Commit 24 - func letters in secret word wird eingebaut --- src/main/c/hangman.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 1be3268..be37548 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -19,6 +19,7 @@ void add_guessed_letter(char* guessed_letters, char guessed_letter); char eingabe_buchstabe(); void lade_secret_word(char* secret_word, int level, char* path); void show_letters(char secret_word[100], char guessed_letters[100]); +int letter_in_secret_word(char guessed_letter, char secret_word[100]); void protokoll(){ clear_screen(); @@ -306,4 +307,13 @@ void show_letters(char secret_word[100], char guessed_letters[100]){ } } printf("\n"); +} + +int letter_in_secret_word(char guessed_letter, char secret_word[100]){ + for(int i = 0; i < strlen(secret_word); i++){ + if(guessed_letter == secret_word[i]){ + return 0; + } + } + return 1; } \ No newline at end of file From d372b301600849dd7be8b79e7b95b45e672e6b0b Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:45:26 +0100 Subject: [PATCH 039/270] refactoring: State --> Field_State --- src/main/c/global.h | 2 +- src/main/c/labyrinth.c | 2 +- src/main/c/labyrinth.h | 2 +- src/test/c/test_labyrinth.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/c/global.h b/src/main/c/global.h index 1dea8db..6da861c 100644 --- a/src/main/c/global.h +++ b/src/main/c/global.h @@ -7,6 +7,6 @@ typedef enum { typedef enum { WAY, WALL, SOLUTION -} State; +} Field_State; #endif \ No newline at end of file diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 7b13e6e..71ccb5c 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -43,7 +43,7 @@ void lab_move(unsigned short *x, unsigned short *y, Direction direction){ } -void set_wall(State** field, unsigned short x, unsigned short y) { +void set_wall(Field_State** field, unsigned short x, unsigned short y) { field[0][0] = WALL; } diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index 15cd364..5b789f4 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -5,6 +5,6 @@ void turn_direction_right(Direction *direction); void lab_move(unsigned short *x, unsigned short *y, Direction direction); -void set_wall(State** field, unsigned short x, unsigned short y); +void set_wall(Field_State** field, unsigned short x, unsigned short y); #endif // TEST_H diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index f950838..9ef1074 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -207,7 +207,7 @@ void test_set_wall_at_0_0_expected_WALL(void) unsigned short y = 0; unsigned short len_x = 1, len_y = 1; - State **field; + Field_State **field; field = malloc(len_x * sizeof *field); for (int c_index = 0; c_index < len_x; c_index++){ @@ -216,7 +216,7 @@ void test_set_wall_at_0_0_expected_WALL(void) field[x][y] = WAY; - State expected = WALL; + Field_State expected = WALL; /* act */ set_wall(field, x, y); From f62a2d3e76f963d8eb1f68ada7824a59b6098fba Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:46:12 +0100 Subject: [PATCH 040/270] Commit 25 - hauptspiel bisweit erweitern --- src/main/c/hangman.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index be37548..25cb67d 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -176,10 +176,19 @@ void hauptSpiel(int level){ lade_secret_word(secret_word, level, path); - //hangman soll gemalt werden - //Buchstaben sollen gezeigt werden - //Buchstaben sollen eingegeben werden können - //eingegeben Buchstaben sollen überprüft und dem Lösungswort hinzugefügt werden, damit Gewinn ermittelt werden kann + while (attempts < 6) { //um gewinnen erweitern + draw_hangman(attempts); + show_letters(secret_word, guessed_letters); + guessed_letter = eingabe_buchstabe(); + result = letter_in_secret_word(guessed_letter, secret_word); + if (result == 0){ + add_guessed_letter(guessed_letters, guessed_letter); + } + else { + attempts++; + } + //gewonnen erweitern + } } void draw_hangman(int attempts) { From 690ae4eeaf6a3778869ca48fc904eee63146571a Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:47:01 +0100 Subject: [PATCH 041/270] set_wall at any x y --- src/main/c/labyrinth.c | 2 +- src/test/c/test_labyrinth.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 71ccb5c..8afa959 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -44,6 +44,6 @@ void lab_move(unsigned short *x, unsigned short *y, Direction direction){ } void set_wall(Field_State** field, unsigned short x, unsigned short y) { - field[0][0] = WALL; + field[x][y] = WALL; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 9ef1074..b5d9091 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -231,3 +231,34 @@ void test_set_wall_at_0_0_expected_WALL(void) free(field); } +void test_set_wall_at_2_3_expected_WALL(void) +{ + /* arrange */ + unsigned short x = 2; + unsigned short y = 3; + + unsigned short len_x = 5, len_y = 5; + Field_State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + + field[x][y] = WAY; + + Field_State expected = WALL; + + /* act */ + set_wall(field, x, y); + + /* assert */ + TEST_ASSERT_TRUE(field[x][y] == expected); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} + From d8b150ea5417278034955404ed54d537ed47b064 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:48:37 +0100 Subject: [PATCH 042/270] Commit 27 - gewonnen funktionalitt in hauptspiel einbinden --- src/main/c/hangman.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 25cb67d..d20711d 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -20,6 +20,7 @@ char eingabe_buchstabe(); void lade_secret_word(char* secret_word, int level, char* path); void show_letters(char secret_word[100], char guessed_letters[100]); int letter_in_secret_word(char guessed_letter, char secret_word[100]); +int has_won(char secret_word[100], char guessed_letters[100]); void protokoll(){ clear_screen(); @@ -176,7 +177,7 @@ void hauptSpiel(int level){ lade_secret_word(secret_word, level, path); - while (attempts < 6) { //um gewinnen erweitern + while (attempts < 6 && won == 0) { draw_hangman(attempts); show_letters(secret_word, guessed_letters); guessed_letter = eingabe_buchstabe(); @@ -187,7 +188,7 @@ void hauptSpiel(int level){ else { attempts++; } - //gewonnen erweitern + won = has_won(secret_word, guessed_letters); } } @@ -325,4 +326,20 @@ int letter_in_secret_word(char guessed_letter, char secret_word[100]){ } } return 1; +} + +int has_won(char secret_word[100], char guessed_letters[100]){ + int occured; + for (int i = 0; i < strlen(secret_word); i++){ + occured = 0; + for (int k = 0; k < strlen(guessed_letters); k++){ + if (secret_word[i] == guessed_letters[k]){ + occured = 1; + } + } + if (occured == 0){ + return 0; + } + } + return 1; } \ No newline at end of file From ce4005981d335169d8f7446860e2ea0c47e5f2b4 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:48:59 +0100 Subject: [PATCH 043/270] init_field with WAY at 0 0 --- src/main/c/labyrinth.c | 4 ++++ src/main/c/labyrinth.h | 1 + src/test/c/test_labyrinth.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 8afa959..75c718b 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -47,3 +47,7 @@ void set_wall(Field_State** field, unsigned short x, unsigned short y) { field[x][y] = WALL; } +void init_field(Field_State** field, unsigned short len_x, unsigned short len_y){ + field[0][0] = WAY; +} + diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index 5b789f4..19b1835 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -6,5 +6,6 @@ void turn_direction_right(Direction *direction); void lab_move(unsigned short *x, unsigned short *y, Direction direction); void set_wall(Field_State** field, unsigned short x, unsigned short y); +void init_field(Field_State** field, unsigned short len_x, unsigned short len_y); #endif // TEST_H diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index b5d9091..3658ce2 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -262,3 +262,33 @@ void test_set_wall_at_2_3_expected_WALL(void) free(field); } +void test_init_field_at_0_0_expected_WAY(void) +{ + /* arrange */ + unsigned short x = 0; + unsigned short y = 0; + + unsigned short len_x = 1, len_y = 1; + Field_State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + + field[x][y] = WALL; + + Field_State expected = WAY; + + /* act */ + init_field(field, len_x, len_y); + + /* assert */ + TEST_ASSERT_TRUE(field[x][y] == expected); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} From cfb70011a9d987c618739c73d026d79e256b4b05 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:49:35 +0100 Subject: [PATCH 044/270] Commit 28 - func level_plus einbauen --- src/main/c/hangman.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index d20711d..037c170 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -21,6 +21,7 @@ void lade_secret_word(char* secret_word, int level, char* path); void show_letters(char secret_word[100], char guessed_letters[100]); int letter_in_secret_word(char guessed_letter, char secret_word[100]); int has_won(char secret_word[100], char guessed_letters[100]); +void level_plus(); void protokoll(){ clear_screen(); @@ -342,4 +343,31 @@ int has_won(char secret_word[100], char guessed_letters[100]){ } } return 1; +} + +void level_plus(){ + char KonfDatei[100]; + char levelstr[3]; + int i = 0; + + FILE *fp = NULL; + fp = fopen("hangman.txt", "r+"); + fscanf(fp, "%s", KonfDatei); + + while(KonfDatei[i] != 0){ + i++; + } + levelstr[0] = KonfDatei[i-2]; + levelstr[1] = KonfDatei[i-1]; + levelstr[2] = '\0'; + if (levelstr[1] == '9'){ + KonfDatei[i-2]++; + KonfDatei[i-1] = '0'; + } else { + KonfDatei[i-1]++; + } + fclose(fp); + fp = fopen("hangman.txt", "w"); + fprintf(fp, "%s", KonfDatei); + fclose(fp); } \ No newline at end of file From 862ea944d09e98b63904c2a244fec8b2ba480696 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:50:31 +0100 Subject: [PATCH 045/270] Commit 29 - level_plus in Hauptspiel einbauen --- src/main/c/hangman.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 037c170..d1f72c3 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -191,6 +191,9 @@ void hauptSpiel(int level){ } won = has_won(secret_word, guessed_letters); } + if (won == 1){ + level_plus(); + } } void draw_hangman(int attempts) { From 96863d5beaf2a303b2ba44dc746955f5820e7fb8 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:51:20 +0100 Subject: [PATCH 046/270] init_field with all x --> WAY --- src/main/c/labyrinth.c | 4 +++- src/test/c/test_labyrinth.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 75c718b..4c10c06 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -48,6 +48,8 @@ void set_wall(Field_State** field, unsigned short x, unsigned short y) { } void init_field(Field_State** field, unsigned short len_x, unsigned short len_y){ - field[0][0] = WAY; + for (int x = 0; x < len_x; x++){ + field[x][0] = WAY; + } } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 3658ce2..c8fa6cf 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -292,3 +292,34 @@ void test_init_field_at_0_0_expected_WAY(void) } free(field); } + +void test_init_field_at_2_0_expected_WAY(void) +{ + /* arrange */ + unsigned short x = 2; + unsigned short y = 0; + + unsigned short len_x = 5, len_y = 5; + Field_State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + + field[x][y] = WALL; + + Field_State expected = WAY; + + /* act */ + init_field(field, len_x, len_y); + + /* assert */ + TEST_ASSERT_TRUE(field[x][y] == expected); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} From ce9fcaef3147fa6b10209556fb48251f299bdc32 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:51:31 +0100 Subject: [PATCH 047/270] Commit 30 - func Overlay einbauen & hauptspiel mit levelauswahl verbinden --- src/main/c/hangman.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index d1f72c3..2fc5f8a 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -22,6 +22,7 @@ void show_letters(char secret_word[100], char guessed_letters[100]); int letter_in_secret_word(char guessed_letter, char secret_word[100]); int has_won(char secret_word[100], char guessed_letters[100]); void level_plus(); +int overlay(); void protokoll(){ clear_screen(); @@ -39,7 +40,7 @@ void clear_screen() { void willkommen(){ char ENTERtxt[] = {"-Druecke ENTER zum starten-\n"}; - + overlay(); printf("%s", ENTERtxt); getchar(); } @@ -81,7 +82,7 @@ void nameWaehlen(){ fp = fopen("hangman.txt", "w"); clear_screen(); // - + overlay(); printf("Geben Sie den Namen ein: "); scanf("%s", name); @@ -97,7 +98,7 @@ void startauswahl() { int modus; clear_screen(); // - + overlay(); printf("Willkommen "); nameAusgeben(); printf("[1] Spielen\n[2] Namen aendern\n"); @@ -150,7 +151,7 @@ void levelauswahl(){ int i = 0; clear_screen(); // - + overlay(); FILE *fp = NULL; fp = fopen("hangman.txt", "r"); @@ -163,7 +164,7 @@ void levelauswahl(){ levelstr[1] = KonfDatei[i-1]; levelstr[2] = '\0'; level = atoi(levelstr); - //hauptspiel mit dem Level starten + hauptSpiel(level); fclose(fp); } @@ -373,4 +374,25 @@ void level_plus(){ fp = fopen("hangman.txt", "w"); fprintf(fp, "%s", KonfDatei); fclose(fp); +} + +int overlay(){ + char hangmanArt[10][41] = { + " _______ ", + " | | ", + " | ", + " | ", + " | ", + " | ", + "__|_________\n" + }; + + printf("Galgenmann!\n"); + printf("v.1.0.2\n\n"); + + + for (int i = 0; i < 9; i++) { + printf("%s\n", hangmanArt[i]); + } + return 0; } \ No newline at end of file From 3758ec226cddfde007c0353fefad660fe3c16198 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:52:27 +0100 Subject: [PATCH 048/270] init_field any x y --> WAY --- src/main/c/labyrinth.c | 4 +++- src/test/c/test_labyrinth.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 4c10c06..63d9f94 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -49,7 +49,9 @@ void set_wall(Field_State** field, unsigned short x, unsigned short y) { void init_field(Field_State** field, unsigned short len_x, unsigned short len_y){ for (int x = 0; x < len_x; x++){ - field[x][0] = WAY; + for (int y = 0; y < len_y; y++){ + field[x][y] = WAY; + } } } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index c8fa6cf..2027c8b 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -323,3 +323,35 @@ void test_init_field_at_2_0_expected_WAY(void) } free(field); } + +void test_init_field_at_2_3_expected_WAY(void) +{ + /* arrange */ + unsigned short x = 2; + unsigned short y = 3; + + unsigned short len_x = 5, len_y = 5; + Field_State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + + field[x][y] = WALL; + + Field_State expected = WAY; + + /* act */ + init_field(field, len_x, len_y); + + /* assert */ + TEST_ASSERT_TRUE(field[x][y] == expected); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} + From 09b8bc1e75c5277dd0b95ec55b328ba732781c5a Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:56:31 +0100 Subject: [PATCH 049/270] refactoring: init_field --- src/main/c/labyrinth.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 63d9f94..9259093 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -48,9 +48,9 @@ void set_wall(Field_State** field, unsigned short x, unsigned short y) { } void init_field(Field_State** field, unsigned short len_x, unsigned short len_y){ - for (int x = 0; x < len_x; x++){ - for (int y = 0; y < len_y; y++){ - field[x][y] = WAY; + for (int c_x = 0; c_x < len_x; c_x++){ + for (int c_y = 0; c_y < len_y; c_y++){ + field[c_x][c_y] = WAY; } } } From 5de30c9dc50499a45cddb92c77cd73cdb0493427 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:58:10 +0100 Subject: [PATCH 050/270] lab_can_move North undefined --- src/main/c/labyrinth.c | 10 ++++++++++ src/main/c/labyrinth.h | 1 + src/test/c/test_labyrinth.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 9259093..8087c3b 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -55,3 +55,13 @@ void init_field(Field_State** field, unsigned short len_x, unsigned short len_y) } } +short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Direction direction, unsigned short len_x, unsigned short len_y){ + + lab_move(&x, &y, direction); + if (x == 65535){ + return 1; + } + + return 0; +} + diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index 19b1835..ef19e30 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -7,5 +7,6 @@ void turn_direction_right(Direction *direction); void lab_move(unsigned short *x, unsigned short *y, Direction direction); void set_wall(Field_State** field, unsigned short x, unsigned short y); void init_field(Field_State** field, unsigned short len_x, unsigned short len_y); +short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Direction direction, unsigned short len_x, unsigned short len_y); #endif // TEST_H diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 2027c8b..7192ff4 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -355,3 +355,34 @@ void test_init_field_at_2_3_expected_WAY(void) free(field); } +void test_lab_can_move_at_0_0_direction_N_target_undefined_expected_1(void) +{ + /* arrange */ + unsigned short x = 0; + unsigned short y = 0; + Direction direction = N; + short expected = 1; + short actual; + + unsigned short len_x = 1, len_y = 1; + Field_State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + + /* act */ + actual = lab_can_move(field, x, y, direction, len_x, len_y); + + /* assert */ + TEST_ASSERT_EQUAL_INT8(expected, actual); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} + + From fc9181ff5f077b5e20b94a9bf3841460f078f31e Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:00:18 +0100 Subject: [PATCH 051/270] lab_can_move y undefined --- src/main/c/labyrinth.c | 3 +++ src/test/c/test_labyrinth.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 8087c3b..4686b6c 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -61,6 +61,9 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire if (x == 65535){ return 1; } + if (y == 1){ + return 1; + } return 0; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 7192ff4..aa50607 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -385,4 +385,35 @@ void test_lab_can_move_at_0_0_direction_N_target_undefined_expected_1(void) free(field); } +void test_lab_can_move_at_0_0_direction_E_target_undefined_expected_1(void) +{ + /* arrange */ + unsigned short x = 0; + unsigned short y = 0; + Direction direction = E; + short expected = 1; + short actual; + + unsigned short len_x = 1, len_y = 1; + Field_State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + + /* act */ + actual = lab_can_move(field, x, y, direction, len_x, len_y); + + /* assert */ + TEST_ASSERT_EQUAL_INT8(expected, actual); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} + + From f6caf8b8e2c5e6045d37468667212bdad1821152 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:01:44 +0100 Subject: [PATCH 052/270] lab_can_move x undefined over 0 --- src/main/c/labyrinth.c | 2 +- src/test/c/test_labyrinth.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 4686b6c..ea27816 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -58,7 +58,7 @@ void init_field(Field_State** field, unsigned short len_x, unsigned short len_y) short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Direction direction, unsigned short len_x, unsigned short len_y){ lab_move(&x, &y, direction); - if (x == 65535){ + if (x >= len_x){ return 1; } if (y == 1){ diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index aa50607..83abd75 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -415,5 +415,36 @@ void test_lab_can_move_at_0_0_direction_E_target_undefined_expected_1(void) free(field); } +void test_lab_can_move_at_0_0_direction_S_target_undefined_expected_1(void) +{ + /* arrange */ + unsigned short x = 0; + unsigned short y = 0; + Direction direction = S; + short expected = 1; + short actual; + + unsigned short len_x = 1, len_y = 1; + Field_State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + + /* act */ + actual = lab_can_move(field, x, y, direction, len_x, len_y); + + /* assert */ + TEST_ASSERT_EQUAL_INT8(expected, actual); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} + + From c53ffc1fa86392f771a828f2b9b7797c544d40b0 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:03:36 +0100 Subject: [PATCH 053/270] lab_can_move y undefined below 0 (overflow) --- src/main/c/labyrinth.c | 2 +- src/test/c/test_labyrinth.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index ea27816..50db9df 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -61,7 +61,7 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire if (x >= len_x){ return 1; } - if (y == 1){ + if (y >= len_y){ return 1; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 83abd75..0d8d6bc 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -445,6 +445,37 @@ void test_lab_can_move_at_0_0_direction_S_target_undefined_expected_1(void) free(field); } +void test_lab_can_move_at_0_0_direction_W_target_undefined_expected_1(void) +{ + /* arrange */ + unsigned short x = 0; + unsigned short y = 0; + Direction direction = W; + short expected = 1; + short actual; + + unsigned short len_x = 1, len_y = 1; + Field_State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + + /* act */ + actual = lab_can_move(field, x, y, direction, len_x, len_y); + + /* assert */ + TEST_ASSERT_EQUAL_INT8(expected, actual); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} + + From 8bfd95afccc04a23cc4b448e99d3c871ba1c1f93 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:04:46 +0100 Subject: [PATCH 054/270] lab_can_move direction N WALL above --- src/main/c/labyrinth.c | 5 ++++- src/test/c/test_labyrinth.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 50db9df..688ef35 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -56,7 +56,7 @@ void init_field(Field_State** field, unsigned short len_x, unsigned short len_y) } short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Direction direction, unsigned short len_x, unsigned short len_y){ - + lab_move(&x, &y, direction); if (x >= len_x){ return 1; @@ -64,6 +64,9 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire if (y >= len_y){ return 1; } + if (direction == N && field[x][y] == WALL){ + return 1; + } return 0; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 0d8d6bc..a392006 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -475,6 +475,40 @@ void test_lab_can_move_at_0_0_direction_W_target_undefined_expected_1(void) free(field); } +void test_lab_can_move_at_1_1_direction_N_target_WALL_expected_1(void) +{ + /* arrange */ + unsigned short x = 1; + unsigned short y = 1; + unsigned short x_target = 0; + unsigned short y_target = 1; + Direction direction = N; + short expected = 1; + short actual; + + unsigned short len_x = 3, len_y = 3; + Field_State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + field[x_target][y_target] = WALL; + + /* act */ + actual = lab_can_move(field, x, y, direction, len_x, len_y); + + /* assert */ + TEST_ASSERT_EQUAL_INT8(expected, actual); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} + + From 1e36e6b4c1e2e7cf66a4a6f221c8106566376574 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:06:22 +0100 Subject: [PATCH 055/270] lab_can_move direction E WALL heading WALL --- src/main/c/labyrinth.c | 3 +++ src/test/c/test_labyrinth.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 688ef35..004c661 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -67,6 +67,9 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire if (direction == N && field[x][y] == WALL){ return 1; } + if (direction == E && field[x][y] == WALL){ + return 1; + } return 0; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index a392006..3c00353 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -508,6 +508,40 @@ void test_lab_can_move_at_1_1_direction_N_target_WALL_expected_1(void) free(field); } +void test_lab_can_move_at_1_1_direction_E_target_WALL_expected_1(void) +{ + /* arrange */ + unsigned short x = 1; + unsigned short y = 1; + unsigned short x_target = 1; + unsigned short y_target = 2; + Direction direction = E; + short expected = 1; + short actual; + + unsigned short len_x = 3, len_y = 3; + Field_State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + field[x_target][y_target] = WALL; + + /* act */ + actual = lab_can_move(field, x, y, direction, len_x, len_y); + + /* assert */ + TEST_ASSERT_EQUAL_INT8(expected, actual); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} + + From 7f3925512d86b424006fdec789cb07bab4d3acc9 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:08:55 +0100 Subject: [PATCH 056/270] lab_can_move direction S heading WALL --- src/main/c/labyrinth.c | 3 +++ src/test/c/test_labyrinth.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 004c661..7b9a2a8 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -70,6 +70,9 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire if (direction == E && field[x][y] == WALL){ return 1; } + if (direction == S && field[x][y] == WALL){ + return 1; + } return 0; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 3c00353..de5b7c6 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -541,6 +541,40 @@ void test_lab_can_move_at_1_1_direction_E_target_WALL_expected_1(void) free(field); } +void test_lab_can_move_at_1_1_direction_S_target_WALL_expected_1(void) +{ + /* arrange */ + unsigned short x = 1; + unsigned short y = 1; + unsigned short x_target = 2; + unsigned short y_target = 1; + Direction direction = S; + short expected = 1; + short actual; + + unsigned short len_x = 3, len_y = 3; + Field_State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + field[x_target][y_target] = WALL; + + /* act */ + actual = lab_can_move(field, x, y, direction, len_x, len_y); + + /* assert */ + TEST_ASSERT_EQUAL_INT8(expected, actual); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} + + From 32e5b54cab6b52ab257ed491895d4a5e10adfc6e Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:09:56 +0100 Subject: [PATCH 057/270] lab_can_move direction W heading WALL --- src/main/c/labyrinth.c | 3 +++ src/test/c/test_labyrinth.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 7b9a2a8..c0aa3ed 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -73,6 +73,9 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire if (direction == S && field[x][y] == WALL){ return 1; } + if (direction == W && field[x][y] == WALL){ + return 1; + } return 0; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index de5b7c6..4a60303 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -574,6 +574,40 @@ void test_lab_can_move_at_1_1_direction_S_target_WALL_expected_1(void) free(field); } +void test_lab_can_move_at_1_1_direction_W_target_WALL_expected_1(void) +{ + /* arrange */ + unsigned short x = 1; + unsigned short y = 1; + unsigned short x_target = 1; + unsigned short y_target = 0; + Direction direction = W; + short expected = 1; + short actual; + + unsigned short len_x = 3, len_y = 3; + Field_State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + field[x_target][y_target] = WALL; + + /* act */ + actual = lab_can_move(field, x, y, direction, len_x, len_y); + + /* assert */ + TEST_ASSERT_EQUAL_INT8(expected, actual); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} + + From 5b28c39baac32859b51907ec6ec51d876b93c3f5 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:11:32 +0100 Subject: [PATCH 058/270] refactoring: lab_can_move --- src/main/c/labyrinth.c | 11 +---------- src/test/c/test_labyrinth.c | 8 -------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index c0aa3ed..6acd557 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -64,16 +64,7 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire if (y >= len_y){ return 1; } - if (direction == N && field[x][y] == WALL){ - return 1; - } - if (direction == E && field[x][y] == WALL){ - return 1; - } - if (direction == S && field[x][y] == WALL){ - return 1; - } - if (direction == W && field[x][y] == WALL){ + if (field[x][y] == WALL){ return 1; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 4a60303..5cde2e1 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -607,11 +607,3 @@ void test_lab_can_move_at_1_1_direction_W_target_WALL_expected_1(void) free(field); } - - - - - - - - From 36507739f86906594f240738afd7e7e45eafba6e Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:13:03 +0100 Subject: [PATCH 059/270] lab_can_move direction N heading SOLUTION --- src/main/c/labyrinth.c | 3 +++ src/test/c/test_labyrinth.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 6acd557..e6f9ed5 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -67,6 +67,9 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire if (field[x][y] == WALL){ return 1; } + if (direction == N && field[x][y] == SOLUTION){ + return 1; + } return 0; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 5cde2e1..27bc07f 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -607,3 +607,35 @@ void test_lab_can_move_at_1_1_direction_W_target_WALL_expected_1(void) free(field); } +void test_lab_can_move_at_1_1_direction_N_target_SOLUTION_expected_1(void) +{ + /* arrange */ + unsigned short x = 1; + unsigned short y = 1; + unsigned short x_target = 0; + unsigned short y_target = 1; + Direction direction = N; + short expected = 1; + short actual; + unsigned short len_x = 3, len_y = 3; + Field_State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + field[x_target][y_target] = SOLUTION; + + /* act */ + actual = lab_can_move(field, x, y, direction, len_x, len_y); + + /* assert */ + TEST_ASSERT_EQUAL_INT8(expected, actual); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} + From 5612121dab3d543ef9f3917a6b633ce9d7069cb5 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:14:15 +0100 Subject: [PATCH 060/270] lab_can_move direction E heading SOLUTION --- src/main/c/labyrinth.c | 3 +++ src/test/c/test_labyrinth.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index e6f9ed5..6e168d9 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -70,6 +70,9 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire if (direction == N && field[x][y] == SOLUTION){ return 1; } + if (direction == E && field[x][y] == SOLUTION){ + return 1; + } return 0; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 27bc07f..99d45be 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -639,3 +639,35 @@ void test_lab_can_move_at_1_1_direction_N_target_SOLUTION_expected_1(void) free(field); } +void test_lab_can_move_at_1_1_direction_E_target_SOLUTION_expected_1(void) +{ + /* arrange */ + unsigned short x = 1; + unsigned short y = 1; + unsigned short x_target = 1; + unsigned short y_target = 2; + Direction direction = E; + short expected = 1; + short actual; + unsigned short len_x = 3, len_y = 3; + Field_State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + field[x_target][y_target] = SOLUTION; + + /* act */ + actual = lab_can_move(field, x, y, direction, len_x, len_y); + + /* assert */ + TEST_ASSERT_EQUAL_INT8(expected, actual); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} + From def3a558e3f04bc215c70983e65494ee63a07a6f Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:15:22 +0100 Subject: [PATCH 061/270] lab_can_move direction S heading SOLUTION --- src/main/c/labyrinth.c | 3 +++ src/test/c/test_labyrinth.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 6e168d9..42b180c 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -73,6 +73,9 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire if (direction == E && field[x][y] == SOLUTION){ return 1; } + if (direction == S && field[x][y] == SOLUTION){ + return 1; + } return 0; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 99d45be..4f30f4b 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -671,3 +671,35 @@ void test_lab_can_move_at_1_1_direction_E_target_SOLUTION_expected_1(void) free(field); } +void test_lab_can_move_at_1_1_direction_S_target_SOLUTION_expected_1(void) +{ + /* arrange */ + unsigned short x = 1; + unsigned short y = 1; + unsigned short x_target = 2; + unsigned short y_target = 1; + Direction direction = S; + short expected = 1; + short actual; + unsigned short len_x = 3, len_y = 3; + Field_State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + field[x_target][y_target] = SOLUTION; + + /* act */ + actual = lab_can_move(field, x, y, direction, len_x, len_y); + + /* assert */ + TEST_ASSERT_EQUAL_INT8(expected, actual); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} + From 76cbafc7b24ec17e8f2d822f98abedb0e0c0723b Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:17:08 +0100 Subject: [PATCH 062/270] lab_can_move direction W heading SOLUTION --- src/main/c/labyrinth.c | 3 +++ src/test/c/test_labyrinth.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 42b180c..53bf12d 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -76,6 +76,9 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire if (direction == S && field[x][y] == SOLUTION){ return 1; } + if (direction == W && field[x][y] == SOLUTION){ + return 1; + } return 0; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 4f30f4b..4f52132 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -703,3 +703,35 @@ void test_lab_can_move_at_1_1_direction_S_target_SOLUTION_expected_1(void) free(field); } +void test_lab_can_move_at_1_1_direction_W_target_SOLUTION_expected_1(void) +{ + /* arrange */ + unsigned short x = 1; + unsigned short y = 1; + unsigned short x_target = 1; + unsigned short y_target = 0; + Direction direction = W; + short expected = 1; + short actual; + unsigned short len_x = 3, len_y = 3; + Field_State **field; + + field = malloc(len_x * sizeof *field); + for (int c_index = 0; c_index < len_x; c_index++){ + field[c_index] = malloc(len_y * sizeof field[c_index]); + } + field[x_target][y_target] = SOLUTION; + + /* act */ + actual = lab_can_move(field, x, y, direction, len_x, len_y); + + /* assert */ + TEST_ASSERT_EQUAL_INT8(expected, actual); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(field[c_index]); + } + free(field); +} + From 2302392b0cef6822231b61c518ce91f43f2705c7 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:24:57 +0100 Subject: [PATCH 063/270] refactoring: lab_can_move --- src/main/c/labyrinth.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 53bf12d..09e00a1 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -70,13 +70,7 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire if (direction == N && field[x][y] == SOLUTION){ return 1; } - if (direction == E && field[x][y] == SOLUTION){ - return 1; - } - if (direction == S && field[x][y] == SOLUTION){ - return 1; - } - if (direction == W && field[x][y] == SOLUTION){ + if (field[x][y] == SOLUTION){ return 1; } From ce38e86808adf74bcc2bbf30d10653582d302045 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:26:40 +0100 Subject: [PATCH 064/270] show_solution --- src/main/c/labyrinth.c | 12 +++++++++--- src/main/c/labyrinth.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 09e00a1..bc3c05c 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -5,6 +5,15 @@ #include "stdio.h" #include "stdlib.h" +void show_solution(Field_State** field, unsigned short len_x, unsigned short len_y){ + for (int c_x = 0; c_x < len_x; c_x++){ + for (int c_y = 0; c_y < len_y; c_y++){ + printf("%hi", field[c_x][c_y]); + } + printf("\n"); + } +} + void turn_direction_right(Direction *direction){ switch (*direction) { case N: @@ -67,9 +76,6 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire if (field[x][y] == WALL){ return 1; } - if (direction == N && field[x][y] == SOLUTION){ - return 1; - } if (field[x][y] == SOLUTION){ return 1; } diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index ef19e30..42c953a 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -8,5 +8,6 @@ void lab_move(unsigned short *x, unsigned short *y, Direction direction); void set_wall(Field_State** field, unsigned short x, unsigned short y); void init_field(Field_State** field, unsigned short len_x, unsigned short len_y); short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Direction direction, unsigned short len_x, unsigned short len_y); +void show_solution(Field_State** field, unsigned short len_x, unsigned short len_y); #endif // TEST_H From 126fd0d3d6e3d2cfd4ed7d7e9fce94618b485a38 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:27:39 +0100 Subject: [PATCH 065/270] get_natural_number --- src/main/c/labyrinth.c | 7 +++++++ src/main/c/labyrinth.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index bc3c05c..1d70380 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -14,6 +14,13 @@ void show_solution(Field_State** field, unsigned short len_x, unsigned short len } } +unsigned short get_natural_number(char text[]){ + unsigned short result; + printf("%s", text); + scanf("%hu", &result); + return result; +} + void turn_direction_right(Direction *direction){ switch (*direction) { case N: diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index 42c953a..593d111 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -9,5 +9,6 @@ void set_wall(Field_State** field, unsigned short x, unsigned short y); void init_field(Field_State** field, unsigned short len_x, unsigned short len_y); short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Direction direction, unsigned short len_x, unsigned short len_y); void show_solution(Field_State** field, unsigned short len_x, unsigned short len_y); +unsigned short get_natural_number(char text[]); #endif // TEST_H From 711d24f20e30022d239bda4e4fcf5b658a8d6a3d Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:31:49 +0100 Subject: [PATCH 066/270] dimesions --- src/main/c/labyrinth.c | 5 +++++ src/main/c/labyrinth.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 1d70380..997f1b7 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -21,6 +21,11 @@ unsigned short get_natural_number(char text[]){ return result; } +void dimesions(unsigned short *len_x, unsigned short *len_y){ + *len_x = get_natural_number("Bitte gib die x-Laenge des Labyrinthes an:\n"); + *len_y = get_natural_number("Bitte gib die y-Laenge des Labyrinthes an:\n"); +} + void turn_direction_right(Direction *direction){ switch (*direction) { case N: diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index 593d111..4494394 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -10,5 +10,6 @@ void init_field(Field_State** field, unsigned short len_x, unsigned short len_y) short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Direction direction, unsigned short len_x, unsigned short len_y); void show_solution(Field_State** field, unsigned short len_x, unsigned short len_y); unsigned short get_natural_number(char text[]); +void dimesions(unsigned short *len_x, unsigned short *len_y); #endif // TEST_H From 7d46b6020ecb65828d01303c011b62523e0c1f86 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:33:21 +0100 Subject: [PATCH 067/270] refactoring: dimesions --> get_lab_dimensions --- src/main/c/labyrinth.c | 2 +- src/main/c/labyrinth.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 997f1b7..81b9ed4 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -21,7 +21,7 @@ unsigned short get_natural_number(char text[]){ return result; } -void dimesions(unsigned short *len_x, unsigned short *len_y){ +void ask_lab_dimensions(unsigned short *len_x, unsigned short *len_y){ *len_x = get_natural_number("Bitte gib die x-Laenge des Labyrinthes an:\n"); *len_y = get_natural_number("Bitte gib die y-Laenge des Labyrinthes an:\n"); } diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index 4494394..d9cb80c 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -10,6 +10,6 @@ void init_field(Field_State** field, unsigned short len_x, unsigned short len_y) short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Direction direction, unsigned short len_x, unsigned short len_y); void show_solution(Field_State** field, unsigned short len_x, unsigned short len_y); unsigned short get_natural_number(char text[]); -void dimesions(unsigned short *len_x, unsigned short *len_y); +void ask_lab_dimensions(unsigned short *len_x, unsigned short *len_y); #endif // TEST_H From c508f0ae095569445a01f3e6784bbc85d5dab7f1 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:34:34 +0100 Subject: [PATCH 068/270] wall input --- src/main/c/labyrinth.c | 20 ++++++++++++++++++++ src/main/c/labyrinth.h | 1 + 2 files changed, 21 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 81b9ed4..690f831 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -26,6 +26,26 @@ void ask_lab_dimensions(unsigned short *len_x, unsigned short *len_y){ *len_y = get_natural_number("Bitte gib die y-Laenge des Labyrinthes an:\n"); } +short wall(unsigned short *x, unsigned short *y, unsigned short len_x, unsigned short len_y){ + char answer; + printf("Moechten Sie die Koordinaten einer weiteren Labyrinthwand angeben? (y/n)\n"); + scanf(" %c", &answer); + + if (answer == 'n'){ + return 1; + } + + printf("Bitte geben Sie die Koordinaten von Labyrinthwaenden im Format x, y ein.\n"); + scanf("%hu, %hu", x, y); + + if (*x >= len_x || *y >= len_y){ + printf("Die eingegebenen Koordinaten sind zu gross.\n"); + return -1; + } + + return 0; +} + void turn_direction_right(Direction *direction){ switch (*direction) { case N: diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index d9cb80c..b2160ff 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -11,5 +11,6 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire void show_solution(Field_State** field, unsigned short len_x, unsigned short len_y); unsigned short get_natural_number(char text[]); void ask_lab_dimensions(unsigned short *len_x, unsigned short *len_y); +short wall(unsigned short *x, unsigned short *y, unsigned short len_x, unsigned short len_y); #endif // TEST_H From 435fe6dc4766aeb2471a1477b15c2cdb322bdde9 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:35:39 +0100 Subject: [PATCH 069/270] refactoring: wall --> get_wall_input --- src/main/c/labyrinth.c | 2 +- src/main/c/labyrinth.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 690f831..06def76 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -26,7 +26,7 @@ void ask_lab_dimensions(unsigned short *len_x, unsigned short *len_y){ *len_y = get_natural_number("Bitte gib die y-Laenge des Labyrinthes an:\n"); } -short wall(unsigned short *x, unsigned short *y, unsigned short len_x, unsigned short len_y){ +short get_wall_input(unsigned short *x, unsigned short *y, unsigned short len_x, unsigned short len_y){ char answer; printf("Moechten Sie die Koordinaten einer weiteren Labyrinthwand angeben? (y/n)\n"); scanf(" %c", &answer); diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index b2160ff..c50580c 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -11,6 +11,6 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire void show_solution(Field_State** field, unsigned short len_x, unsigned short len_y); unsigned short get_natural_number(char text[]); void ask_lab_dimensions(unsigned short *len_x, unsigned short *len_y); -short wall(unsigned short *x, unsigned short *y, unsigned short len_x, unsigned short len_y); +short get_wall_input(unsigned short *x, unsigned short *y, unsigned short len_x, unsigned short len_y); #endif // TEST_H From 818266ef5e32a5f37626134077edf363dd7d5635 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:36:37 +0100 Subject: [PATCH 070/270] ask_lab_walls --- src/main/c/labyrinth.c | 15 +++++++++++++++ src/main/c/labyrinth.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 06def76..5acb7d5 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -115,3 +115,18 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire return 0; } +void ask_lab_walls(Field_State** field, unsigned short len_x, unsigned short len_y){ + unsigned short x, y; + short a; + + init_field(field, len_x, len_y); + + do { + a = get_wall_input(&x, &y, len_x, len_y); + if (a == 0){ + set_wall(field, x, y); + show_solution(field, len_x, len_y); + } + } while (a != 1); +} + diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index c50580c..c731167 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -12,5 +12,6 @@ void show_solution(Field_State** field, unsigned short len_x, unsigned short len unsigned short get_natural_number(char text[]); void ask_lab_dimensions(unsigned short *len_x, unsigned short *len_y); short get_wall_input(unsigned short *x, unsigned short *y, unsigned short len_x, unsigned short len_y); +void ask_lab_walls(Field_State** field, unsigned short len_x, unsigned short len_y); #endif // TEST_H From 9e00574912d011c872213cde75c5c5895800d705 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:38:24 +0100 Subject: [PATCH 071/270] refactoring: ask_lab_walls --- src/main/c/labyrinth.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 5acb7d5..fafbe33 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -117,16 +117,16 @@ short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Dire void ask_lab_walls(Field_State** field, unsigned short len_x, unsigned short len_y){ unsigned short x, y; - short a; + short wall_input_continue; init_field(field, len_x, len_y); do { - a = get_wall_input(&x, &y, len_x, len_y); - if (a == 0){ + wall_input_continue = get_wall_input(&x, &y, len_x, len_y); + if (wall_input_continue == 0){ set_wall(field, x, y); show_solution(field, len_x, len_y); } - } while (a != 1); + } while (wall_input_continue != 1); } From 4a697fad046bb4a25f8b8970e1c186e10b5bbda2 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:41:56 +0100 Subject: [PATCH 072/270] calculate_lab_way --- src/main/c/labyrinth.c | 29 +++++++++++++++++++++++++++++ src/main/c/labyrinth.h | 1 + 2 files changed, 30 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index fafbe33..584f88c 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -130,3 +130,32 @@ void ask_lab_walls(Field_State** field, unsigned short len_x, unsigned short len } while (wall_input_continue != 1); } +short calculate_lab_way(Field_State** field, unsigned short len_x, unsigned short len_y, unsigned short x, unsigned short y){ + Direction direction = N; + + unsigned short c_x; + unsigned short c_y; + + if (x == len_x-1 && y == len_y-1){ + field[x][y] = SOLUTION; + return 0; + } + + do { + c_x = x; + c_y = y; + if (lab_can_move(field, c_x, c_y, direction, len_x, len_y) == 0){ + lab_move(&c_x, &c_y, direction); + printf("%d - %d\n", c_x, c_y); + field[c_x][c_y] = SOLUTION; + if (calculate_lab_way(field, len_x, len_y, c_x, c_y) == 0){ + return 0; + } + field[c_x][c_y] = WAY; + } + turn_direction_right(&direction); + } + while (direction != N); + return 1; +} + diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index c731167..fc6001c 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -13,5 +13,6 @@ unsigned short get_natural_number(char text[]); void ask_lab_dimensions(unsigned short *len_x, unsigned short *len_y); short get_wall_input(unsigned short *x, unsigned short *y, unsigned short len_x, unsigned short len_y); void ask_lab_walls(Field_State** field, unsigned short len_x, unsigned short len_y); +short calculate_lab_way(Field_State** field, unsigned short len_x, unsigned short len_y, unsigned short x, unsigned short y); #endif // TEST_H From f1321b298c0fa9895ccf7f055b18722df3de4fdf Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:43:07 +0100 Subject: [PATCH 073/270] refactoring: calculate_lab_way --- src/main/c/labyrinth.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 584f88c..7f3d89f 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -133,8 +133,8 @@ void ask_lab_walls(Field_State** field, unsigned short len_x, unsigned short len short calculate_lab_way(Field_State** field, unsigned short len_x, unsigned short len_y, unsigned short x, unsigned short y){ Direction direction = N; - unsigned short c_x; - unsigned short c_y; + unsigned short current_x; + unsigned short current_y; if (x == len_x-1 && y == len_y-1){ field[x][y] = SOLUTION; @@ -142,16 +142,16 @@ short calculate_lab_way(Field_State** field, unsigned short len_x, unsigned shor } do { - c_x = x; - c_y = y; - if (lab_can_move(field, c_x, c_y, direction, len_x, len_y) == 0){ - lab_move(&c_x, &c_y, direction); - printf("%d - %d\n", c_x, c_y); - field[c_x][c_y] = SOLUTION; - if (calculate_lab_way(field, len_x, len_y, c_x, c_y) == 0){ + current_x = x; + current_y = y; + if (lab_can_move(field, current_x, current_y, direction, len_x, len_y) == 0){ + lab_move(¤t_x, ¤t_y, direction); + printf("%d - %d\n", current_x, current_y); + field[current_x][current_y] = SOLUTION; + if (calculate_lab_way(field, len_x, len_y, current_x, current_y) == 0){ return 0; } - field[c_x][c_y] = WAY; + field[current_x][current_y] = WAY; } turn_direction_right(&direction); } From ce9b9eab96809fdd4cb6828ef3345c4d57e9bb61 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:43:52 +0100 Subject: [PATCH 074/270] labyrinth --- src/main/c/labyrinth.c | 7 +++++++ src/main/c/labyrinth.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 7f3d89f..70b3f74 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -159,3 +159,10 @@ short calculate_lab_way(Field_State** field, unsigned short len_x, unsigned shor return 1; } +void labyrinth(){ + unsigned short x, y; + + ask_lab_dimensions(&x, &y); + +} + diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index fc6001c..8e9f178 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -14,5 +14,6 @@ void ask_lab_dimensions(unsigned short *len_x, unsigned short *len_y); short get_wall_input(unsigned short *x, unsigned short *y, unsigned short len_x, unsigned short len_y); void ask_lab_walls(Field_State** field, unsigned short len_x, unsigned short len_y); short calculate_lab_way(Field_State** field, unsigned short len_x, unsigned short len_y, unsigned short x, unsigned short y); +void labyrinth(); #endif // TEST_H From 6783b5b8dbdca0337a3b75dc32872c3753c2b62b Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:44:55 +0100 Subject: [PATCH 075/270] refactoring: labyrinth --- src/main/c/labyrinth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 70b3f74..a83f54d 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -160,9 +160,9 @@ short calculate_lab_way(Field_State** field, unsigned short len_x, unsigned shor } void labyrinth(){ - unsigned short x, y; + unsigned short len_x, len_y; - ask_lab_dimensions(&x, &y); + ask_lab_dimensions(&len_x, &len_y); } From 232425ef462c57ef7a9898878f6415d8c392bfa5 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:46:05 +0100 Subject: [PATCH 076/270] final piece of cake in labyrinth --- src/main/c/labyrinth.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index a83f54d..221e0f7 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -161,8 +161,28 @@ short calculate_lab_way(Field_State** field, unsigned short len_x, unsigned shor void labyrinth(){ unsigned short len_x, len_y; + Field_State **f; ask_lab_dimensions(&len_x, &len_y); + f = malloc(len_x * sizeof *f); + for (int c_index = 0; c_index < len_x; c_index++){ + f[c_index] = malloc(len_y * sizeof f[c_index]); + } + + ask_lab_walls(f, len_x, len_y); + + if (calculate_lab_way(f, len_x, len_y, 0, 0) == 1){ + printf("Keine Loesung moeglich!\n"); + } + + show_solution(f, len_x, len_y); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(f[c_index]); + } + free(f); + } From e0b81b5611c9bce1ea45980835d65ff971ef0be7 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:47:09 +0100 Subject: [PATCH 077/270] refactoring: labyrinth, final piece of cake --- src/main/c/labyrinth.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 221e0f7..11eaf59 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -161,28 +161,28 @@ short calculate_lab_way(Field_State** field, unsigned short len_x, unsigned shor void labyrinth(){ unsigned short len_x, len_y; - Field_State **f; + Field_State **field; ask_lab_dimensions(&len_x, &len_y); - f = malloc(len_x * sizeof *f); + field = malloc(len_x * sizeof *field); for (int c_index = 0; c_index < len_x; c_index++){ - f[c_index] = malloc(len_y * sizeof f[c_index]); + field[c_index] = malloc(len_y * sizeof field[c_index]); } - ask_lab_walls(f, len_x, len_y); + ask_lab_walls(field, len_x, len_y); - if (calculate_lab_way(f, len_x, len_y, 0, 0) == 1){ + if (calculate_lab_way(field, len_x, len_y, 0, 0) == 1){ printf("Keine Loesung moeglich!\n"); } - show_solution(f, len_x, len_y); + show_solution(field, len_x, len_y); for (int c_index = 0; c_index < len_x; c_index++) { - free(f[c_index]); + free(field[c_index]); } - free(f); + free(field); } From 128bfa21d26b2a424935637176d2be39bac6d918 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:19:55 +0100 Subject: [PATCH 078/270] 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 079/270] =?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 080/270] 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 081/270] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20initiali?= =?UTF-8?q?zeBoard?= 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 082/270] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20printBoa?= =?UTF-8?q?rd?= 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 083/270] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20clearScr?= =?UTF-8?q?een?= 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 084/270] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20isColumn?= =?UTF-8?q?Full?= 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 085/270] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20dropPiec?= =?UTF-8?q?e?= 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 086/270] =?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 087/270] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20checkHor?= =?UTF-8?q?izontal?= 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 088/270] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20checkVer?= =?UTF-8?q?tical?= 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 089/270] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20checkDia?= =?UTF-8?q?gonalLR?= 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 090/270] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20checkDia?= =?UTF-8?q?gonalRL?= 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 091/270] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20showMess?= =?UTF-8?q?age?= 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 092/270] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20showInva?= =?UTF-8?q?lidInputMessage?= 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 093/270] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20showColu?= =?UTF-8?q?mnFullMessage?= 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 094/270] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20showWinM?= =?UTF-8?q?essage?= 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 095/270] 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 096/270] 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 097/270] 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 098/270] 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 099/270] 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 100/270] 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 101/270] 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 102/270] 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 103/270] 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 104/270] 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 105/270] 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 106/270] 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 107/270] 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 108/270] 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 109/270] 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 110/270] 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 111/270] 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 112/270] 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 113/270] 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 114/270] 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 115/270] 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 116/270] 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 117/270] 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 118/270] 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 119/270] 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 120/270] 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 121/270] 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 b9c75e4a231b8a8e291434c72a4cb8d19ffe6a05 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:44:41 +0100 Subject: [PATCH 122/270] refactoring: attempts --> versuche --- src/main/c/hangman.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 2fc5f8a..03667c1 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -14,7 +14,7 @@ void startauswahl(); void nameAusgeben(); void levelauswahl(); void hauptSpiel(int level); -void draw_hangman(int attempts); +void draw_hangman(int versuche); void add_guessed_letter(char* guessed_letters, char guessed_letter); char eingabe_buchstabe(); void lade_secret_word(char* secret_word, int level, char* path); From 8c500778398edaf2cbbd1e7a6151ec66925caf00 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:45:04 +0100 Subject: [PATCH 123/270] refactoring: attempts --> versuche --- src/main/c/hangman.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 03667c1..ad7a86f 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -170,7 +170,7 @@ void levelauswahl(){ void hauptSpiel(int level){ char secret_word[100]; - int attempts = 0; + int versuche = 0; char guessed_letter; char guessed_letters[100]; char path[] = "hangman_words.txt"; @@ -179,8 +179,8 @@ void hauptSpiel(int level){ lade_secret_word(secret_word, level, path); - while (attempts < 6 && won == 0) { - draw_hangman(attempts); + while (versuche < 6 && won == 0) { + draw_hangman(versuche); show_letters(secret_word, guessed_letters); guessed_letter = eingabe_buchstabe(); result = letter_in_secret_word(guessed_letter, secret_word); @@ -188,7 +188,7 @@ void hauptSpiel(int level){ add_guessed_letter(guessed_letters, guessed_letter); } else { - attempts++; + versuche++; } won = has_won(secret_word, guessed_letters); } @@ -197,12 +197,12 @@ void hauptSpiel(int level){ } } -void draw_hangman(int attempts) { +void draw_hangman(int versuche) { clear_screen(); printf("Galgenmann!\n"); printf("v.1.0.2\n\n"); - switch(attempts) { + switch(versuche) { case 0: printf(" _______\n"); printf(" | |\n"); From 2a1e0f356ba97f57e427c2d3b3ff22616a7b3b07 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:46:41 +0100 Subject: [PATCH 124/270] refactoring: draw_hangman --> zeichne_galgen --- src/main/c/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index ad7a86f..b5fb04c 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -14,7 +14,7 @@ void startauswahl(); void nameAusgeben(); void levelauswahl(); void hauptSpiel(int level); -void draw_hangman(int versuche); +void zeichne_galgen(int versuche); void add_guessed_letter(char* guessed_letters, char guessed_letter); char eingabe_buchstabe(); void lade_secret_word(char* secret_word, int level, char* path); @@ -180,7 +180,7 @@ void hauptSpiel(int level){ lade_secret_word(secret_word, level, path); while (versuche < 6 && won == 0) { - draw_hangman(versuche); + zeichne_galgen(versuche); show_letters(secret_word, guessed_letters); guessed_letter = eingabe_buchstabe(); result = letter_in_secret_word(guessed_letter, secret_word); @@ -197,7 +197,7 @@ void hauptSpiel(int level){ } } -void draw_hangman(int versuche) { +void zeichne_galgen(int versuche) { clear_screen(); printf("Galgenmann!\n"); printf("v.1.0.2\n\n"); From d462e29b615a12b70d51e70ec65fd8a738845a38 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:48:36 +0100 Subject: [PATCH 125/270] refactoring: add_guessed_letter --> erratene_buchstaben_hinzufuegen --- src/main/c/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index b5fb04c..62fc135 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -15,7 +15,7 @@ void nameAusgeben(); void levelauswahl(); void hauptSpiel(int level); void zeichne_galgen(int versuche); -void add_guessed_letter(char* guessed_letters, char guessed_letter); +void erratenen_buchstaben_hinzufuegen(char* guessed_letters, char guessed_letter); char eingabe_buchstabe(); void lade_secret_word(char* secret_word, int level, char* path); void show_letters(char secret_word[100], char guessed_letters[100]); @@ -185,7 +185,7 @@ void hauptSpiel(int level){ guessed_letter = eingabe_buchstabe(); result = letter_in_secret_word(guessed_letter, secret_word); if (result == 0){ - add_guessed_letter(guessed_letters, guessed_letter); + erratenen_buchstaben_hinzufuegen(guessed_letters, guessed_letter); } else { versuche++; @@ -271,7 +271,7 @@ void zeichne_galgen(int versuche) { } } -void add_guessed_letter(char* guessed_letters, char guessed_letter){ +void erratenen_buchstaben_hinzufuegen(char* guessed_letters, char guessed_letter){ for (int i = 0; i < strlen(guessed_letters); i++){ if (guessed_letters[i] == guessed_letter){ return; From 745e22138d0967dbcd65de5731457b681107129f Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:50:24 +0100 Subject: [PATCH 126/270] refactoring: load_secret_word --> hole_zu_erratendes_wort --- src/main/c/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 62fc135..b558f02 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -17,7 +17,7 @@ void hauptSpiel(int level); void zeichne_galgen(int versuche); void erratenen_buchstaben_hinzufuegen(char* guessed_letters, char guessed_letter); char eingabe_buchstabe(); -void lade_secret_word(char* secret_word, int level, char* path); +void hole_zu_erratendes_wort(char* secret_word, int level, char* path); void show_letters(char secret_word[100], char guessed_letters[100]); int letter_in_secret_word(char guessed_letter, char secret_word[100]); int has_won(char secret_word[100], char guessed_letters[100]); @@ -177,7 +177,7 @@ void hauptSpiel(int level){ int result; int won = 0; - lade_secret_word(secret_word, level, path); + hole_zu_erratendes_wort(secret_word, level, path); while (versuche < 6 && won == 0) { zeichne_galgen(versuche); @@ -288,7 +288,7 @@ char eingabe_buchstabe(){ return guess; } -void lade_secret_word(char* secret_word, int level, char* path){ +void hole_zu_erratendes_wort(char* secret_word, int level, char* path){ FILE *file = fopen(path, "r"); int count = 0; if ( file != NULL ) From 416d01bce77f02f895ed86f9396248bc1149d8ab Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:51:33 +0100 Subject: [PATCH 127/270] refactoring: show_letters --> zeige_Buchstabenfeld --- src/main/c/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index b558f02..81d746d 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -18,7 +18,7 @@ void zeichne_galgen(int versuche); void erratenen_buchstaben_hinzufuegen(char* guessed_letters, char guessed_letter); char eingabe_buchstabe(); void hole_zu_erratendes_wort(char* secret_word, int level, char* path); -void show_letters(char secret_word[100], char guessed_letters[100]); +void zeige_Buchstabenfeld(char secret_word[100], char guessed_letters[100]); int letter_in_secret_word(char guessed_letter, char secret_word[100]); int has_won(char secret_word[100], char guessed_letters[100]); void level_plus(); @@ -181,7 +181,7 @@ void hauptSpiel(int level){ while (versuche < 6 && won == 0) { zeichne_galgen(versuche); - show_letters(secret_word, guessed_letters); + zeige_Buchstabenfeld(secret_word, guessed_letters); guessed_letter = eingabe_buchstabe(); result = letter_in_secret_word(guessed_letter, secret_word); if (result == 0){ @@ -311,7 +311,7 @@ void hole_zu_erratendes_wort(char* secret_word, int level, char* path){ } } -void show_letters(char secret_word[100], char guessed_letters[100]){ +void zeige_Buchstabenfeld(char secret_word[100], char guessed_letters[100]){ printf("Erratene Buchstaben: "); for(int i = 0; i < strlen(secret_word); i++) { if(strchr(guessed_letters, secret_word[i])){ From 936934f3b9f2f408073b1b8fee94b2499544f4e6 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:53:07 +0100 Subject: [PATCH 128/270] refactoring: letter_in_secret_word --> Buchstabe_im_zu_erratenden_wort --- src/main/c/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 81d746d..bc7d492 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -19,7 +19,7 @@ void erratenen_buchstaben_hinzufuegen(char* guessed_letters, char guessed_letter char eingabe_buchstabe(); void hole_zu_erratendes_wort(char* secret_word, int level, char* path); void zeige_Buchstabenfeld(char secret_word[100], char guessed_letters[100]); -int letter_in_secret_word(char guessed_letter, char secret_word[100]); +int buchstabe_im_zu_erratenden_wort(char guessed_letter, char secret_word[100]); int has_won(char secret_word[100], char guessed_letters[100]); void level_plus(); int overlay(); @@ -183,7 +183,7 @@ void hauptSpiel(int level){ zeichne_galgen(versuche); zeige_Buchstabenfeld(secret_word, guessed_letters); guessed_letter = eingabe_buchstabe(); - result = letter_in_secret_word(guessed_letter, secret_word); + result = buchstabe_im_zu_erratenden_wort(guessed_letter, secret_word); if (result == 0){ erratenen_buchstaben_hinzufuegen(guessed_letters, guessed_letter); } @@ -324,7 +324,7 @@ void zeige_Buchstabenfeld(char secret_word[100], char guessed_letters[100]){ printf("\n"); } -int letter_in_secret_word(char guessed_letter, char secret_word[100]){ +int buchstabe_im_zu_erratenden_wort(char guessed_letter, char secret_word[100]){ for(int i = 0; i < strlen(secret_word); i++){ if(guessed_letter == secret_word[i]){ return 0; From a292fb10619856bf493998aa1dd6228bbd424a97 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:54:13 +0100 Subject: [PATCH 129/270] refactoring: has_won --> gewonnen --- src/main/c/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index bc7d492..4b54af8 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -20,7 +20,7 @@ char eingabe_buchstabe(); void hole_zu_erratendes_wort(char* secret_word, int level, char* path); void zeige_Buchstabenfeld(char secret_word[100], char guessed_letters[100]); int buchstabe_im_zu_erratenden_wort(char guessed_letter, char secret_word[100]); -int has_won(char secret_word[100], char guessed_letters[100]); +int gewonnen(char secret_word[100], char guessed_letters[100]); void level_plus(); int overlay(); @@ -190,7 +190,7 @@ void hauptSpiel(int level){ else { versuche++; } - won = has_won(secret_word, guessed_letters); + won = gewonnen(secret_word, guessed_letters); } if (won == 1){ level_plus(); @@ -333,7 +333,7 @@ int buchstabe_im_zu_erratenden_wort(char guessed_letter, char secret_word[100]){ return 1; } -int has_won(char secret_word[100], char guessed_letters[100]){ +int gewonnen(char secret_word[100], char guessed_letters[100]){ int occured; for (int i = 0; i < strlen(secret_word); i++){ occured = 0; From a0de73329667ea7211ad149056d7b42744132ef9 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:56:20 +0100 Subject: [PATCH 130/270] refactoring: nameAusgeben nullt --> nullterminante --- src/main/c/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 4b54af8..1d490a4 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -118,7 +118,7 @@ void nameAusgeben(){ char name[50]; int i = 5; int zaehler = 0; - int nullt; + int nullterminante; FILE *fp = NULL; fp = fopen("hangman.txt", "r"); @@ -128,7 +128,7 @@ void nameAusgeben(){ zaehler++; i++; } - nullt = zaehler; + nullterminante = zaehler; while(zaehler != 0){ name[--zaehler] = KonfDatei[--i]; } @@ -138,7 +138,7 @@ void nameAusgeben(){ i++; } - name[nullt] = '\0'; + name[nullterminante] = '\0'; printf("%s\n", name); fclose(fp); From 34e44fbcbd3c0fb6871d95bb102013d00ec74b4b Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:05:23 +0100 Subject: [PATCH 131/270] refactoring: level --- src/main/c/hangman.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 1d490a4..41bfcda 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -351,7 +351,7 @@ int gewonnen(char secret_word[100], char guessed_letters[100]){ void level_plus(){ char KonfDatei[100]; - char levelstr[3]; + char level[3]; int i = 0; FILE *fp = NULL; @@ -361,10 +361,10 @@ void level_plus(){ while(KonfDatei[i] != 0){ i++; } - levelstr[0] = KonfDatei[i-2]; - levelstr[1] = KonfDatei[i-1]; - levelstr[2] = '\0'; - if (levelstr[1] == '9'){ + level[0] = KonfDatei[i-2]; + level[1] = KonfDatei[i-1]; + level[2] = '\0'; + if (level[1] == '9'){ KonfDatei[i-2]++; KonfDatei[i-1] = '0'; } else { From b054a28ae875235457bea447b862f600952a0f22 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:06:15 +0100 Subject: [PATCH 132/270] refactoring: galgen_overlay --- src/main/c/hangman.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 41bfcda..014302c 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -377,7 +377,7 @@ void level_plus(){ } int overlay(){ - char hangmanArt[10][41] = { + char galgen_overlay[10][41] = { " _______ ", " | | ", " | ", @@ -392,7 +392,7 @@ int overlay(){ for (int i = 0; i < 9; i++) { - printf("%s\n", hangmanArt[i]); + printf("%s\n", galgen_overlay[i]); } return 0; } \ No newline at end of file From 7786aa4f6b50a33e956c2fb79541578c3946573a Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:23:37 +0100 Subject: [PATCH 133/270] test_Buchstabe_im_zu_erratenden_wort 1 --- src/main/c/hangman.h | 23 +++++++++++++++++++++++ src/main/c/hangman.txt | 2 +- src/test/c/test_hangman_test.c | 24 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/main/c/hangman.h create mode 100644 src/test/c/test_hangman_test.c diff --git a/src/main/c/hangman.h b/src/main/c/hangman.h new file mode 100644 index 0000000..8d2ac70 --- /dev/null +++ b/src/main/c/hangman.h @@ -0,0 +1,23 @@ +#ifndef TEST_H +#define TEST_H + +void protokoll(); +void clear_screen(); +void willkommen(); +int namePruefen(); +void nameWaehlen(); +void startauswahl(); +void nameAusgeben(); +void levelauswahl(); +void hauptSpiel(int level); +void zeichne_galgen(int versuche); +void erratenen_buchstaben_hinzufuegen(char* guessed_letters, char guessed_letter); +char eingabe_buchstabe(); +void hole_zu_erratendes_wort(char* secret_word, int level, char* path); +void zeige_Buchstabenfeld(char secret_word[100], char guessed_letters[100]); +int buchstabe_im_zu_erratenden_wort(char guessed_letter, char secret_word[100]); +int gewonnen(char secret_word[100], char guessed_letters[100]); +void level_plus(); +int overlay(); + +#endif // TEST_H diff --git a/src/main/c/hangman.txt b/src/main/c/hangman.txt index 4456b2e..4e41ffd 100644 --- a/src/main/c/hangman.txt +++ b/src/main/c/hangman.txt @@ -1 +1 @@ -name:peter,level:01 \ No newline at end of file +name:peter,level:02 \ No newline at end of file diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c new file mode 100644 index 0000000..b29661a --- /dev/null +++ b/src/test/c/test_hangman_test.c @@ -0,0 +1,24 @@ +#ifdef TEST + +#include "unity.h" +#include "hangman.h" + +void setUp(void) {} + +void tearDown(void) {} + +void test_Buchstabe_im_zu_erratenden_wort_eingabe_j_in_leerstring_falsch() { + // arrange + int expected = 1; + int actual; + char guessed_letter = 'j'; + char secret_word[100] = ""; + + // act + actual = Buchstabe_im_zu_erratenden_wort(guessed_letter, secret_word); + + // assert + TEST_ASSERT_EQUAL_INT(expected, actual); +} + +#endif // TEST From dbfa72438aa84dca3d643c366d3a6e7797c55cc5 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:25:30 +0100 Subject: [PATCH 134/270] test_buchstabe_im_zu_erratenden_wort 1 richtigstellung --- src/test/c/test_hangman_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index b29661a..b84d988 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -7,7 +7,7 @@ void setUp(void) {} void tearDown(void) {} -void test_Buchstabe_im_zu_erratenden_wort_eingabe_j_in_leerstring_falsch() { +void test_buchstabe_im_zu_erratenden_wort_eingabe_j_in_leerstring_falsch() { // arrange int expected = 1; int actual; @@ -15,7 +15,7 @@ void test_Buchstabe_im_zu_erratenden_wort_eingabe_j_in_leerstring_falsch() { char secret_word[100] = ""; // act - actual = Buchstabe_im_zu_erratenden_wort(guessed_letter, secret_word); + actual = buchstabe_im_zu_erratenden_wort(guessed_letter, secret_word); // assert TEST_ASSERT_EQUAL_INT(expected, actual); From 16403a8a6fd49012d46cdcfa29342ef244d4ef06 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:26:29 +0100 Subject: [PATCH 135/270] test_buchstabe_im_zu_erratenden_wort 2 --- src/test/c/test_hangman_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index b84d988..6f70048 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -21,4 +21,18 @@ void test_buchstabe_im_zu_erratenden_wort_eingabe_j_in_leerstring_falsch() { TEST_ASSERT_EQUAL_INT(expected, actual); } +void test_buchstabe_im_zu_erratenden_wort_eingabe_j_in_joe_richtig() { + // arrange + int expected = 0; + int actual; + char guessed_letter = 'j'; + char secret_word[100] = "joe"; + + // act + actual = buchstabe_im_zu_erratenden_wort(guessed_letter, secret_word); + + // assert + TEST_ASSERT_EQUAL_INT(expected, actual); +} + #endif // TEST From 3c8a80091a6102216bd213b9f26c10f5a27dbb57 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:27:13 +0100 Subject: [PATCH 136/270] test_buchstabe_im_zu_erratenden_wort 3 --- src/test/c/test_hangman_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index 6f70048..f244008 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -35,4 +35,18 @@ void test_buchstabe_im_zu_erratenden_wort_eingabe_j_in_joe_richtig() { TEST_ASSERT_EQUAL_INT(expected, actual); } +void test_buchstabe_im_zu_erratenden_wort_eingabe_k_in_joe_falsch() { + // arrange + int expected = 1; + int actual; + char guessed_letter = 'k'; + char secret_word[100] = "joe"; + + // act + actual = buchstabe_im_zu_erratenden_wort(guessed_letter, secret_word); + + // assert + TEST_ASSERT_EQUAL_INT(expected, actual); +} + #endif // TEST From 44c23009a6ee4df11c5ed9ea0a032403e52393de Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:28:49 +0100 Subject: [PATCH 137/270] test_buchstabe_im_zu_erratenden_wort 4 --- src/test/c/test_hangman_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index f244008..a092ee3 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -49,4 +49,18 @@ void test_buchstabe_im_zu_erratenden_wort_eingabe_k_in_joe_falsch() { TEST_ASSERT_EQUAL_INT(expected, actual); } +void test_buchstabe_im_zu_erratenden_wort_eingabe_j_in_eoj_richtig() { + // arrange + int expected = 0; + int actual; + char guessed_letter = 'j'; + char secret_word[100] = "eoj"; + + // act + actual = buchstabe_im_zu_erratenden_wort(guessed_letter, secret_word); + + // assert + TEST_ASSERT_EQUAL_INT(expected, actual); +} + #endif // TEST From b4331381c018243325f5b72b918b283f594a958c Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:29:44 +0100 Subject: [PATCH 138/270] test_erratene_buchstaben_hinzufuegen 1 --- src/test/c/test_hangman_test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index a092ee3..c8fe86b 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -63,4 +63,17 @@ void test_buchstabe_im_zu_erratenden_wort_eingabe_j_in_eoj_richtig() { TEST_ASSERT_EQUAL_INT(expected, actual); } +void test_erratene_buchstaben_hinzufuegen_anhaengen_r_an_leerstring_zu_peter_richtig() { + // arrange + char expected[100] = "r"; + char actual[100] = ""; + char to_add = 'r'; + + // act + erratene_buchstaben_hinzufuegen(actual, to_add); + + // assert + TEST_ASSERT_EQUAL_STRING(expected, actual); +} + #endif // TEST From bd85f32d84e9e3ec48fd09622f4241f03bface92 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:30:49 +0100 Subject: [PATCH 139/270] test_erratene_buchstaben_hinzufuegen 1 richtigstellung --- src/test/c/test_hangman_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index c8fe86b..a799622 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -63,14 +63,14 @@ void test_buchstabe_im_zu_erratenden_wort_eingabe_j_in_eoj_richtig() { TEST_ASSERT_EQUAL_INT(expected, actual); } -void test_erratene_buchstaben_hinzufuegen_anhaengen_r_an_leerstring_zu_peter_richtig() { +void test_erratenen_buchstaben_hinzufuegen_anhaengen_r_an_leerstring_zu_peter_richtig() { // arrange char expected[100] = "r"; char actual[100] = ""; char to_add = 'r'; // act - erratene_buchstaben_hinzufuegen(actual, to_add); + erratenen_buchstaben_hinzufuegen(actual, to_add); // assert TEST_ASSERT_EQUAL_STRING(expected, actual); From 84daac09abe3602274daa279fd390a249b5c158a Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:31:44 +0100 Subject: [PATCH 140/270] test_erratene_buchstaben_hinzufuegen 2 --- src/test/c/test_hangman_test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index a799622..98308e8 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -76,4 +76,17 @@ void test_erratenen_buchstaben_hinzufuegen_anhaengen_r_an_leerstring_zu_peter_ri TEST_ASSERT_EQUAL_STRING(expected, actual); } +void test_erratenen_buchstaben_hinzufuegen_anhaengen_r_an_pete_zu_peter_richtig() { + // arrange + char expected[100] = "peter"; + char actual[100] = "pete"; + char to_add = 'r'; + + // act + erratenen_buchstaben_hinzufuegen(actual, to_add); + + // assert + TEST_ASSERT_EQUAL_STRING(expected, actual); +} + #endif // TEST From 7a4bc9f343ab331700cdc71188f61a7adec43668 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:32:22 +0100 Subject: [PATCH 141/270] test_erratene_buchstaben_hinzufuegen 3 --- src/test/c/test_hangman_test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index 98308e8..aade409 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -89,4 +89,17 @@ void test_erratenen_buchstaben_hinzufuegen_anhaengen_r_an_pete_zu_peter_richtig( TEST_ASSERT_EQUAL_STRING(expected, actual); } +void test_erratenen_buchstaben_hinzufuegen_anhaengen_r_an_peter_zu_peter_falsch() { + // arrange + char expected[100] = "peter"; + char actual[100] = "peter"; + char to_add = 'r'; + + // act + erratenen_buchstaben_hinzufuegen(actual, to_add); + + // assert + TEST_ASSERT_FALSE(expected == actual); +} + #endif // TEST From 76e514199ce4855f6d55763d0458cd600e587f0f Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:32:57 +0100 Subject: [PATCH 142/270] test_gewonnen 1 --- src/test/c/test_hangman_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index aade409..99550b1 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -102,4 +102,18 @@ void test_erratenen_buchstaben_hinzufuegen_anhaengen_r_an_peter_zu_peter_falsch( TEST_ASSERT_FALSE(expected == actual); } +void test_gewonnen_petr_in_peter_richtig() { + // arrange + int expected = 1; + char actual; + char secret_word[100] = "peter"; + char guessed_letters[100] = "petr"; + + // act + actual = gewonnen(secret_word, guessed_letters); + + // assert + TEST_ASSERT_EQUAL_INT(expected, actual); +} + #endif // TEST From c68a10ea8e048694bfb135f367d30e464d359252 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:33:23 +0100 Subject: [PATCH 143/270] test_gewonnen 2 --- src/test/c/test_hangman_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index 99550b1..07ceafa 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -116,4 +116,18 @@ void test_gewonnen_petr_in_peter_richtig() { TEST_ASSERT_EQUAL_INT(expected, actual); } +void test_gewonnen_p_in_peter_falsch() { + // arrange + int expected = 0; + char actual; + char secret_word[100] = "peter"; + char guessed_letters[100] = "p"; + + // act + actual = gewonnen(secret_word, guessed_letters); + + // assert + TEST_ASSERT_EQUAL_INT(expected, actual); +} + #endif // TEST From e8ad1176a1fa114d942c8f59ffeffc325b5b5df1 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:33:53 +0100 Subject: [PATCH 144/270] test_gewonnen 3 --- src/test/c/test_hangman_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index 07ceafa..e63bdba 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -130,4 +130,18 @@ void test_gewonnen_p_in_peter_falsch() { TEST_ASSERT_EQUAL_INT(expected, actual); } +void test_gewonnen_petr_in_leerstring_richtig() { + // arrange + int expected = 1; + char actual; + char secret_word[100] = ""; + char guessed_letters[100] = "petr"; + + // act + actual = gewonnen(secret_word, guessed_letters); + + // assert + TEST_ASSERT_EQUAL_INT(expected, actual); +} + #endif // TEST From 152fea0f0d3f47f17e9c8d348029b94965e66632 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 12:40:35 +0100 Subject: [PATCH 145/270] 1 Init Board --- src/main/c/TicTacToe.c | 14 ++++++++++++++ src/main/c/a.exe | Bin 0 -> 42690 bytes 2 files changed, 14 insertions(+) create mode 100644 src/main/c/TicTacToe.c create mode 100644 src/main/c/a.exe diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c new file mode 100644 index 0000000..e011caf --- /dev/null +++ b/src/main/c/TicTacToe.c @@ -0,0 +1,14 @@ +#include +#include +#include +#include + +// Funktion, um das Spielfeld zu initialisieren +//1 +void Brett(char Feld[3][3]) { + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + Feld[i][j] = '_'; + } + } +} \ No newline at end of file diff --git a/src/main/c/a.exe b/src/main/c/a.exe new file mode 100644 index 0000000000000000000000000000000000000000..b9e385d1dd5fc87e0a27275592ca9c71612bbfaa GIT binary patch literal 42690 zcmeIb4}4VBwJ*NU%!CXi;}9;|23^L18=!2}w^>Ez z;C%d$Knrk^GI7URR<$;}sa~xI%tdfFPUy@Q;fy=nY(Zakr$BU4V^-lLUQ6PTkOZE4 zzD}Dp34paYQ*qvaGwvX~?1ru`0(HcG;t=#?H`UuJ>g6`U|=kk$< z5}q1E;R)!GZ-xBd&jnA<2p49#!Ys^|eH|9sRI#iVm#($T&?)-lo+A)xurP~z=Aa`h z1=+~-Y{r74k{l|5UOhm1576G-*O2r%eZhk>4mj8jJ-_T>uu)5w{XKCDX~0>GyPZOdivBosErDuLwln*MxN;1gIv5Uoa}3YEbtQXqc+jWB3&rpl*8*m zuAS|D?pmT>b_G|f4zM^0NWF+huu^Y>N})xB;NW`e5)6M4pdGpm44AC*i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)g%7A!VF_EVgrTENqOO;PJpSe&85y zvudttYzyQuAs{}Wiw06nWuO~%j(pk*4|K6ePto7-FuFA{Bu)HhXyZ%CS8wpqEls94 zAAM;A6PCn(r>3J=H;qPX>E<=V<(NKTiSu27b|cJx?#ODL@fzak^Exi-Uz#IaKq>$K% zGV6VvZ9YG?8L0;_zH7z#r2g>82&HBV#|y~iiS2LBy-7sgL|r&)Z1d?@%UOemrD2+I zm!OZowPWT+oY_UEI-lRE#~WBUzp?RK_v6@Z+n*PZjnNe2hiTl{v`ryZM7+b)DekU> aVEF8u0)f%P^w2rhQWx#LTy%Z)`+os4M^G~W literal 0 HcmV?d00001 From 2107498e6bb3d070cb2aaee847fbb799bd32a4c2 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 12:41:40 +0100 Subject: [PATCH 146/270] 2 display Board --- src/main/c/TicTacToe.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index e011caf..837e2a2 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -4,11 +4,18 @@ #include // Funktion, um das Spielfeld zu initialisieren -//1 void Brett(char Feld[3][3]) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { Feld[i][j] = '_'; } } +} +void Bild(char Feld[3][3]) { + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + printf("%c ", Feld[i][j]); + } + printf("\n"); + } } \ No newline at end of file From 403fd219da53cef366d89b28afdde9d0e13e2dcc Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 12:43:01 +0100 Subject: [PATCH 147/270] 3 del old Board --- src/main/c/TicTacToe.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 837e2a2..31999f4 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -12,6 +12,11 @@ void Brett(char Feld[3][3]) { } } void Bild(char Feld[3][3]) { +#ifdef _WIN32 + system("cls"); +#else + system("clear"); +#endif for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { printf("%c ", Feld[i][j]); From 4af9a27662f2e87139e7b8b09d9e6d373d578084 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 12:45:41 +0100 Subject: [PATCH 148/270] 4 win condition row --- src/main/c/TicTacToe.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 31999f4..762fcb3 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -23,4 +23,16 @@ void Bild(char Feld[3][3]) { } printf("\n"); } +} +int Entscheiden(char Feld[3][3]) { + // Überprüfen Sieg + // Überprüfen Reihen + for (int i = 0; i < 3; i++) { + if (Feld[i][0] == Feld[i][1] && Feld[i][1] == Feld[i][2] && Feld[i][0] != '_') { + if (Feld[i][0] == 'X') { + return 1; + } + else return 2; + } + } } \ No newline at end of file From 7b8852835f197bb834d1fd62ed361d9c07510893 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 12:49:16 +0100 Subject: [PATCH 149/270] refactoring: function winner --- src/main/c/TicTacToe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 762fcb3..d6a2860 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -24,7 +24,7 @@ void Bild(char Feld[3][3]) { printf("\n"); } } -int Entscheiden(char Feld[3][3]) { +int Winner(char Feld[3][3]) { // Überprüfen Sieg // Überprüfen Reihen for (int i = 0; i < 3; i++) { From 54a3160ebe0cedbfd89f05a944fd7e8bed11bb84 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 12:57:12 +0100 Subject: [PATCH 150/270] 6 erster Test + Header --- src/main/c/TicTacToe.h | 7 +++++++ src/test/c/test_TicTacToe.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/main/c/TicTacToe.h create mode 100644 src/test/c/test_TicTacToe.c diff --git a/src/main/c/TicTacToe.h b/src/main/c/TicTacToe.h new file mode 100644 index 0000000..1e04a7d --- /dev/null +++ b/src/main/c/TicTacToe.h @@ -0,0 +1,7 @@ +#ifndef TICTACTOE_H +#define TICTACTOE_H + +int Winner(char board[3][3]); + +#endif + diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c new file mode 100644 index 0000000..b1c8b25 --- /dev/null +++ b/src/test/c/test_TicTacToe.c @@ -0,0 +1,29 @@ + +#include "unity.h" + +#include "TicTacToe.h" + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + +void test_TicTacToe_Winner_X_line_1(void) +{ + /* arrange */ + int expected = 1; + int actual; + char board[3][3] = { + {'X', 'X', 'X'}, + {'O', 'O', '_'}, + {'O', '_', '_'} + }; + /* act */ + actual = Winner(board); + + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} \ No newline at end of file From 535f9a54b0c30211d50629c07034ca212c372f54 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 13:06:34 +0100 Subject: [PATCH 151/270] 7 zweiter Test --- src/test/c/test_TicTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index b1c8b25..f8a1c62 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -26,4 +26,20 @@ void test_TicTacToe_Winner_X_line_1(void) /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); +} +void test_TicTacToe_Winner_O_line_2(void) +{ + /* arrange */ + int expected = 2; + int actual; + char board[3][3] = { + {'X', 'O', 'X'}, + {'O', 'O', 'O'}, + {'O', 'X', 'X'} + }; + /* act */ + actual = Winner(board); + + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); } \ No newline at end of file From aa593e91a3ef765f6e3933d87430ff0f5e31eb56 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 13:09:37 +0100 Subject: [PATCH 152/270] 8 dritter Test --- src/test/c/test_TicTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index f8a1c62..fc12b42 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -40,6 +40,22 @@ void test_TicTacToe_Winner_O_line_2(void) /* act */ actual = Winner(board); + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} +void test_TicTacToe_Winner_X_line_3(void) +{ + /* arrange */ + int expected = 1; + int actual; + char board[3][3] = { + {'O', '_', '_'}, + {'O', 'O', '_'}, + {'X', 'X', 'X'} + }; + /* act */ + actual = Winner(board); + /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); } \ No newline at end of file From 65918b52a6d7ba8175f401ff0e59394aa1ac138c Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 15:22:49 +0100 Subject: [PATCH 153/270] 9 win condition column --- src/main/c/TicTacToe.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index d6a2860..035d6c4 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -35,4 +35,13 @@ int Winner(char Feld[3][3]) { else return 2; } } + // Überprüfen Spalten + for (int j = 0; j < 3; j++) { + if (Feld[0][j] == Feld[1][j] && Feld[1][j] == Feld[2][j] && Feld[0][j] != '_') { + if (Feld[0][j] == 'X') { + return 1; + } + else return 2; + } + } } \ No newline at end of file From 46ae979f08ff3c39ead782c4187b01db9989c6c2 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 15:23:03 +0100 Subject: [PATCH 154/270] 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 +} + From 8b7146705acce6a764bc2b0b9901d3c1e7d4d7e1 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 15:26:03 +0100 Subject: [PATCH 155/270] 10 vierter Test --- src/test/c/test_TicTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index fc12b42..57809a8 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -56,6 +56,22 @@ void test_TicTacToe_Winner_X_line_3(void) /* act */ actual = Winner(board); + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} +void test_TicTacToe_Winner_O_col_1(void) +{ + /* arrange */ + int expected = 2; + int actual; + char board[3][3] = { + {'O', 'X', 'X'}, + {'O', 'O', '_'}, + {'O', '_', '_'} + }; + /* act */ + actual = Winner(board); + /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); } \ No newline at end of file From 6a30e7372ca7ea669dcffe32357123c608c31048 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 15:28:06 +0100 Subject: [PATCH 156/270] =?UTF-8?q?11=20f=C3=BCnfter=20Test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/c/test_TicTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index 57809a8..d65895b 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -72,6 +72,22 @@ void test_TicTacToe_Winner_O_col_1(void) /* act */ actual = Winner(board); + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} +void test_TicTacToe_Winner_X_col_2(void) +{ + /* arrange */ + int expected = 1; + int actual; + char board[3][3] = { + {'O', 'X', 'X'}, + {'_', 'X', 'O'}, + {'O', 'X', '_'} + }; + /* act */ + actual = Winner(board); + /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); } \ No newline at end of file From ff4961c714bd5b80b2078734227002a5e69e34e5 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 15:33:31 +0100 Subject: [PATCH 157/270] refactoring: change function name from showInvalidInputMessage() int showInvalidInputWarning() --- src/main/c/VierGewinnt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index c4d1419..ee289c8 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -49,7 +49,7 @@ 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(); +void showInvalidInputWarning(); //Funktionsprototyp für showColumnFullMessage void showColumnFullMessage(); @@ -72,7 +72,7 @@ int main_function() { scanf("%d", &column); if (column < 1 || column > 7) { - showInvalidInputMessage(); + showInvalidInputWarning(); continue; } @@ -233,7 +233,7 @@ void showMessage(const char* messageColor, const char* message) { } // Write showInvalidInputMessage function -void showInvalidInputMessage() { +void showInvalidInputWarning() { showMessage(RED, "Ungültige Eingabe. Bitte wähle eine Spalte zwischen 1 und 7.\n"); } From 802e23fa9bc627e49f4fea738cc39896f2cbb0a7 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 15:36:35 +0100 Subject: [PATCH 158/270] refactoring: Ausgabetext Anpassen --- src/main/c/VierGewinnt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index ee289c8..f91b268 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -242,7 +242,7 @@ void showInvalidInputWarning() { // Write showColumnFullMessage function void showColumnFullMessage() { - showMessage(RED, "Die Spalte ist voll. Bitte wähle eine andere.\n"); + showMessage(RED, "Die ausgewählte Spalte ist bereits belegt. Bitte wähle eine andere Spalte aus.\n"); } From 241aa5116b64d44149dc1d3f1ee9bd24d4052836 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 15:41:20 +0100 Subject: [PATCH 159/270] =?UTF-8?q?refactoring:=20Funktionsprototypen=20An?= =?UTF-8?q?passen=20und=20unn=C3=B6tige=20Kommentare=20l=C3=B6schen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index f91b268..65613cf 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -17,44 +17,18 @@ #define CYAN "\033[0;36m" #define WHITE "\033[0;37m" - -//Funktionsprototyp für initializeBoard +//Funktionsprototypen void initializeBoard(char board[ROWS][COLS]); - -//Funktionsprototyp für printBoard void printBoard(char board[ROWS][COLS]); - -// Funktionsprototyp für clearScreen 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); -//Funktionsprototyp für checkWin 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); - -// Funktionsprototyp für checkDiagonalLR -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); -//Funktionsprototyp für showInvalidInputMessage void showInvalidInputWarning(); - -//Funktionsprototyp für showColumnFullMessage void showColumnFullMessage(); - -//Funktionsprototyp für showWinMessage void showWinMessage(int player); From 651527c3bbe9472dc9521e19108853483de185e6 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 15:43:33 +0100 Subject: [PATCH 160/270] =?UTF-8?q?refactoring:=20unn=C3=B6tige=20Kommenta?= =?UTF-8?q?re=20l=C3=B6schen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 65613cf..88b2b33 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -32,10 +32,9 @@ void showColumnFullMessage(); void showWinMessage(int player); -//Write starter function int main_function() { char board[ROWS][COLS]; - int currentPlayer = 1; // Spieler 1 beginnt + int currentPlayer = 1; initializeBoard(board); printBoard(board); @@ -70,7 +69,6 @@ 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++) { @@ -80,7 +78,6 @@ void initializeBoard(char board[ROWS][COLS]) { } -// Write printBoard function void printBoard(char board[ROWS][COLS]) { clearScreen(); printf("\n"); @@ -99,7 +96,6 @@ 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"); @@ -108,12 +104,10 @@ void clearScreen() { #endif } -// Write isColumnFull function 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] == ' ') { @@ -122,11 +116,10 @@ int dropPiece(char board[ROWS][COLS], int col, char player) { } } - return 0; // Column is full + return 0; } -// 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++) { @@ -134,14 +127,13 @@ int checkHorizontal(char board[ROWS][COLS], char player) { board[row][col + 1] == player && board[row][col + 2] == player && board[row][col + 3] == player) { - return 1; // Gewonnen + return 1; } } } 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++) { @@ -149,7 +141,7 @@ int checkVertical(char board[ROWS][COLS], char player) { board[row + 1][col] == player && board[row + 2][col] == player && board[row + 3][col] == player) { - return 1; // Gewonnen + return 1; } } } @@ -158,7 +150,6 @@ int checkVertical(char board[ROWS][COLS], char player) { -// 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++) { @@ -166,7 +157,7 @@ int checkDiagonalLR(char board[ROWS][COLS], char player) { board[row + 1][col + 1] == player && board[row + 2][col + 2] == player && board[row + 3][col + 3] == player) { - return 1; // Gewonnen + return 1; } } } @@ -176,7 +167,6 @@ 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++) { @@ -184,7 +174,7 @@ int checkDiagonalRL(char board[ROWS][COLS], char player) { board[row + 1][col - 1] == player && board[row + 2][col - 2] == player && board[row + 3][col - 3] == player) { - return 1; // Gewonnen + return 1; } } } @@ -192,7 +182,6 @@ int checkDiagonalRL(char board[ROWS][COLS], char player) { } -// Write checkWin function int checkWin(char board[ROWS][COLS], char player) { return checkHorizontal(board, player) || checkVertical(board, player) || @@ -201,12 +190,10 @@ 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); } -// Write showInvalidInputMessage function void showInvalidInputWarning() { showMessage(RED, "Ungültige Eingabe. Bitte wähle eine Spalte zwischen 1 und 7.\n"); } @@ -214,14 +201,12 @@ void showInvalidInputWarning() { -// Write showColumnFullMessage function void showColumnFullMessage() { showMessage(RED, "Die ausgewählte Spalte ist bereits belegt. Bitte wähle eine andere Spalte aus.\n"); } -// Write showWinMessage function void showWinMessage(int player) { printf("Spieler %d hat gewonnen!\n", player); } From e4024a180d839af04327e00ad6ea77d4d13431c3 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 15:47:08 +0100 Subject: [PATCH 161/270] =?UTF-8?q?refactoring:=20=C3=84ndere=20variabel?= =?UTF-8?q?=20currentPlayer=20zu=20=20Player?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 88b2b33..711d018 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -34,14 +34,14 @@ void showWinMessage(int player); int main_function() { char board[ROWS][COLS]; - int currentPlayer = 1; + int Player = 1; initializeBoard(board); printBoard(board); int column; while (1) { - printf(YELLOW"Spieler %d, wähle eine Spalte (1-7): "RESET_COLOR, currentPlayer); + printf(YELLOW"Spieler %d, wähle eine Spalte (1-7): "RESET_COLOR, Player); scanf("%d", &column); if (column < 1 || column > 7) { @@ -56,14 +56,14 @@ int main_function() { continue; } - if (dropPiece(board, column, (currentPlayer == 1) ? 'X' : 'O')) { + if (dropPiece(board, column, (Player == 1) ? 'X' : 'O')) { printBoard(board); - if (checkWin(board, (currentPlayer == 1) ? 'X' : 'O')) { - showWinMessage(currentPlayer); + if (checkWin(board, (Player == 1) ? 'X' : 'O')) { + showWinMessage(Player); break; } - currentPlayer = (currentPlayer == 1) ? 2 : 1; + Player = (Player == 1) ? 2 : 1; } } From 382719583bd68c52c438b2a3fd0a25a6a4c684e4 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 16:03:50 +0100 Subject: [PATCH 162/270] =?UTF-8?q?refactoring:=20F=C3=BCge=20fdai-Nummer?= =?UTF-8?q?=20als=20Kommentar=20im=20Code=20f=C3=BCr=20Support=20hinzu?= 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 711d018..a9bfaa0 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -1,3 +1,5 @@ +// Author fdai7726 + //Importiere wichtige Bibliotheken #include #include From af94b552d42d531c34c80df69749694aa45a0cd7 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 16:10:57 +0100 Subject: [PATCH 163/270] =?UTF-8?q?refactoring:=20Spiel=20Beschreibung=20a?= =?UTF-8?q?ls=20Kommentar=20hinzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 a9bfaa0..e6b84cc 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -1,5 +1,17 @@ // Author fdai7726 +/* +*Ein Vier-Gewinnt-Spiel, das in der Kommandozeile gespielt wird. +*Das Programm ermöglicht es zwei Spielern, abwechselnd Steine in eine Spalte zu setzen, +*um eine Reihe von vier Steinen horizontal, +*vertikal oder diagonal zu bilden und das Spiel zu gewinnen. +*Das Spielfeld wird grafisch in der Kommandozeile dargestellt, +*und das Programm überprüft automatisch, +*ob einer der Spieler gewonnen hat oder ob das Spielfeld voll ist. + */ + + + //Importiere wichtige Bibliotheken #include #include From a7cff576b79eebb61a1f8a93eaa9dce62280c352 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 16:15:55 +0100 Subject: [PATCH 164/270] =?UTF-8?q?refactoring:=20Gewinner=20Nachrricht=20?= =?UTF-8?q?=C3=A4ndern?= 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 e6b84cc..44b22ee 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -222,7 +222,8 @@ void showColumnFullMessage() { void showWinMessage(int player) { - printf("Spieler %d hat gewonnen!\n", player); +printf("Spieler %d ist der Gewinner!\n", player); + } From 7a8cd52f0d93e9dfe5d3a9debef99c43debe7070 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 16:17:39 +0100 Subject: [PATCH 165/270] refactoring: Funktion showMessage beschreiben --- src/main/c/VierGewinnt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 44b22ee..a8609ca 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -203,7 +203,7 @@ int checkWin(char board[ROWS][COLS], char player) { checkDiagonalRL(board, player); } - +// Die Funktion showMessage gibt eine formatierte Nachricht aus, wobei die Farbe der Nachricht dynamisch festgelegt werden kann. void showMessage(const char* messageColor, const char* message) { printf("%s%s"RESET_COLOR, messageColor, message); } From 3b75ec27be04597cc58e9d1bdaf276f1a1e3534c Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 16:22:30 +0100 Subject: [PATCH 166/270] refactoring: Beschreibung der Funktion showInvalidInputWarning() --- src/main/c/VierGewinnt.c | 2 ++ src/main/c/a.out | Bin 0 -> 10336 bytes 2 files changed, 2 insertions(+) create mode 100755 src/main/c/a.out diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index a8609ca..2072110 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -208,6 +208,8 @@ void showMessage(const char* messageColor, const char* message) { printf("%s%s"RESET_COLOR, messageColor, message); } +//Die Funktion showInvalidInputWarning zeigt eine Warnung für ungültige Benutzereingaben an. Sie ruft die Funktion showMessage auf, um die Nachricht in roter Farbe auszugeben, die den Benutzer darüber informiert, dass die Eingabe ungültig ist und er eine Spalte zwischen 1 und 7 wählen soll. + void showInvalidInputWarning() { showMessage(RED, "Ungültige Eingabe. Bitte wähle eine Spalte zwischen 1 und 7.\n"); } diff --git a/src/main/c/a.out b/src/main/c/a.out new file mode 100755 index 0000000000000000000000000000000000000000..b6a2002109ba2d4eef443ffc2d731c453a0436f7 GIT binary patch literal 10336 zcmc&)e{5XGao)R=B8sFW>X$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T zek%1g z;~!f_k3Q!__I}1A_ZeLH+ZaE8zrpqSCbGR6H<1L-bj}IO zdY_0pshkSOpGjq(8B^hr)OeVGB9;_v*Az#i*-^ut1L8W#D2Z||lY}NWP4`MF?2OvS z-RPKOkH*0%C53yYQ{d998Qg;4Cd-bxZuA)i`^x#_CNIoIS2RWUa=jJvT^IHq==3b!abn~S%s6Dy~xT6SjDe^26haWZX`TkKxisJ(+M^bBB^M z=0vEa7J8NK@D^?R(BS?@584MG>$7cQYiIj${rC9b!NZRoe!|{AIJp1IsI_fh@eslq>aW`b2bfcLJj4WL##BG%h!dw(Y-rq>)TSlZn&L zfppZ3o4ZI)wsb8ynm&0r^)xu+hf|sH+?S$m3U_TPk?l<<$H!8K#*;~v1yi~BsFTe` zM;wLSO6KtdwiycdZm|7^h{G_Q)bH`)Hy1Vh233oe(~u zt*E0tx0GeyE!09iC28Mp|9;f{r$=7C8-&VwEbWW^S}9(Cfrsj(efcgCdRiEn`u$J) zF|tYI<-1Gh5X<@77yr?|jpPq7pL}--eaR!g4SBI&A^Cu00sr{ZzLDA& z`O^0kPn-#s6C(RfDgP}pgvt2GcY*w!kDuRf|92rvF)s4*{V>n%-%kEVklo~wFMVh5 z7WQ`Xv>&CuOZ&2)l)rD1zhk2LLrLrxy*~v;{u6omJC9jD2(VD+O(HMY&yn%U>x*)# z>{f7j*b_m|&?EVUoO<4qzz=LL}`UP?l7r&o%7UBRyiA1oZ@ s`9wtvkF+oI?_Yt5?Z}qWdEP(XEFmT%?Fu}P%u4bTyl=F9^T#j$-$UwV$N&HU literal 0 HcmV?d00001 From 36ba25bcdae6b6d0293e91a5a46e354fc652421e Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 16:59:34 +0100 Subject: [PATCH 167/270] 12 sechster Test --- src/test/c/test_TicTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index d65895b..f0d5ab7 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -88,6 +88,22 @@ void test_TicTacToe_Winner_X_col_2(void) /* act */ actual = Winner(board); + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} +void test_TicTacToe_Winner_O_col_3(void) +{ + /* arrange */ + int expected = 2; + int actual; + char board[3][3] = { + {'X', 'X', 'O'}, + {'_', 'O', 'O'}, + {'_', '_', 'O'} + }; + /* act */ + actual = Winner(board); + /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); } \ No newline at end of file From 47eadc816640b331792e8bbf545c6eb3fb7e5fe4 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:01:40 +0100 Subject: [PATCH 168/270] 13 win condition diagonal --- src/main/c/TicTacToe.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 035d6c4..14e960e 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -44,4 +44,13 @@ int Winner(char Feld[3][3]) { else return 2; } } + // Überprüfen Diagonalen + if ((Feld[0][0] == Feld[1][1] && Feld[1][1] == Feld[2][2]) || (Feld[0][2] == Feld[1][1] && Feld[1][1] == Feld[2][0])) { + if (Feld[1][1] != '_') { + if (Feld[1][1] == 'X') { + return 1; + } + else return 2; + } + } } \ No newline at end of file From cb7a7bc6682401d132f5734543df7d29ef286fed Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:04:28 +0100 Subject: [PATCH 169/270] 14 siebter Test --- src/test/c/test_TicTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index f0d5ab7..0dc4844 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -104,6 +104,22 @@ void test_TicTacToe_Winner_O_col_3(void) /* act */ actual = Winner(board); + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} +void test_TicTacToe_Winner_X_diagonal_1(void) +{ + /* arrange */ + int expected = 1; + int actual; + char board[3][3] = { + {'X', 'O', 'X'}, + {'O', 'X', 'O'}, + {'O', '_', 'X'} + }; + /* act */ + actual = Winner(board); + /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); } \ No newline at end of file From f1d5198ae9bcb40bb4f20ef9383d687cb4d662db Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:05:25 +0100 Subject: [PATCH 170/270] 15 achter Test --- src/test/c/test_TicTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index 0dc4844..fd80b53 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -120,6 +120,22 @@ void test_TicTacToe_Winner_X_diagonal_1(void) /* act */ actual = Winner(board); + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} +void test_TicTacToe_Winner_O_diagonal_2(void) +{ + /* arrange */ + int expected = 2; + int actual; + char board[3][3] = { + {'O', 'X', 'O'}, + {'X', 'O', 'X'}, + {'O', '_', '_'} + }; + /* act */ + actual = Winner(board); + /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); } \ No newline at end of file From 98f46f8da8299c0ac08b4137cbc4ed68112307d8 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:07:52 +0100 Subject: [PATCH 171/270] Commit 1 code --- src/main/c/sudoku.c | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/main/c/sudoku.c diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c new file mode 100644 index 0000000..8e7d480 --- /dev/null +++ b/src/main/c/sudoku.c @@ -0,0 +1,47 @@ +#include +#include +#include +#include + +#define SIZE 9 +#define EMPTY 0 +#define LEVEL_NUMBER 3 + + +int difficulty; +int selected_level; + + +void startSudoku(); //is instead of main + +void startSudoku() { + int grid[SIZE][SIZE]; + selected_level = 0; + + while (1) { + printf("\nDifficulty Function - Choose difficulty:\n"); + printf("1. Easy\n2. Medium\n3. Hard\n"); + printf("Enter the corresponding number or type 'quit' to exit: "); + + char input[10]; + scanf("%s", input); + + if (strcmp(input, "quit") == 0) { + break; + } + + difficulty = input[0] - '0'; // Convert the first character to an integer + + if ((difficulty >= 1 && difficulty <= 3) && input[1] == '\0') { + printf("Input is correct"); + } else { + printf("Invalid input. Please enter a number between 1 and 3.\n"); + } + + } +} + +int main(){ + startSudoku(); + return 0; +} \ No newline at end of file From c021ee3a8829b5e933776d571aa5f4ad99d0ab8e Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:08:24 +0100 Subject: [PATCH 172/270] 16 check round --- src/main/c/TicTacToe.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 14e960e..72f52ae 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -53,4 +53,13 @@ int Winner(char Feld[3][3]) { else return 2; } } + //Überprüfe Runde + for (int k = 0; k < 3; k++) { + for (int l = 0; l < 3; l++) { + if (Feld[k][l] == '_') { + return 9; + } + } + } + } \ No newline at end of file From 8afce67efadd0f6e1496cab71c8b59b52300517f Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:08:26 +0100 Subject: [PATCH 173/270] Commit 2 code --- src/main/c/sudoku.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 8e7d480..a065a5d 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -1,3 +1,8 @@ + + + + + #include #include #include @@ -13,6 +18,8 @@ int selected_level; void startSudoku(); //is instead of main +void availableLevelsFunction(int difficulty); + void startSudoku() { int grid[SIZE][SIZE]; @@ -33,7 +40,7 @@ void startSudoku() { difficulty = input[0] - '0'; // Convert the first character to an integer if ((difficulty >= 1 && difficulty <= 3) && input[1] == '\0') { - printf("Input is correct"); + availableLevelsFunction(difficulty); } else { printf("Invalid input. Please enter a number between 1 and 3.\n"); } @@ -41,6 +48,11 @@ void startSudoku() { } } +void availableLevelsFunction(int difficulty) { + printf("\nAvailable Levels for Difficulty %d:\n", difficulty); + +} + int main(){ startSudoku(); return 0; From 577426a70c8b2d0f5622ba0bcb3dd58c72c63ff1 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Wed, 7 Feb 2024 17:08:59 +0100 Subject: [PATCH 174/270] refactoring: labyrinth --> start_labyrinth_game --- src/main/c/labyrinth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 11eaf59..bdad7fb 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -159,7 +159,7 @@ short calculate_lab_way(Field_State** field, unsigned short len_x, unsigned shor return 1; } -void labyrinth(){ +void start_labyrinth_game(){ unsigned short len_x, len_y; Field_State **field; From 0df5a54a96546030940bf01ab52f61e5ac0a7396 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:09:52 +0100 Subject: [PATCH 175/270] Commit 3 code --- src/main/c/sudoku.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index a065a5d..4ea2db4 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -1,8 +1,6 @@ - - #include #include #include @@ -50,7 +48,9 @@ void startSudoku() { void availableLevelsFunction(int difficulty) { printf("\nAvailable Levels for Difficulty %d:\n", difficulty); - + for (int i = 0; i < LEVEL_NUMBER; i++) { + printf("%d. Level %d\n", i + 1, i + 1); + } } int main(){ From 56f81ee41ad3a3681d345b4072045f6a1d27a8ad Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:10:18 +0100 Subject: [PATCH 176/270] Commit 4 code --- src/main/c/sudoku.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 4ea2db4..dac8629 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -17,7 +17,7 @@ int selected_level; void startSudoku(); //is instead of main void availableLevelsFunction(int difficulty); - +void selectLevel(int grid[SIZE][SIZE]); void startSudoku() { int grid[SIZE][SIZE]; @@ -39,6 +39,7 @@ void startSudoku() { if ((difficulty >= 1 && difficulty <= 3) && input[1] == '\0') { availableLevelsFunction(difficulty); + selectLevel(grid); } else { printf("Invalid input. Please enter a number between 1 and 3.\n"); } @@ -53,6 +54,22 @@ void availableLevelsFunction(int difficulty) { } } + + +void selectLevel(int grid[SIZE][SIZE]) { + int level = 0; + printf("\nSelect a level:\n"); + + + +} + + + + + + + int main(){ startSudoku(); return 0; From 7dc3d6e0f94095f26fa0f86419c621263b9e2f68 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:11:20 +0100 Subject: [PATCH 177/270] Commit 5 code --- src/main/c/sudoku.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index dac8629..4329efc 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -1,6 +1,3 @@ - - - #include #include #include @@ -59,7 +56,21 @@ void availableLevelsFunction(int difficulty) { void selectLevel(int grid[SIZE][SIZE]) { int level = 0; printf("\nSelect a level:\n"); - + while (true){ + char level_select[10]; + scanf("%s", level_select); + + + level = level_select[0] - '0'; // Convert the first character to an integer + + if ((level >= 1 && level <= 3) && level_select[1] == '\0') { + printf("Input is correct"); + break; + } else { + printf("Invalid input. Please enter a number between 1 and 3.\n"); + + } + } } From 6534e2e59690fc0b5a09c1ca9f5626e75c61c8d1 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:12:27 +0100 Subject: [PATCH 178/270] Commit 6 code --- src/main/c/sudoku.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 4329efc..87089c0 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -15,6 +15,9 @@ int selected_level; void startSudoku(); //is instead of main void availableLevelsFunction(int difficulty); void selectLevel(int grid[SIZE][SIZE]); +void initializeGrid(int grid[SIZE][SIZE]); +void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level); + void startSudoku() { int grid[SIZE][SIZE]; @@ -64,17 +67,39 @@ void selectLevel(int grid[SIZE][SIZE]) { level = level_select[0] - '0'; // Convert the first character to an integer if ((level >= 1 && level <= 3) && level_select[1] == '\0') { - printf("Input is correct"); + selected_level = level; + + level--; // Adjust to 0-based index + + generateSudoku(grid, difficulty, selected_level); break; } else { printf("Invalid input. Please enter a number between 1 and 3.\n"); - + } } } +void initializeGrid(int grid[SIZE][SIZE]) { + for (int i = 0; i < SIZE; i++) { + for (int j = 0; j < SIZE; j++) { + grid[i][j] = EMPTY; + } + } +} + +void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level) { + initializeGrid(grid); + printf("Level is getting initialized"); + + +} + + + + From 4f1c6d2516f2c770dfd716e6a023692803b098b2 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:13:03 +0100 Subject: [PATCH 179/270] Commit 7 code --- src/main/c/sudoku.c | 102 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 87089c0..dcdfb7b 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -1,3 +1,6 @@ + + + #include #include #include @@ -19,6 +22,104 @@ void initializeGrid(int grid[SIZE][SIZE]); void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level); +int availableLevels[3][3][SIZE][SIZE] = { + { //easy + {{0, 0, 3, 0, 2, 1, 8, 0, 0}, + {6, 0, 0, 0, 7, 0, 1, 3, 2}, + {9, 2, 1, 5, 0, 0, 7, 6, 4}, + {7, 6, 0, 3, 0, 0, 4, 0, 0}, + {8, 5, 4, 1, 9, 7, 0, 0, 0}, + {1, 0, 0, 4, 0, 6, 0, 0, 0}, + {2, 9, 0, 8, 1, 5, 0, 0, 6}, + {0, 4, 8, 2, 0, 9, 5, 0, 0}, + {5, 0, 0, 7, 0, 3, 2, 0, 1}}, + + {{0, 0, 3, 0, 2, 1, 8, 0, 0}, + {6, 0, 0, 0, 7, 0, 1, 3, 2}, + {9, 2, 1, 5, 0, 0, 7, 6, 4}, + {7, 6, 0, 3, 0, 0, 4, 0, 0}, + {8, 5, 4, 1, 9, 7, 0, 0, 0}, + {1, 0, 0, 4, 0, 6, 0, 0, 0}, + {2, 9, 0, 8, 1, 5, 0, 0, 6}, + {0, 4, 8, 2, 0, 9, 5, 0, 0}, + {5, 0, 0, 7, 0, 3, 2, 0, 2}}, + + {{0, 0, 3, 0, 2, 1, 8, 0, 0}, + {6, 0, 0, 0, 7, 0, 1, 3, 2}, + {9, 2, 1, 5, 0, 0, 7, 6, 4}, + {7, 6, 0, 3, 0, 0, 4, 0, 0}, + {8, 5, 4, 1, 9, 7, 0, 0, 0}, + {1, 0, 0, 4, 0, 6, 0, 0, 0}, + {2, 9, 0, 8, 1, 5, 0, 0, 6}, + {0, 4, 8, 2, 0, 9, 5, 0, 0}, + {5, 0, 0, 7, 0, 3, 2, 0, 3}}}, + + {//medium + {{0, 0, 3, 0, 2, 1, 8, 0, 0}, + {6, 0, 0, 0, 7, 0, 1, 3, 2}, + {9, 2, 1, 5, 0, 0, 7, 6, 4}, + {7, 6, 0, 3, 0, 0, 4, 0, 0}, + {8, 5, 4, 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{7, 6, 0, 3, 0, 0, 4, 0, 0}, + {8, 5, 4, 1, 9, 7, 0, 0, 0}, + {1, 0, 0, 4, 0, 6, 0, 0, 0}, + {2, 9, 0, 8, 1, 5, 0, 0, 6}, + {0, 4, 8, 2, 0, 9, 5, 0, 0}, + {5, 0, 0, 7, 0, 3, 2, 0, 0}}, + + {{0, 0, 3, 0, 2, 1, 8, 0, 0}, + {6, 0, 0, 0, 7, 0, 1, 3, 2}, + {9, 2, 1, 5, 0, 0, 7, 6, 4}, + {7, 6, 0, 3, 0, 0, 4, 0, 0}, + {8, 5, 4, 1, 9, 7, 0, 0, 0}, + {1, 0, 0, 4, 0, 6, 0, 0, 0}, + {2, 9, 0, 8, 1, 5, 0, 0, 6}, + {0, 4, 8, 2, 0, 9, 5, 0, 0}, + {5, 0, 0, 7, 0, 3, 2, 0, 0}} + } +}; + + void startSudoku() { int grid[SIZE][SIZE]; selected_level = 0; @@ -93,6 +194,7 @@ void initializeGrid(int grid[SIZE][SIZE]) { void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level) { initializeGrid(grid); printf("Level is getting initialized"); + } From 818253186debf50ed4395abc36130751baa305f0 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:13:17 +0100 Subject: [PATCH 180/270] Commit 8 code --- src/main/c/sudoku.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index dcdfb7b..f877f62 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -1,6 +1,5 @@ - #include #include #include @@ -32,7 +31,7 @@ int availableLevels[3][3][SIZE][SIZE] = { {1, 0, 0, 4, 0, 6, 0, 0, 0}, {2, 9, 0, 8, 1, 5, 0, 0, 6}, {0, 4, 8, 2, 0, 9, 5, 0, 0}, - {5, 0, 0, 7, 0, 3, 2, 0, 1}}, + {5, 0, 0, 7, 0, 3, 2, 0, 0}}, {{0, 0, 3, 0, 2, 1, 8, 0, 0}, {6, 0, 0, 0, 7, 0, 1, 3, 2}, @@ -42,7 +41,7 @@ int availableLevels[3][3][SIZE][SIZE] = { {1, 0, 0, 4, 0, 6, 0, 0, 0}, {2, 9, 0, 8, 1, 5, 0, 0, 6}, {0, 4, 8, 2, 0, 9, 5, 0, 0}, - {5, 0, 0, 7, 0, 3, 2, 0, 2}}, + {5, 0, 0, 7, 0, 3, 2, 0, 0}}, {{0, 0, 3, 0, 2, 1, 8, 0, 0}, {6, 0, 0, 0, 7, 0, 1, 3, 2}, @@ -52,7 +51,7 @@ int availableLevels[3][3][SIZE][SIZE] = { {1, 0, 0, 4, 0, 6, 0, 0, 0}, {2, 9, 0, 8, 1, 5, 0, 0, 6}, {0, 4, 8, 2, 0, 9, 5, 0, 0}, - {5, 0, 0, 7, 0, 3, 2, 0, 3}}}, + {5, 0, 0, 7, 0, 3, 2, 0, 0}}}, {//medium {{0, 0, 3, 0, 2, 1, 8, 0, 0}, @@ -194,7 +193,11 @@ void initializeGrid(int grid[SIZE][SIZE]) { void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level) { initializeGrid(grid); printf("Level is getting initialized"); - + for (int i = 0; i < SIZE; i++) { + for (int j = 0; j < SIZE; j++) { + grid[i][j] = availableLevels[difficulty - 1][level - 1][i][j]; + } + } } From 1742cbf7f16893f7225547b92e5b199b4fa111cb Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:13:43 +0100 Subject: [PATCH 181/270] Commit 9 code --- src/main/c/sudoku.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index f877f62..3ee5b72 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -1,5 +1,9 @@ + + + + #include #include #include @@ -198,6 +202,12 @@ void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level) { grid[i][j] = availableLevels[difficulty - 1][level - 1][i][j]; } } + for (int i = 0; i < SIZE; i++) { + for (int j = 0; j < SIZE; j++) { + printf("%d", grid[i][j]); + } + printf("\n"); + } } From 33dbddd780357f4a286be557123ad3c314eb3808 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:13:59 +0100 Subject: [PATCH 182/270] Commit 10 code --- src/main/c/sudoku.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 3ee5b72..41f512f 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -23,6 +23,7 @@ void availableLevelsFunction(int difficulty); void selectLevel(int grid[SIZE][SIZE]); void initializeGrid(int grid[SIZE][SIZE]); void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level); +void turnFunction(int grid[SIZE][SIZE]); int availableLevels[3][3][SIZE][SIZE] = { @@ -144,6 +145,7 @@ void startSudoku() { if ((difficulty >= 1 && difficulty <= 3) && input[1] == '\0') { availableLevelsFunction(difficulty); selectLevel(grid); + turnFunction(grid); } else { printf("Invalid input. Please enter a number between 1 and 3.\n"); } @@ -196,7 +198,6 @@ void initializeGrid(int grid[SIZE][SIZE]) { void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level) { initializeGrid(grid); - printf("Level is getting initialized"); for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { grid[i][j] = availableLevels[difficulty - 1][level - 1][i][j]; @@ -212,7 +213,9 @@ void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level) { } - +void turnFunction(int grid[SIZE][SIZE]) { + printf("\nTurn function - Choose an action:\n"); +} From ee80c6e1ccab100317a22bd9b4f36ca8e25d6e2f Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:14:15 +0100 Subject: [PATCH 183/270] Commit 11 code --- src/main/c/sudoku.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 41f512f..2c82cfd 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -215,6 +215,21 @@ void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level) { void turnFunction(int grid[SIZE][SIZE]) { printf("\nTurn function - Choose an action:\n"); + + int action; + + while (true){ + char action_str[10]; + scanf("%s", action_str); + + action = action_str[0] - '0'; // Convert the first character to an integer + + if ((action >= 1 && action <= 6) && action_str[1] == '\0') { + break; + } else { + printf("Invalid input. Please enter a number between 1 and 6.\n"); + } + } } From 00504715f1d26ecb630884ac49d7dc93f9208a27 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:14:27 +0100 Subject: [PATCH 184/270] Commit 12 code --- src/main/c/sudoku.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 2c82cfd..8d0de5c 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -230,6 +230,29 @@ void turnFunction(int grid[SIZE][SIZE]) { printf("Invalid input. Please enter a number between 1 and 6.\n"); } } + + switch (action) { + case 1: + printf("Case 1.\n"); + break; + case 2: + printf("Case 2.\n"); + break; + case 3: + printf("Case 3.\n"); + break; + case 4: + printf("Case 4.\n"); + break; + case 5: + printf("Case 5.\n"); + break; + case 6: + printf("Case 6.\n"); + break; + default: + printf("Invalid input. Please enter a number between 1 and 6.\n"); + } } From 8bd82443fc0fcf84888c8186a510933a103d23bb Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:14:43 +0100 Subject: [PATCH 185/270] Commit 13 code --- src/main/c/sudoku.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 8d0de5c..7d3d57d 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -24,6 +24,7 @@ void selectLevel(int grid[SIZE][SIZE]); void initializeGrid(int grid[SIZE][SIZE]); void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level); void turnFunction(int grid[SIZE][SIZE]); +void tipFunction(int grid[SIZE][SIZE]); int availableLevels[3][3][SIZE][SIZE] = { @@ -256,7 +257,9 @@ void turnFunction(int grid[SIZE][SIZE]) { } - +void tipFunction(int grid[SIZE][SIZE]) { + printf("\nTip function - Choose an option:\n"); +} From 087ace082ea2c6fa13165fdb9865749629f85d78 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:14:57 +0100 Subject: [PATCH 186/270] Commit 14 code --- src/main/c/sudoku.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 7d3d57d..8f5f0b0 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -216,6 +216,7 @@ void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level) { void turnFunction(int grid[SIZE][SIZE]) { printf("\nTurn function - Choose an action:\n"); + printf("1. Tip function\n"); int action; @@ -234,7 +235,7 @@ void turnFunction(int grid[SIZE][SIZE]) { switch (action) { case 1: - printf("Case 1.\n"); + tipFunction(grid); break; case 2: printf("Case 2.\n"); From 95e096b756294ba49e793686dc453ad9103ff86e Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:15:00 +0100 Subject: [PATCH 187/270] 17 neuneter Test --- src/test/c/test_TicTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index fd80b53..53292e3 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -136,6 +136,22 @@ void test_TicTacToe_Winner_O_diagonal_2(void) /* act */ actual = Winner(board); + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} +void test_TicTacToe_mid_Round(void) +{ + /* arrange */ + int expected = 9; + int actual; + char board[3][3] = { + {'X', 'X', 'O'}, + {'_', 'O', 'X'}, + {'_', '_', 'O'} + }; + /* act */ + actual = Winner(board); + /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); } \ No newline at end of file From 6f35efdf81ebcfcc7ddaca03e90212d9e1a3b59d Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:15:12 +0100 Subject: [PATCH 188/270] Commit 15 code --- src/main/c/sudoku.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 8f5f0b0..5b76aca 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -260,6 +260,22 @@ void turnFunction(int grid[SIZE][SIZE]) { void tipFunction(int grid[SIZE][SIZE]) { printf("\nTip function - Choose an option:\n"); + + int option = 0; + + while (true){ + char tip_str[10]; + scanf("%s", tip_str); + + + option = tip_str[0] - '0'; // Convert the first character to an integer + + if ((option >= 1 && option <= 3) && tip_str[1] == '\0') { + break; + } else { + printf("Invalid input. Please enter a number between 1 and 3.\n"); + } + } } From c4b2846039bb1a8be76e414c420f363ba78e5344 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:15:36 +0100 Subject: [PATCH 189/270] Commit 16 code --- src/main/c/sudoku.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 5b76aca..93ec660 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -260,6 +260,10 @@ void turnFunction(int grid[SIZE][SIZE]) { void tipFunction(int grid[SIZE][SIZE]) { printf("\nTip function - Choose an option:\n"); + printf("1. Set the user-specified cell to the right value\n"); + printf("2. Set the user-specified 3x3 field to the right values\n"); + printf("3. Solve the entire puzzle for the current level\n"); + int option = 0; @@ -276,6 +280,22 @@ void tipFunction(int grid[SIZE][SIZE]) { printf("Invalid input. Please enter a number between 1 and 3.\n"); } } + + switch (option) { + case 1: + printf("Case 1\n"); + break; + + case 2: + printf("Case 2\n"); + break; + + case 3: + printf("Case 3\n"); + break; + default: + printf("Invalid option. Please enter a number between 1 and 3.\n"); + } } From e0170a538f0cbe812765af73c37a9bfc15f68e7b Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:15:49 +0100 Subject: [PATCH 190/270] Commit 17 code --- src/main/c/sudoku.c | 98 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 93ec660..560e174 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -124,6 +124,104 @@ int availableLevels[3][3][SIZE][SIZE] = { } }; +int solutionLevels[3][3][SIZE][SIZE] = { + + { //easy + {{4, 7, 3, 6, 2, 1, 8, 5, 9}, + {6, 8, 5, 9, 7, 4, 1, 3, 2}, + {9, 2, 1, 5, 3, 8, 7, 6, 4}, + {7, 6, 9, 3, 5, 2, 4, 8, 1}, + {8, 5, 4, 1, 9, 7, 6, 2, 3}, + {1, 3, 2, 4, 8, 6, 9, 7, 5}, + {2, 9, 7, 8, 1, 5, 3, 4, 6}, + {3, 4, 8, 2, 6, 9, 5, 1, 7}, + {5, 1, 6, 7, 4, 3, 2, 9, 8}}, + + {{4, 7, 3, 6, 2, 1, 8, 5, 9}, + {6, 8, 5, 9, 7, 4, 1, 3, 2}, + {9, 2, 1, 5, 3, 8, 7, 6, 4}, + {7, 6, 9, 3, 5, 2, 4, 8, 1}, + {8, 5, 4, 1, 9, 7, 6, 2, 3}, + {1, 3, 2, 4, 8, 6, 9, 7, 5}, + {2, 9, 7, 8, 1, 5, 3, 4, 6}, + {3, 4, 8, 2, 6, 9, 5, 1, 7}, + {5, 1, 6, 7, 4, 3, 2, 9, 8}}, + + {{4, 7, 3, 6, 2, 1, 8, 5, 9}, + {6, 8, 5, 9, 7, 4, 1, 3, 2}, + {9, 2, 1, 5, 3, 8, 7, 6, 4}, + {7, 6, 9, 3, 5, 2, 4,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, 1, 5, 3, 8, 7, 6, 4}, + {7, 6, 9, 3, 5, 2, 4, 8, 1}, + {8, 5, 4, 1, 9, 7, 6, 2, 3}, + {1, 3, 2, 4, 8, 6, 9, 7, 5}, + {2, 9, 7, 8, 1, 5, 3, 4, 6}, + {3, 4, 8, 2, 6, 9, 5, 1, 7}, + {5, 1, 6, 7, 4, 3, 2, 9, 8}}, + + {{4, 7, 3, 6, 2, 1, 8, 5, 9}, + {6, 8, 5, 9, 7, 4, 1, 3, 2}, + {9, 2, 1, 5, 3, 8, 7, 6, 4}, + {7, 6, 9, 3, 5, 2, 4, 8, 1}, + {8, 5, 4, 1, 9, 7, 6, 2, 3}, + {1, 3, 2, 4, 8, 6, 9, 7, 5}, + {2, 9, 7, 8, 1, 5, 3, 4, 6}, + {3, 4, 8, 2, 6, 9, 5, 1, 7}, + {5, 1, 6, 7, 4, 3, 2, 9, 8}}, + + {{4, 7, 3, 6, 2, 1, 8, 5, 9}, + {6, 8, 5, 9, 7, 4, 1, 3, 2}, + {9, 2, 1, 5, 3, 8, 7, 6, 4}, + {7, 6, 9, 3, 5, 2, 4, 8, 1}, + {8, 5, 4, 1, 9, 7, 6, 2, 3}, + {1, 3, 2, 4, 8, 6, 9, 7, 5}, + {2, 9, 7, 8, 1, 5, 3, 4, 6}, + {3, 4, 8, 2, 6, 9, 5, 1, 7}, + {5, 1, 6, 7, 4, 3, 2, 9, 8}} + } +}; + void startSudoku() { int grid[SIZE][SIZE]; From 567bb758eb4a09b3d902dda269db5530f040d532 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:16:14 +0100 Subject: [PATCH 191/270] Commit 18 code --- src/main/c/sudoku.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 560e174..792f227 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -381,7 +381,24 @@ void tipFunction(int grid[SIZE][SIZE]) { switch (option) { case 1: - printf("Case 1\n"); + printf("Enter the coordinates (row and column) separated by space:\n"); + int row, col; + + while (true){ + char row_str[10]; + char col_str[10]; + scanf("%s %s", row_str, col_str); + + + row = row_str[0] - '0'; // Convert the first character to an integer + col = col_str[0] - '0'; // Convert the first character to an integer + + if (((row >= 1 && row <= 9) && row_str[1] == '\0') && ((col >= 1 && col <= 9) && col_str[1] == '\0')) { + break; + } else { + printf("Invalid input. Please enter a number between 1 and 9.\n"); + } + } break; case 2: From f9c88ccc940acd3ed5eef5eb6e029a1545c7bc16 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:16:21 +0100 Subject: [PATCH 192/270] 18 win condition Tie --- src/main/c/TicTacToe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 72f52ae..29ac1fe 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -61,5 +61,7 @@ int Winner(char Feld[3][3]) { } } } - + //Bestätige Unendschieden + printf("Es ist ein Unendschieden\n"); + return 0; } \ No newline at end of file From 779dd7ecceb127e9ecefd61d80c8db57bb4fb20d Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:16:26 +0100 Subject: [PATCH 193/270] Commit 19 code --- src/main/c/sudoku.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 792f227..353c70b 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -399,6 +399,8 @@ void tipFunction(int grid[SIZE][SIZE]) { printf("Invalid input. Please enter a number between 1 and 9.\n"); } } + grid[row - 1][col - 1] = solutionLevels[difficulty - 1][selected_level - 1][row - 1][col - 1]; + printf("Value set successfully.\n"); break; case 2: From 7d583c0f215422d3d82dbf2c6729b0e9168c5445 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:16:37 +0100 Subject: [PATCH 194/270] Commit 20 code --- src/main/c/sudoku.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 353c70b..23ee743 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -404,7 +404,24 @@ void tipFunction(int grid[SIZE][SIZE]) { break; case 2: - printf("Case 2\n"); + printf("Enter the coordinates (top-left cell of the 3x3 field) separated by space:\n"); + int startRow, startCol; + + while (true){ + char row_squ[10]; + char col_squ[10]; + scanf("%s %s", row_squ, col_squ); + + + startRow = row_squ[0] - '0'; // Convert the first character to an integer + startCol = col_squ[0] - '0'; // Convert the first character to an integer + + if (((startRow >= 1 && startRow <= 9) && row_squ[1] == '\0') && ((startCol >= 1 && startCol <= 9) && col_squ[1] == '\0')) { + break; + } else { + printf("Invalid input. Please enter a number between 1 and 9.\n"); + } + } break; case 3: From 32a05ff7eb3c9393b5a77eb0bde1a83bdcd5721c Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:17:22 +0100 Subject: [PATCH 195/270] 19 letzter Test --- src/test/c/test_TicTacToe.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index 53292e3..a6e0cf9 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -62,18 +62,18 @@ void test_TicTacToe_Winner_X_line_3(void) void test_TicTacToe_Winner_O_col_1(void) { /* arrange */ - int expected = 2; - int actual; - char board[3][3] = { - {'O', 'X', 'X'}, - {'O', 'O', '_'}, - {'O', '_', '_'} - }; + int expected = 2; + int actual; + char board[3][3] = { + {'O', 'X', 'X'}, + {'O', 'O', '_'}, + {'O', '_', '_'} + }; /* act */ - actual = Winner(board); + actual = Winner(board); /* assert */ - TEST_ASSERT_EQUAL_INT(expected, actual); + TEST_ASSERT_EQUAL_INT(expected, actual); } void test_TicTacToe_Winner_X_col_2(void) { @@ -154,4 +154,20 @@ void test_TicTacToe_mid_Round(void) /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); -} \ No newline at end of file +} +void test_TicTacToe_Tie(void) +{ + /* arrange */ + int expected = 0; + int actual; + char board[3][3] = { + {'X', 'X', 'O'}, + {'O', 'O', 'X'}, + {'X', 'X', 'O'} + }; + /* act */ + actual = Winner(board); + + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} From 50c89e2a4485d8b574a5cb7132385af3ea28a8d9 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:18:15 +0100 Subject: [PATCH 196/270] Commit 21 code --- src/main/c/sudoku.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 23ee743..9b6b0f5 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -422,6 +422,13 @@ void tipFunction(int grid[SIZE][SIZE]) { printf("Invalid input. Please enter a number between 1 and 9.\n"); } } + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + grid[startRow - 1 + i][startCol - 1 + j] = + solutionLevels[difficulty - 1][selected_level - 1][startRow - 1 + i][startCol - 1 + j]; + } + } + printf("3x3 field set successfully.\n"); break; case 3: From 92d7f78edd282162fb1926839722b1e26a7ea17c Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:18:26 +0100 Subject: [PATCH 197/270] Commit 22 code --- src/main/c/sudoku.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 9b6b0f5..65e0e50 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -432,7 +432,12 @@ void tipFunction(int grid[SIZE][SIZE]) { break; case 3: - printf("Case 3\n"); + for (int i = 0; i < SIZE; i++) { + for (int j = 0; j < SIZE; j++) { + grid[i][j] = solutionLevels[difficulty - 1][selected_level - 1][i][j]; + } + } + printf("Puzzle solved. \n"); break; default: printf("Invalid option. Please enter a number between 1 and 3.\n"); From d8f815a58d068fd49b69b2066c40a12f9a02439d Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:18:48 +0100 Subject: [PATCH 198/270] Commit 23 code --- src/main/c/sudoku.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 65e0e50..77122dc 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -25,6 +25,7 @@ void initializeGrid(int grid[SIZE][SIZE]); void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level); void turnFunction(int grid[SIZE][SIZE]); void tipFunction(int grid[SIZE][SIZE]); +void inputFunction(int grid[SIZE][SIZE]); int availableLevels[3][3][SIZE][SIZE] = { @@ -315,6 +316,7 @@ void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level) { void turnFunction(int grid[SIZE][SIZE]) { printf("\nTurn function - Choose an action:\n"); printf("1. Tip function\n"); + printf("2. Input function\n"); int action; @@ -336,7 +338,7 @@ void turnFunction(int grid[SIZE][SIZE]) { tipFunction(grid); break; case 2: - printf("Case 2.\n"); + inputFunction(grid); break; case 3: printf("Case 3.\n"); @@ -444,7 +446,11 @@ void tipFunction(int grid[SIZE][SIZE]) { } } +void inputFunction(int grid[SIZE][SIZE]) { + printf("\nInput function - Choose an action:\n"); + +} From ec2928b40a4a5a0fa6f7b0205f3152071e112a3f Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:19:02 +0100 Subject: [PATCH 199/270] Commit 24 code --- src/main/c/sudoku.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 77122dc..705e694 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -448,8 +448,35 @@ void tipFunction(int grid[SIZE][SIZE]) { void inputFunction(int grid[SIZE][SIZE]) { printf("\nInput function - Choose an action:\n"); + printf("1. Insert value in an empty field\n"); + printf("2. Clear an already filled field\n"); - + int action; + + while (true){ + char in_str[10]; + scanf("%s", in_str); + + action = in_str[0] - '0'; // Convert the first character to an integer + + if ((action >= 1 && action <= 2) && in_str[1] == '\0') { + break; + } else { + printf("Invalid input. Please enter a number between 1 and 2.\n"); + } + } + + switch (action) { + case 1: + printf("Case 1 \n"); + break; + + case 2: + printf("Case 2 \n"); + break; + default: + printf("Invalid input. Please enter 1 or 2.\n"); + } } From 2318c9e395241f1a55c68a428170931f5b9f1cd2 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:19:14 +0100 Subject: [PATCH 200/270] Commit 25 code --- src/main/c/sudoku.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 705e694..51551e1 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -468,7 +468,24 @@ void inputFunction(int grid[SIZE][SIZE]) { switch (action) { case 1: - printf("Case 1 \n"); + printf("Enter the coordinates (row and column) separated by space:\n"); + int row_e, col_e, num; + + + while (true){ + char rowe_str[10]; + char cole_str[10]; + scanf("%s %s", rowe_str, cole_str); + + row_e = rowe_str[0] - '0'; // Convert the first character to an integer + col_e = cole_str[0] - '0'; // Convert the first character to an integer + + if (((row_e >= 1 && row_e <= 9) && rowe_str[1] == '\0') && ((col_e >= 1 && col_e <= 9) && cole_str[1] == '\0')) { + break; + } else { + printf("Invalid input. Please enter a number between 1 and 9.\n"); + } + } break; case 2: From 35fa2b71ffe3a19040104ba1a1e96d7a0eefce73 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:20:01 +0100 Subject: [PATCH 201/270] 20 move O --- src/main/c/TicTacToe.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 29ac1fe..024f326 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -3,6 +3,7 @@ #include #include +int Zaehler = 1; // Funktion, um das Spielfeld zu initialisieren void Brett(char Feld[3][3]) { for (int i = 0; i < 3; i++) { @@ -64,4 +65,11 @@ int Winner(char Feld[3][3]) { //Bestätige Unendschieden printf("Es ist ein Unendschieden\n"); return 0; +} +void Zuege(char Feld[3][3], int row, int col) { + if (Zaehler % 2 == 0) { + if (Feld[row][col] == '_') { + Feld[row][col] = 'O'; + } + } } \ No newline at end of file From 63f52c7292e4785a2af28e1acecb33add2d9e401 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:20:19 +0100 Subject: [PATCH 202/270] Commit 26 code --- src/main/c/sudoku.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 51551e1..74e1c47 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -485,6 +485,25 @@ void inputFunction(int grid[SIZE][SIZE]) { } else { printf("Invalid input. Please enter a number between 1 and 9.\n"); } + } + printf("Enter the value to insert (1-9):\n"); + + + + + while (true){ + char nume_str[10]; + scanf("%s", nume_str); + + num = nume_str[0] - '0'; // Convert the first character to an integer + + if ((num >= 1 && num <= 9) && nume_str[1] == '\0') { + grid[row_e - 1][col_e - 1] = num; + printf("Value inserted successfully.\n"); + break; + } else { + printf("Invalid input. Please enter a number between 1 and 9.\n"); + } } break; From 89a79037c483c3151741e6906844630256d93b4d Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:20:33 +0100 Subject: [PATCH 203/270] Commit 27 code --- src/main/c/sudoku.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 74e1c47..fd4b62d 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -508,11 +508,31 @@ void inputFunction(int grid[SIZE][SIZE]) { break; case 2: - printf("Case 2 \n"); + printf("Enter the coordinates (row and column) separated by space:\n"); + int row_d, col_d; + + + while (true){ + char rowd_str[10]; + char cold_str[10]; + scanf("%s %s", rowd_str, cold_str); + + row_d = rowd_str[0] - '0'; // Convert the first character to an integer + col_d = cold_str[0] - '0'; // Convert the first character to an integer + + if (((row_d >= 1 && row_d <= 9) && rowd_str[1] == '\0') && ((col_d >= 1 && col_d <= 9) && cold_str[1] == '\0')) { + grid[row_d - 1][col_d - 1] = 0; + printf("Cell cleared successfully.\n"); + break; + } else { + printf("Invalid input. Please enter a number between 1 and 9.\n"); + } + } break; default: printf("Invalid input. Please enter 1 or 2.\n"); } + } From 334825f98783cd8bdf6c839b0f2bfad2be0d2a09 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:20:41 +0100 Subject: [PATCH 204/270] 21 move X --- src/main/c/TicTacToe.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 024f326..d46d3b3 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -69,7 +69,12 @@ int Winner(char Feld[3][3]) { void Zuege(char Feld[3][3], int row, int col) { if (Zaehler % 2 == 0) { if (Feld[row][col] == '_') { - Feld[row][col] = 'O'; + Feld[row][col] = 'O'; + } + } + else { + if (Feld[row][col] == '_') { + Feld[row][col] = 'X'; } } } \ No newline at end of file From 3c7511ddfa46bd5d56f194e011c5a351b7870671 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:20:52 +0100 Subject: [PATCH 205/270] Commit 28 code --- src/main/c/sudoku.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index fd4b62d..a9e5590 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -26,6 +26,7 @@ void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level); void turnFunction(int grid[SIZE][SIZE]); void tipFunction(int grid[SIZE][SIZE]); void inputFunction(int grid[SIZE][SIZE]); +void printGrid(int grid[SIZE][SIZE]); int availableLevels[3][3][SIZE][SIZE] = { @@ -317,6 +318,7 @@ void turnFunction(int grid[SIZE][SIZE]) { printf("\nTurn function - Choose an action:\n"); printf("1. Tip function\n"); printf("2. Input function\n"); + printf("3. Print Sudoku grid\n"); int action; @@ -341,7 +343,7 @@ void turnFunction(int grid[SIZE][SIZE]) { inputFunction(grid); break; case 3: - printf("Case 3.\n"); + printGrid(grid); break; case 4: printf("Case 4.\n"); @@ -536,6 +538,16 @@ void inputFunction(int grid[SIZE][SIZE]) { } +void printGrid(int grid[SIZE][SIZE]) { + printf("\nSudoku Grid:\n"); + for (int i = 0; i < SIZE; i++) { + for (int j = 0; j < SIZE; j++) { + printf("%d ", grid[i][j]); + } + printf("\n"); + } +} + int main(){ startSudoku(); From 62fdbbc74a29d1ed04b4d57b4239ab8c6f6148e1 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:21:05 +0100 Subject: [PATCH 206/270] Commit 29 code --- src/main/c/sudoku.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index a9e5590..ddff311 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -514,7 +514,7 @@ void inputFunction(int grid[SIZE][SIZE]) { int row_d, col_d; - while (true){ + while (true){ char rowd_str[10]; char cold_str[10]; scanf("%s %s", rowd_str, cold_str); @@ -534,7 +534,7 @@ void inputFunction(int grid[SIZE][SIZE]) { default: printf("Invalid input. Please enter 1 or 2.\n"); } - + printGrid(grid); } From ed81534dea235eee339c461b0febab0aecdc7c99 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:21:22 +0100 Subject: [PATCH 207/270] Commit 30 code --- src/main/c/sudoku.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index ddff311..cc5739c 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -315,6 +315,7 @@ void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level) { } void turnFunction(int grid[SIZE][SIZE]) { + while (1) { printf("\nTurn function - Choose an action:\n"); printf("1. Tip function\n"); printf("2. Input function\n"); @@ -357,9 +358,11 @@ void turnFunction(int grid[SIZE][SIZE]) { default: printf("Invalid input. Please enter a number between 1 and 6.\n"); } + } } + void tipFunction(int grid[SIZE][SIZE]) { printf("\nTip function - Choose an option:\n"); printf("1. Set the user-specified cell to the right value\n"); From cee1f107fe2adcbaa2908c84fee7b2ca8cace614 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:21:42 +0100 Subject: [PATCH 208/270] Commit 31 code --- src/main/c/sudoku.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index cc5739c..ef28e84 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -27,6 +27,7 @@ void turnFunction(int grid[SIZE][SIZE]); void tipFunction(int grid[SIZE][SIZE]); void inputFunction(int grid[SIZE][SIZE]); void printGrid(int grid[SIZE][SIZE]); +void doneFunction(int grid[SIZE][SIZE]); int availableLevels[3][3][SIZE][SIZE] = { @@ -320,6 +321,7 @@ void turnFunction(int grid[SIZE][SIZE]) { printf("1. Tip function\n"); printf("2. Input function\n"); printf("3. Print Sudoku grid\n"); + printf("4. Done function\n"); int action; @@ -347,7 +349,7 @@ void turnFunction(int grid[SIZE][SIZE]) { printGrid(grid); break; case 4: - printf("Case 4.\n"); + doneFunction(grid); break; case 5: printf("Case 5.\n"); @@ -551,6 +553,21 @@ void printGrid(int grid[SIZE][SIZE]) { } } +void doneFunction(int grid[SIZE][SIZE]) { + printf("\nDone function - Checking if the solution is correct...\n"); + + for (int i = 0; i < SIZE; i++) { + for (int j = 0; j < SIZE; j++) { + if (grid[i][j] != solutionLevels[difficulty - 1][selected_level - 1][i][j]) { + printf("Incorrect solution. Keep trying!\n"); + return; + } + } + } + + printf("Congratulations! Sudoku is solved correctly.\n"); +} + int main(){ startSudoku(); From 36cc949e9f0e3684aa2b2efeef5c9abeed2e3bac Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:22:16 +0100 Subject: [PATCH 209/270] Commit 32 code --- src/main/c/sudoku.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index ef28e84..4f8b1ce 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -30,6 +30,7 @@ void printGrid(int grid[SIZE][SIZE]); void doneFunction(int grid[SIZE][SIZE]); + int availableLevels[3][3][SIZE][SIZE] = { { //easy {{0, 0, 3, 0, 2, 1, 8, 0, 0}, @@ -50,7 +51,7 @@ int availableLevels[3][3][SIZE][SIZE] = { {1, 0, 0, 4, 0, 6, 0, 0, 0}, {2, 9, 0, 8, 1, 5, 0, 0, 6}, {0, 4, 8, 2, 0, 9, 5, 0, 0}, - {5, 0, 0, 7, 0, 3, 2, 0, 0}}, + {5, 0, 0, 7, 0, 3, 2, 0, 2}}, {{0, 0, 3, 0, 2, 1, 8, 0, 0}, {6, 0, 0, 0, 7, 0, 1, 3, 2}, @@ -322,6 +323,7 @@ void turnFunction(int grid[SIZE][SIZE]) { printf("2. Input function\n"); printf("3. Print Sudoku grid\n"); printf("4. Done function\n"); + printf("5. Select level\n"); int action; @@ -352,7 +354,7 @@ void turnFunction(int grid[SIZE][SIZE]) { doneFunction(grid); break; case 5: - printf("Case 5.\n"); + selectLevel(grid); break; case 6: printf("Case 6.\n"); From 1e3ebab6949aa66754f42f06481e68ff810b0d5d Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:22:16 +0100 Subject: [PATCH 210/270] 22 belegtes Feld O --- src/main/c/TicTacToe.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index d46d3b3..17f75bb 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -71,6 +71,14 @@ void Zuege(char Feld[3][3], int row, int col) { if (Feld[row][col] == '_') { Feld[row][col] = 'O'; } + else { + printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); + printf("[Reihe Spalte]:"); + scanf("%d %d"); + row -= 1; + col -= 1; + Zuege(Feld, row, col); + } } else { if (Feld[row][col] == '_') { From 4a2a0afae351b73636fae67f4f723ee7f996b0e5 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:22:46 +0100 Subject: [PATCH 211/270] Commit 33 code --- src/main/c/sudoku.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 4f8b1ce..6ea434e 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -9,6 +9,7 @@ #include #include + #define SIZE 9 #define EMPTY 0 #define LEVEL_NUMBER 3 @@ -324,6 +325,7 @@ void turnFunction(int grid[SIZE][SIZE]) { printf("3. Print Sudoku grid\n"); printf("4. Done function\n"); printf("5. Select level\n"); + printf("6. Quit\n"); int action; @@ -357,8 +359,8 @@ void turnFunction(int grid[SIZE][SIZE]) { selectLevel(grid); break; case 6: - printf("Case 6.\n"); - break; + printf("Exiting Sudoku program.\n"); + exit(0); default: printf("Invalid input. Please enter a number between 1 and 6.\n"); } From 6052ef0c2db46e057aa3d43dfa7098c44ae6b851 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:22:56 +0100 Subject: [PATCH 212/270] 23 belegtes Feld X --- src/main/c/TicTacToe.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 17f75bb..c4de506 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -25,7 +25,8 @@ void Bild(char Feld[3][3]) { printf("\n"); } } -int Winner(char Feld[3][3]) { +int Winner +(char Feld[3][3]) { // Überprüfen Sieg // Überprüfen Reihen for (int i = 0; i < 3; i++) { @@ -69,7 +70,7 @@ int Winner(char Feld[3][3]) { void Zuege(char Feld[3][3], int row, int col) { if (Zaehler % 2 == 0) { if (Feld[row][col] == '_') { - Feld[row][col] = 'O'; + Feld[row][col] = 'O'; } else { printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); @@ -84,5 +85,13 @@ void Zuege(char Feld[3][3], int row, int col) { if (Feld[row][col] == '_') { Feld[row][col] = 'X'; } + else { + printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); + printf("[Reihe Spalte]:"); + scanf("%d %d"); + row -= 1; + col -= 1; + Zuege(Feld, row, col); + } } } \ No newline at end of file From 6f0245fd3b47f6a558700093d84b9d850f165af9 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:24:23 +0100 Subject: [PATCH 213/270] 24 start Hauptfunktion --- src/main/c/TicTacToe.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index c4de506..ed21c57 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -25,8 +25,7 @@ void Bild(char Feld[3][3]) { printf("\n"); } } -int Winner -(char Feld[3][3]) { +int Winner(char Feld[3][3]) { // Überprüfen Sieg // Überprüfen Reihen for (int i = 0; i < 3; i++) { @@ -94,4 +93,21 @@ void Zuege(char Feld[3][3], int row, int col) { Zuege(Feld, row, col); } } +} +// Hauptfunktion zum Spielen des Tic Tac Toe-Spiels +int mainx() { + int row; + int col; + char Feld[3][3]; + Brett(Feld); + Bild(Feld); + if (Zaehler % 2 != 0) { + printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); + } + else printf("Spieler 2 gebe das Feld an wo du dein O setzen willst.\n"); + printf("[Reihe Spalte]:"); + scanf("%d %d"); + row -= 1; + col -= 1; + Zuege(Feld, row, col); } \ No newline at end of file From 0eb3a3f1a62b7d3dbc85f6bf000c2fa128851960 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:25:26 +0100 Subject: [PATCH 214/270] 25 Nachfrage optimiert --- src/main/c/TicTacToe.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index ed21c57..8f3df43 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -105,8 +105,10 @@ int mainx() { printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); } else printf("Spieler 2 gebe das Feld an wo du dein O setzen willst.\n"); - printf("[Reihe Spalte]:"); - scanf("%d %d"); + printf("Reihe:"); + scanf("%d", &row); + printf("Spalte:"); + scanf("%d", &col); row -= 1; col -= 1; Zuege(Feld, row, col); From b918a40c3bb57463aed6e43edc9c5467aeb3a17b Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:32:07 +0100 Subject: [PATCH 215/270] refactoring: 1 --- src/main/c/sudoku.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 6ea434e..1b0827d 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -9,7 +9,6 @@ #include #include - #define SIZE 9 #define EMPTY 0 #define LEVEL_NUMBER 3 @@ -20,7 +19,7 @@ int selected_level; void startSudoku(); //is instead of main -void availableLevelsFunction(int difficulty); +void Level_Pool(int difficulty); void selectLevel(int grid[SIZE][SIZE]); void initializeGrid(int grid[SIZE][SIZE]); void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level); @@ -247,7 +246,7 @@ void startSudoku() { difficulty = input[0] - '0'; // Convert the first character to an integer if ((difficulty >= 1 && difficulty <= 3) && input[1] == '\0') { - availableLevelsFunction(difficulty); + Level_Pool(difficulty); selectLevel(grid); turnFunction(grid); } else { @@ -257,7 +256,7 @@ void startSudoku() { } } -void availableLevelsFunction(int difficulty) { +void Level_Pool(int difficulty) { printf("\nAvailable Levels for Difficulty %d:\n", difficulty); for (int i = 0; i < LEVEL_NUMBER; i++) { printf("%d. Level %d\n", i + 1, i + 1); From cef6f153b9cffe17bd1a3901d8abd561a9bfe0b7 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:32:47 +0100 Subject: [PATCH 216/270] refactoring: 2 --- src/main/c/sudoku.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 1b0827d..ee41b13 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -18,7 +18,7 @@ int difficulty; int selected_level; -void startSudoku(); //is instead of main +void Game_loop(); //is instead of main void Level_Pool(int difficulty); void selectLevel(int grid[SIZE][SIZE]); void initializeGrid(int grid[SIZE][SIZE]); @@ -227,7 +227,7 @@ int solutionLevels[3][3][SIZE][SIZE] = { }; -void startSudoku() { +void Game_loop() { int grid[SIZE][SIZE]; selected_level = 0; @@ -573,6 +573,6 @@ void doneFunction(int grid[SIZE][SIZE]) { int main(){ - startSudoku(); + Game_loop(); return 0; } \ No newline at end of file From 1b26c155545ba2c8f13dd04d4c8362f06caa8742 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:33:05 +0100 Subject: [PATCH 217/270] refactoring: 3 --- src/main/c/sudoku.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index ee41b13..d7f0b73 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -22,7 +22,7 @@ void Game_loop(); //is instead of main void Level_Pool(int difficulty); void selectLevel(int grid[SIZE][SIZE]); void initializeGrid(int grid[SIZE][SIZE]); -void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level); +void create_playing_field(int grid[SIZE][SIZE], int difficulty, int level); void turnFunction(int grid[SIZE][SIZE]); void tipFunction(int grid[SIZE][SIZE]); void inputFunction(int grid[SIZE][SIZE]); @@ -280,7 +280,7 @@ void selectLevel(int grid[SIZE][SIZE]) { level--; // Adjust to 0-based index - generateSudoku(grid, difficulty, selected_level); + create_playing_field(grid, difficulty, selected_level); break; } else { printf("Invalid input. Please enter a number between 1 and 3.\n"); @@ -299,7 +299,7 @@ void initializeGrid(int grid[SIZE][SIZE]) { } } -void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level) { +void create_playing_field(int grid[SIZE][SIZE], int difficulty, int level) { initializeGrid(grid); for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { From 61fcead70dd2b029baba6a4bfc2b64f91899878a Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:33:18 +0100 Subject: [PATCH 218/270] refactoring: 4 --- src/main/c/sudoku.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index d7f0b73..81849ef 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -23,7 +23,7 @@ void Level_Pool(int difficulty); void selectLevel(int grid[SIZE][SIZE]); void initializeGrid(int grid[SIZE][SIZE]); void create_playing_field(int grid[SIZE][SIZE], int difficulty, int level); -void turnFunction(int grid[SIZE][SIZE]); +void Player_actions_for_playing(int grid[SIZE][SIZE]); void tipFunction(int grid[SIZE][SIZE]); void inputFunction(int grid[SIZE][SIZE]); void printGrid(int grid[SIZE][SIZE]); @@ -248,7 +248,7 @@ void Game_loop() { if ((difficulty >= 1 && difficulty <= 3) && input[1] == '\0') { Level_Pool(difficulty); selectLevel(grid); - turnFunction(grid); + Player_actions_for_playing(grid); } else { printf("Invalid input. Please enter a number between 1 and 3.\n"); } @@ -316,7 +316,7 @@ void create_playing_field(int grid[SIZE][SIZE], int difficulty, int level) { } -void turnFunction(int grid[SIZE][SIZE]) { +void Player_actions_for_playing(int grid[SIZE][SIZE]) { while (1) { printf("\nTurn function - Choose an action:\n"); printf("1. Tip function\n"); From 49c76d644c522b85fdeffe4030039b479e95b844 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:33:33 +0100 Subject: [PATCH 219/270] refactoring: 5 --- src/main/c/sudoku.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 81849ef..969ecdd 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -24,7 +24,7 @@ void selectLevel(int grid[SIZE][SIZE]); void initializeGrid(int grid[SIZE][SIZE]); void create_playing_field(int grid[SIZE][SIZE], int difficulty, int level); void Player_actions_for_playing(int grid[SIZE][SIZE]); -void tipFunction(int grid[SIZE][SIZE]); +void giving_hints_to_player(int grid[SIZE][SIZE]); void inputFunction(int grid[SIZE][SIZE]); void printGrid(int grid[SIZE][SIZE]); void doneFunction(int grid[SIZE][SIZE]); @@ -319,7 +319,7 @@ void create_playing_field(int grid[SIZE][SIZE], int difficulty, int level) { void Player_actions_for_playing(int grid[SIZE][SIZE]) { while (1) { printf("\nTurn function - Choose an action:\n"); - printf("1. Tip function\n"); + printf("1. Hints\n"); printf("2. Input function\n"); printf("3. Print Sudoku grid\n"); printf("4. Done function\n"); @@ -343,7 +343,7 @@ void Player_actions_for_playing(int grid[SIZE][SIZE]) { switch (action) { case 1: - tipFunction(grid); + giving_hints_to_player(grid); break; case 2: inputFunction(grid); @@ -368,7 +368,7 @@ void Player_actions_for_playing(int grid[SIZE][SIZE]) { -void tipFunction(int grid[SIZE][SIZE]) { +void giving_hints_to_player(int grid[SIZE][SIZE]) { printf("\nTip function - Choose an option:\n"); printf("1. Set the user-specified cell to the right value\n"); printf("2. Set the user-specified 3x3 field to the right values\n"); From d90a870e07c57a086bcaea5fc49afcf517dd6c43 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:34:01 +0100 Subject: [PATCH 220/270] refactoring: 6 --- src/main/c/sudoku.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 969ecdd..81226e5 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -25,7 +25,7 @@ void initializeGrid(int grid[SIZE][SIZE]); void create_playing_field(int grid[SIZE][SIZE], int difficulty, int level); void Player_actions_for_playing(int grid[SIZE][SIZE]); void giving_hints_to_player(int grid[SIZE][SIZE]); -void inputFunction(int grid[SIZE][SIZE]); +void write_userinput_into_Sudoku(int grid[SIZE][SIZE]); void printGrid(int grid[SIZE][SIZE]); void doneFunction(int grid[SIZE][SIZE]); @@ -320,7 +320,7 @@ void Player_actions_for_playing(int grid[SIZE][SIZE]) { while (1) { printf("\nTurn function - Choose an action:\n"); printf("1. Hints\n"); - printf("2. Input function\n"); + printf("2. Insert Number into Game\n"); printf("3. Print Sudoku grid\n"); printf("4. Done function\n"); printf("5. Select level\n"); @@ -346,7 +346,7 @@ void Player_actions_for_playing(int grid[SIZE][SIZE]) { giving_hints_to_player(grid); break; case 2: - inputFunction(grid); + write_userinput_into_Sudoku(grid); break; case 3: printGrid(grid); @@ -456,7 +456,7 @@ void giving_hints_to_player(int grid[SIZE][SIZE]) { } } -void inputFunction(int grid[SIZE][SIZE]) { +void write_userinput_into_Sudoku(int grid[SIZE][SIZE]) { printf("\nInput function - Choose an action:\n"); printf("1. Insert value in an empty field\n"); printf("2. Clear an already filled field\n"); From a3994e08f70b7c99cf7f674a7d0547a7f2c1ddc5 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:34:15 +0100 Subject: [PATCH 221/270] refactoring: 7 --- src/main/c/sudoku.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 81226e5..5d06bbe 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -27,7 +27,7 @@ void Player_actions_for_playing(int grid[SIZE][SIZE]); void giving_hints_to_player(int grid[SIZE][SIZE]); void write_userinput_into_Sudoku(int grid[SIZE][SIZE]); void printGrid(int grid[SIZE][SIZE]); -void doneFunction(int grid[SIZE][SIZE]); +void check_if_Sudoku_solved(int grid[SIZE][SIZE]); @@ -322,7 +322,7 @@ void Player_actions_for_playing(int grid[SIZE][SIZE]) { printf("1. Hints\n"); printf("2. Insert Number into Game\n"); printf("3. Print Sudoku grid\n"); - printf("4. Done function\n"); + printf("4. Check if your Solution is correct\n"); printf("5. Select level\n"); printf("6. Quit\n"); @@ -352,7 +352,7 @@ void Player_actions_for_playing(int grid[SIZE][SIZE]) { printGrid(grid); break; case 4: - doneFunction(grid); + check_if_Sudoku_solved(grid); break; case 5: selectLevel(grid); @@ -556,7 +556,7 @@ void printGrid(int grid[SIZE][SIZE]) { } } -void doneFunction(int grid[SIZE][SIZE]) { +void check_if_Sudoku_solved(int grid[SIZE][SIZE]) { printf("\nDone function - Checking if the solution is correct...\n"); for (int i = 0; i < SIZE; i++) { From 47f98ef25ecded93b43fdef321ef34fac3b04408 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:34:39 +0100 Subject: [PATCH 222/270] refactoring: 8 --- src/main/c/sudoku.c | 71 +++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 38 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 5d06bbe..21fba11 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -1,15 +1,10 @@ - - - - - - #include #include #include #include -#define SIZE 9 +#define SIZE_OF_GAMEBORD_AXIS_X 9 +#define SIZE_OF_GAMEBORD_AXIS_Y 9 #define EMPTY 0 #define LEVEL_NUMBER 3 @@ -20,18 +15,18 @@ int selected_level; void Game_loop(); //is instead of main void Level_Pool(int difficulty); -void selectLevel(int grid[SIZE][SIZE]); -void initializeGrid(int grid[SIZE][SIZE]); -void create_playing_field(int grid[SIZE][SIZE], int difficulty, int level); -void Player_actions_for_playing(int grid[SIZE][SIZE]); -void giving_hints_to_player(int grid[SIZE][SIZE]); -void write_userinput_into_Sudoku(int grid[SIZE][SIZE]); -void printGrid(int grid[SIZE][SIZE]); -void check_if_Sudoku_solved(int grid[SIZE][SIZE]); +void selectLevel(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void initializeGrid(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void create_playing_field(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y], int difficulty, int level); +void Player_actions_for_playing(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void giving_hints_to_player(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void write_userinput_into_Sudoku(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void printGrid(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void check_if_Sudoku_solved(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); -int availableLevels[3][3][SIZE][SIZE] = { +int availableLevels[3][3][SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = { { //easy {{0, 0, 3, 0, 2, 1, 8, 0, 0}, {6, 0, 0, 0, 7, 0, 1, 3, 2}, @@ -128,7 +123,7 @@ int availableLevels[3][3][SIZE][SIZE] = { } }; -int solutionLevels[3][3][SIZE][SIZE] = { +int solutionLevels[3][3][SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = { { //easy {{4, 7, 3, 6, 2, 1, 8, 5, 9}, @@ -228,7 +223,7 @@ int solutionLevels[3][3][SIZE][SIZE] = { void Game_loop() { - int grid[SIZE][SIZE]; + int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]; selected_level = 0; while (1) { @@ -265,7 +260,7 @@ void Level_Pool(int difficulty) { -void selectLevel(int grid[SIZE][SIZE]) { +void selectLevel(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { int level = 0; printf("\nSelect a level:\n"); while (true){ @@ -291,23 +286,23 @@ void selectLevel(int grid[SIZE][SIZE]) { } -void initializeGrid(int grid[SIZE][SIZE]) { - for (int i = 0; i < SIZE; i++) { - for (int j = 0; j < SIZE; j++) { +void initializeGrid(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { + for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; i++) { + for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; j++) { grid[i][j] = EMPTY; } } } -void create_playing_field(int grid[SIZE][SIZE], int difficulty, int level) { +void create_playing_field(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y], int difficulty, int level) { initializeGrid(grid); - for (int i = 0; i < SIZE; i++) { - for (int j = 0; j < SIZE; j++) { + for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; i++) { + for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; j++) { grid[i][j] = availableLevels[difficulty - 1][level - 1][i][j]; } } - for (int i = 0; i < SIZE; i++) { - for (int j = 0; j < SIZE; j++) { + for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; i++) { + for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; j++) { printf("%d", grid[i][j]); } printf("\n"); @@ -316,7 +311,7 @@ void create_playing_field(int grid[SIZE][SIZE], int difficulty, int level) { } -void Player_actions_for_playing(int grid[SIZE][SIZE]) { +void Player_actions_for_playing(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { while (1) { printf("\nTurn function - Choose an action:\n"); printf("1. Hints\n"); @@ -368,7 +363,7 @@ void Player_actions_for_playing(int grid[SIZE][SIZE]) { -void giving_hints_to_player(int grid[SIZE][SIZE]) { +void giving_hints_to_player(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { printf("\nTip function - Choose an option:\n"); printf("1. Set the user-specified cell to the right value\n"); printf("2. Set the user-specified 3x3 field to the right values\n"); @@ -444,8 +439,8 @@ void giving_hints_to_player(int grid[SIZE][SIZE]) { break; case 3: - for (int i = 0; i < SIZE; i++) { - for (int j = 0; j < SIZE; j++) { + for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; i++) { + for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; j++) { grid[i][j] = solutionLevels[difficulty - 1][selected_level - 1][i][j]; } } @@ -456,7 +451,7 @@ void giving_hints_to_player(int grid[SIZE][SIZE]) { } } -void write_userinput_into_Sudoku(int grid[SIZE][SIZE]) { +void write_userinput_into_Sudoku(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { printf("\nInput function - Choose an action:\n"); printf("1. Insert value in an empty field\n"); printf("2. Clear an already filled field\n"); @@ -546,21 +541,21 @@ void write_userinput_into_Sudoku(int grid[SIZE][SIZE]) { } -void printGrid(int grid[SIZE][SIZE]) { +void printGrid(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { printf("\nSudoku Grid:\n"); - for (int i = 0; i < SIZE; i++) { - for (int j = 0; j < SIZE; j++) { + for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; i++) { + for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; j++) { printf("%d ", grid[i][j]); } printf("\n"); } } -void check_if_Sudoku_solved(int grid[SIZE][SIZE]) { +void check_if_Sudoku_solved(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { printf("\nDone function - Checking if the solution is correct...\n"); - for (int i = 0; i < SIZE; i++) { - for (int j = 0; j < SIZE; j++) { + for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; i++) { + for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; j++) { if (grid[i][j] != solutionLevels[difficulty - 1][selected_level - 1][i][j]) { printf("Incorrect solution. Keep trying!\n"); return; From 0fb4fe3a04784ec811cc959e150f28c7a0551a49 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:34:53 +0100 Subject: [PATCH 223/270] refactoring: 9 --- src/main/c/sudoku.c | 256 ++++++++++++++++++++++---------------------- 1 file changed, 128 insertions(+), 128 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 21fba11..1b134a1 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -38,88 +38,88 @@ int availableLevels[3][3][SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = { {0, 4, 8, 2, 0, 9, 5, 0, 0}, {5, 0, 0, 7, 0, 3, 2, 0, 0}}, - {{0, 0, 3, 0, 2, 1, 8, 0, 0}, - {6, 0, 0, 0, 7, 0, 1, 3, 2}, - {9, 2, 1, 5, 0, 0, 7, 6, 4}, - {7, 6, 0, 3, 0, 0, 4, 0, 0}, - {8, 5, 4, 1, 9, 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, 9, 5, 6, 2, 4, 8, 1}, + {8, 9, 7, 2, 1, 4, 3, 6, 5}, + {6, 2, 3, 8, 9, 5, 1, 7, 4}, + {4, 5, 1, 3, 7, 6, 8, 9, 2}}, + + {{4, 2, 5, 6, 9, 7, 1, 3, 8}, + {8, 7, 9, 1, 5, 3, 4, 2, 6}, + {3, 6, 1, 4, 8, 2, 7, 5, 9}, + {1, 5, 2, 7, 3, 9, 8, 6, 4}, + {7, 4, 8, 5, 2, 6, 9, 1, 3}, + {9, 3, 6, 8, 4, 1, 5, 7, 2}, + {2, 8, 7, 9, 6, 5, 3, 4, 1}, + {6, 1, 4, 3, 7, 8, 2, 9, 5}, + {5, 9, 3, 2, 1, 4, 6, 8, 7}} } }; From 590a568535d57886cf2e0e19c3e78165d1c9c0b5 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:35:18 +0100 Subject: [PATCH 224/270] refactoring: 10 --- src/main/c/sudoku.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 1b134a1..975a080 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -3,6 +3,7 @@ #include #include + #define SIZE_OF_GAMEBORD_AXIS_X 9 #define SIZE_OF_GAMEBORD_AXIS_Y 9 #define EMPTY 0 @@ -15,7 +16,7 @@ int selected_level; void Game_loop(); //is instead of main void Level_Pool(int difficulty); -void selectLevel(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void Level_Selection(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); void initializeGrid(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); void create_playing_field(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y], int difficulty, int level); void Player_actions_for_playing(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); @@ -242,7 +243,7 @@ void Game_loop() { if ((difficulty >= 1 && difficulty <= 3) && input[1] == '\0') { Level_Pool(difficulty); - selectLevel(grid); + Level_Selection(grid); Player_actions_for_playing(grid); } else { printf("Invalid input. Please enter a number between 1 and 3.\n"); @@ -260,7 +261,7 @@ void Level_Pool(int difficulty) { -void selectLevel(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { +void Level_Selection(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { int level = 0; printf("\nSelect a level:\n"); while (true){ @@ -350,7 +351,7 @@ void Player_actions_for_playing(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBO check_if_Sudoku_solved(grid); break; case 5: - selectLevel(grid); + Level_Selection(grid); break; case 6: printf("Exiting Sudoku program.\n"); From 4e7375160bf9ffbf07e76a7bc0985cb430d72ad6 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:35:36 +0100 Subject: [PATCH 225/270] refactoring: 11 --- src/main/c/sudoku.c | 96 +++++++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 975a080..f18284d 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -6,28 +6,30 @@ #define SIZE_OF_GAMEBORD_AXIS_X 9 #define SIZE_OF_GAMEBORD_AXIS_Y 9 +#define AVAILABLE_DIFFICULTIES 3 +#define AVAILABLE_LEVELS 3 #define EMPTY 0 #define LEVEL_NUMBER 3 -int difficulty; +int selected_difficulty; int selected_level; void Game_loop(); //is instead of main -void Level_Pool(int difficulty); -void Level_Selection(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); -void initializeGrid(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); -void create_playing_field(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y], int difficulty, int level); -void Player_actions_for_playing(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); -void giving_hints_to_player(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); -void write_userinput_into_Sudoku(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); -void printGrid(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); -void check_if_Sudoku_solved(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void Level_Pool(int selected_difficulty); +void Level_Selection(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void initializeGrid(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void create_playing_field(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y], int selected_difficulty, int level); +void Player_actions_for_playing(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void giving_hints_to_player(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void write_userinput_into_Sudoku(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void printGrid(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void check_if_Sudoku_solved(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); -int availableLevels[3][3][SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = { +int availableLevels[AVAILABLE_DIFFICULTIES][AVAILABLE_LEVELS][SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = { { //easy {{0, 0, 3, 0, 2, 1, 8, 0, 0}, {6, 0, 0, 0, 7, 0, 1, 3, 2}, @@ -124,7 +126,7 @@ int availableLevels[3][3][SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = { } }; -int solutionLevels[3][3][SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = { +int solutionLevels[AVAILABLE_DIFFICULTIES][AVAILABLE_LEVELS][SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = { { //easy {{4, 7, 3, 6, 2, 1, 8, 5, 9}, @@ -224,7 +226,7 @@ int solutionLevels[3][3][SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = { void Game_loop() { - int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]; + int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]; selected_level = 0; while (1) { @@ -239,12 +241,12 @@ void Game_loop() { break; } - difficulty = input[0] - '0'; // Convert the first character to an integer + selected_difficulty = input[0] - '0'; // Convert the first character to an integer - if ((difficulty >= 1 && difficulty <= 3) && input[1] == '\0') { - Level_Pool(difficulty); - Level_Selection(grid); - Player_actions_for_playing(grid); + if ((selected_difficulty >= 1 && selected_difficulty <= 3) && input[1] == '\0') { + Level_Pool(selected_difficulty); + Level_Selection(Sudoku_grid); + Player_actions_for_playing(Sudoku_grid); } else { printf("Invalid input. Please enter a number between 1 and 3.\n"); } @@ -252,8 +254,8 @@ void Game_loop() { } } -void Level_Pool(int difficulty) { - printf("\nAvailable Levels for Difficulty %d:\n", difficulty); +void Level_Pool(int selected_difficulty) { + printf("\nAvailable Levels for Difficulty %d:\n", selected_difficulty); for (int i = 0; i < LEVEL_NUMBER; i++) { printf("%d. Level %d\n", i + 1, i + 1); } @@ -261,7 +263,7 @@ void Level_Pool(int difficulty) { -void Level_Selection(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { +void Level_Selection(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { int level = 0; printf("\nSelect a level:\n"); while (true){ @@ -276,7 +278,7 @@ void Level_Selection(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) level--; // Adjust to 0-based index - create_playing_field(grid, difficulty, selected_level); + create_playing_field(Sudoku_grid, selected_difficulty, selected_level); break; } else { printf("Invalid input. Please enter a number between 1 and 3.\n"); @@ -287,24 +289,24 @@ void Level_Selection(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) } -void initializeGrid(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { +void initializeGrid(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; i++) { for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; j++) { - grid[i][j] = EMPTY; + Sudoku_grid[i][j] = EMPTY; } } } -void create_playing_field(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y], int difficulty, int level) { - initializeGrid(grid); +void create_playing_field(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y], int selected_difficulty, int level) { + initializeGrid(Sudoku_grid); for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; i++) { for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; j++) { - grid[i][j] = availableLevels[difficulty - 1][level - 1][i][j]; + Sudoku_grid[i][j] = availableLevels[selected_difficulty - 1][level - 1][i][j]; } } for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; i++) { for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; j++) { - printf("%d", grid[i][j]); + printf("%d", Sudoku_grid[i][j]); } printf("\n"); } @@ -312,7 +314,7 @@ void create_playing_field(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXI } -void Player_actions_for_playing(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { +void Player_actions_for_playing(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { while (1) { printf("\nTurn function - Choose an action:\n"); printf("1. Hints\n"); @@ -339,19 +341,19 @@ void Player_actions_for_playing(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBO switch (action) { case 1: - giving_hints_to_player(grid); + giving_hints_to_player(Sudoku_grid); break; case 2: - write_userinput_into_Sudoku(grid); + write_userinput_into_Sudoku(Sudoku_grid); break; case 3: - printGrid(grid); + printGrid(Sudoku_grid); break; case 4: - check_if_Sudoku_solved(grid); + check_if_Sudoku_solved(Sudoku_grid); break; case 5: - Level_Selection(grid); + Level_Selection(Sudoku_grid); break; case 6: printf("Exiting Sudoku program.\n"); @@ -364,7 +366,7 @@ void Player_actions_for_playing(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBO -void giving_hints_to_player(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { +void giving_hints_to_player(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { printf("\nTip function - Choose an option:\n"); printf("1. Set the user-specified cell to the right value\n"); printf("2. Set the user-specified 3x3 field to the right values\n"); @@ -407,7 +409,7 @@ void giving_hints_to_player(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_A printf("Invalid input. Please enter a number between 1 and 9.\n"); } } - grid[row - 1][col - 1] = solutionLevels[difficulty - 1][selected_level - 1][row - 1][col - 1]; + Sudoku_grid[row - 1][col - 1] = solutionLevels[selected_difficulty - 1][selected_level - 1][row - 1][col - 1]; printf("Value set successfully.\n"); break; @@ -432,8 +434,8 @@ void giving_hints_to_player(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_A } for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - grid[startRow - 1 + i][startCol - 1 + j] = - solutionLevels[difficulty - 1][selected_level - 1][startRow - 1 + i][startCol - 1 + j]; + Sudoku_grid[startRow - 1 + i][startCol - 1 + j] = + solutionLevels[selected_difficulty - 1][selected_level - 1][startRow - 1 + i][startCol - 1 + j]; } } printf("3x3 field set successfully.\n"); @@ -442,7 +444,7 @@ void giving_hints_to_player(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_A case 3: for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; i++) { for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; j++) { - grid[i][j] = solutionLevels[difficulty - 1][selected_level - 1][i][j]; + Sudoku_grid[i][j] = solutionLevels[selected_difficulty - 1][selected_level - 1][i][j]; } } printf("Puzzle solved. \n"); @@ -452,7 +454,7 @@ void giving_hints_to_player(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_A } } -void write_userinput_into_Sudoku(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { +void write_userinput_into_Sudoku(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { printf("\nInput function - Choose an action:\n"); printf("1. Insert value in an empty field\n"); printf("2. Clear an already filled field\n"); @@ -504,7 +506,7 @@ void write_userinput_into_Sudoku(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEB num = nume_str[0] - '0'; // Convert the first character to an integer if ((num >= 1 && num <= 9) && nume_str[1] == '\0') { - grid[row_e - 1][col_e - 1] = num; + Sudoku_grid[row_e - 1][col_e - 1] = num; printf("Value inserted successfully.\n"); break; } else { @@ -527,7 +529,7 @@ void write_userinput_into_Sudoku(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEB col_d = cold_str[0] - '0'; // Convert the first character to an integer if (((row_d >= 1 && row_d <= 9) && rowd_str[1] == '\0') && ((col_d >= 1 && col_d <= 9) && cold_str[1] == '\0')) { - grid[row_d - 1][col_d - 1] = 0; + Sudoku_grid[row_d - 1][col_d - 1] = 0; printf("Cell cleared successfully.\n"); break; } else { @@ -538,26 +540,26 @@ void write_userinput_into_Sudoku(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEB default: printf("Invalid input. Please enter 1 or 2.\n"); } - printGrid(grid); + printGrid(Sudoku_grid); } -void printGrid(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { +void printGrid(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { printf("\nSudoku Grid:\n"); for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; i++) { for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; j++) { - printf("%d ", grid[i][j]); + printf("%d ", Sudoku_grid[i][j]); } printf("\n"); } } -void check_if_Sudoku_solved(int grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { +void check_if_Sudoku_solved(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { printf("\nDone function - Checking if the solution is correct...\n"); for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; i++) { for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; j++) { - if (grid[i][j] != solutionLevels[difficulty - 1][selected_level - 1][i][j]) { + if (Sudoku_grid[i][j] != solutionLevels[selected_difficulty - 1][selected_level - 1][i][j]) { printf("Incorrect solution. Keep trying!\n"); return; } From 879c81a656b73bcf6f6c1d07e831642c9515a098 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:39:34 +0100 Subject: [PATCH 226/270] adding sudoku.h, changing the game to include the header --- src/main/c/sudoku.c | 71 +++++++++++++++++++++++++++++++++++++-------- src/main/c/sudoku.h | 41 ++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 12 deletions(-) create mode 100644 src/main/c/sudoku.h diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index f18284d..accd026 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -2,7 +2,7 @@ #include #include #include - +#include "sudoku.h" #define SIZE_OF_GAMEBORD_AXIS_X 9 #define SIZE_OF_GAMEBORD_AXIS_Y 9 @@ -14,6 +14,11 @@ int selected_difficulty; int selected_level; +bool check_solved; +bool test_help = false; +int test_row_e; +int test_col_e; +int test_num; void Game_loop(); //is instead of main @@ -29,6 +34,7 @@ void check_if_Sudoku_solved(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAM + int availableLevels[AVAILABLE_DIFFICULTIES][AVAILABLE_LEVELS][SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = { { //easy {{0, 0, 3, 0, 2, 1, 8, 0, 0}, @@ -234,6 +240,7 @@ void Game_loop() { printf("1. Easy\n2. Medium\n3. Hard\n"); printf("Enter the corresponding number or type 'quit' to exit: "); + if(!test_help){ char input[10]; scanf("%s", input); @@ -242,6 +249,7 @@ void Game_loop() { } selected_difficulty = input[0] - '0'; // Convert the first character to an integer + if ((selected_difficulty >= 1 && selected_difficulty <= 3) && input[1] == '\0') { Level_Pool(selected_difficulty); @@ -250,7 +258,11 @@ void Game_loop() { } else { printf("Invalid input. Please enter a number between 1 and 3.\n"); } - + } + if(test_help){ + Level_Pool(selected_difficulty); + break; + } } } @@ -267,7 +279,8 @@ void Level_Selection(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_A int level = 0; printf("\nSelect a level:\n"); while (true){ - char level_select[10]; + if(!test_help){ + char level_select[10]; scanf("%s", level_select); @@ -284,6 +297,13 @@ void Level_Selection(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_A printf("Invalid input. Please enter a number between 1 and 3.\n"); } + } + if(test_help){ + selected_level = level; + level--; + create_playing_field(Sudoku_grid, selected_difficulty, selected_level); + break; + } } @@ -299,11 +319,13 @@ void initializeGrid(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AX void create_playing_field(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y], int selected_difficulty, int level) { initializeGrid(Sudoku_grid); + if(!test_help){ for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; i++) { for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; j++) { Sudoku_grid[i][j] = availableLevels[selected_difficulty - 1][level - 1][i][j]; } } + } for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; i++) { for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; j++) { printf("%d", Sudoku_grid[i][j]); @@ -324,8 +346,14 @@ void Player_actions_for_playing(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF printf("5. Select level\n"); printf("6. Quit\n"); - int action; - + + int action; + if(test_help){ + printGrid(Sudoku_grid); + check_if_Sudoku_solved(Sudoku_grid); + break; + } + if(!test_help){ while (true){ char action_str[10]; scanf("%s", action_str); @@ -338,7 +366,7 @@ void Player_actions_for_playing(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF printf("Invalid input. Please enter a number between 1 and 6.\n"); } } - + switch (action) { case 1: giving_hints_to_player(Sudoku_grid); @@ -361,6 +389,7 @@ void Player_actions_for_playing(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF default: printf("Invalid input. Please enter a number between 1 and 6.\n"); } + } } } @@ -372,9 +401,18 @@ void giving_hints_to_player(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAM printf("2. Set the user-specified 3x3 field to the right values\n"); printf("3. Solve the entire puzzle for the current level\n"); - + if(test_help){ + initializeGrid(Sudoku_grid); + for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; i++) { + for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; j++) { + Sudoku_grid[i][j] = solutionLevels[selected_difficulty - 1][selected_level - 1][i][j]; + } + } + printf("Puzzle solved. \n"); + + } int option = 0; - + if(!test_help){ while (true){ char tip_str[10]; scanf("%s", tip_str); @@ -388,7 +426,7 @@ void giving_hints_to_player(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAM printf("Invalid input. Please enter a number between 1 and 3.\n"); } } - + switch (option) { case 1: printf("Enter the coordinates (row and column) separated by space:\n"); @@ -452,15 +490,22 @@ void giving_hints_to_player(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAM default: printf("Invalid option. Please enter a number between 1 and 3.\n"); } + } } void write_userinput_into_Sudoku(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]) { printf("\nInput function - Choose an action:\n"); printf("1. Insert value in an empty field\n"); printf("2. Clear an already filled field\n"); + + if(test_help){ + initializeGrid(Sudoku_grid); + Sudoku_grid[test_row_e -1][test_col_e -1] = test_num; + printGrid(Sudoku_grid); + } int action; - + if(!test_help){ while (true){ char in_str[10]; scanf("%s", in_str); @@ -541,6 +586,7 @@ void write_userinput_into_Sudoku(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_O printf("Invalid input. Please enter 1 or 2.\n"); } printGrid(Sudoku_grid); + } } @@ -561,16 +607,17 @@ void check_if_Sudoku_solved(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAM for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; j++) { if (Sudoku_grid[i][j] != solutionLevels[selected_difficulty - 1][selected_level - 1][i][j]) { printf("Incorrect solution. Keep trying!\n"); + check_solved = false; return; } } } - + check_solved = true; printf("Congratulations! Sudoku is solved correctly.\n"); } -int main(){ +int mainn(){ Game_loop(); return 0; } \ No newline at end of file diff --git a/src/main/c/sudoku.h b/src/main/c/sudoku.h new file mode 100644 index 0000000..63914c1 --- /dev/null +++ b/src/main/c/sudoku.h @@ -0,0 +1,41 @@ +#ifndef SUDOKU_H +#define SUDOKU_H + +#include +//constants +#define SIZE_OF_GAMEBORD_AXIS_X 9 +#define SIZE_OF_GAMEBORD_AXIS_Y 9 +#define AVAILABLE_DIFFICULTIES 3 +#define AVAILABLE_LEVELS 3 +#define EMPTY 0 +#define LEVEL_NUMBER 3 + + +extern int selected_difficulty; +extern int selected_level; +extern int solutionLevels[AVAILABLE_DIFFICULTIES][AVAILABLE_LEVELS][SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]; +extern int availableLevels[AVAILABLE_DIFFICULTIES][AVAILABLE_LEVELS][SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]; +extern bool check_solved; +extern bool test_help; +extern int test_row_e; +extern int test_col_e; +extern int test_num; + + + +//functions +void Game_loop(); //is instead of main +void Level_Pool(int selected_difficulty); +void Level_Selection(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void initializeGrid(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void create_playing_field(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y], int selected_difficulty, int level); +void Player_actions_for_playing(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void giving_hints_to_player(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void write_userinput_into_Sudoku(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void printGrid(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +void check_if_Sudoku_solved(int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]); +int mainn(); + + + +#endif // SUDOKU_H From e9350c906910448c684a71697e59ea863faec6e6 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:42:58 +0100 Subject: [PATCH 227/270] test 1 --- src/test/c/test_sudoku.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/test/c/test_sudoku.c diff --git a/src/test/c/test_sudoku.c b/src/test/c/test_sudoku.c new file mode 100644 index 0000000..59be98f --- /dev/null +++ b/src/test/c/test_sudoku.c @@ -0,0 +1,22 @@ +#ifdef TEST + +#include "unity.h" +#include "sudoku.h" +#include +#include +#include +#include +#include + + + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + + +#endif // TEST From c9fa4676eb03b894eb1132cb123b4644c03a6f0c Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:44:13 +0100 Subject: [PATCH 228/270] test 2 --- src/test/c/test_sudoku.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/test/c/test_sudoku.c b/src/test/c/test_sudoku.c index 59be98f..e58d373 100644 --- a/src/test/c/test_sudoku.c +++ b/src/test/c/test_sudoku.c @@ -18,5 +18,32 @@ void tearDown(void) { } +//1 + +// Unit test for Level_Pool() function +// Call the Level_Pool() function, prints 3 fixed lines and "Available levels for Difficulty " +void test_Level_Pool_0() { + selected_difficulty = 0; + Level_Pool(selected_difficulty); + //TEST_PASS(); + printf("Unit test for Level_Pool_0() executed.\n"); +} + +void test_Level_Pool_5() { + selected_difficulty = 5; + Level_Pool(selected_difficulty); + //TEST_PASS(); + printf("Unit test for Level_Pool_5() executed.\n"); +} + +void test_Level_Pool_neg_1() { + selected_difficulty = -1; + Level_Pool(selected_difficulty); + //TEST_PASS(); + printf("Unit test for Level_Pool_-1() executed.\n\n"); +} + + + #endif // TEST From 3530bf8035af32b5db254f10438404b48b7ef46f Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:44:35 +0100 Subject: [PATCH 229/270] test 3 --- src/test/c/test_sudoku.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/c/test_sudoku.c b/src/test/c/test_sudoku.c index e58d373..674cf9b 100644 --- a/src/test/c/test_sudoku.c +++ b/src/test/c/test_sudoku.c @@ -43,6 +43,27 @@ void test_Level_Pool_neg_1() { printf("Unit test for Level_Pool_-1() executed.\n\n"); } +//2 + +void test_initializeGrid() { + int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]; + + + initializeGrid(Sudoku_grid); + int expected = EMPTY; + + + for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; ++i) { + for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; ++j) { + TEST_ASSERT_EQUAL_INT_MESSAGE(expected, Sudoku_grid[i][j], "Checking if every space is 0"); + } + } + + + printf("Unit test for initializeGrid() executed.\n\n"); +} + + From 319f79a4f3f6b246b7c48854eb70893f7d8e707f Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:44:54 +0100 Subject: [PATCH 230/270] test 4 --- src/test/c/test_sudoku.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/test/c/test_sudoku.c b/src/test/c/test_sudoku.c index 674cf9b..92a9053 100644 --- a/src/test/c/test_sudoku.c +++ b/src/test/c/test_sudoku.c @@ -64,6 +64,33 @@ void test_initializeGrid() { } +//3 + +void test_create_playing_field_level_medium_two() { + int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]; + selected_difficulty = 2; + selected_level = 2; + int expected_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = {{7, 0, 2, 0, 0, 0, 9, 5, 0}, + {0, 0, 0, 7, 5, 0, 2, 0, 6}, + {0, 0, 5, 0, 2, 8, 7, 0, 3}, + {5, 1, 8, 0, 3, 0, 6, 0, 0}, + {0, 0, 6, 1, 0, 0, 0, 3, 0}, + {0, 0, 0, 0, 6, 2, 0, 8, 1}, + {0, 9, 0, 2, 0, 4, 0, 0, 5}, + {0, 0, 0, 0, 9, 0, 0, 0, 4}, + {0, 5, 1, 0, 0, 0, 0, 9, 2}}; + + create_playing_field(Sudoku_grid, selected_difficulty, selected_level); + + // Check if the generated Sudoku grid is valid + for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; ++i) { + for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; ++j) { + TEST_ASSERT_EQUAL_INT_MESSAGE(expected_grid[i][j], Sudoku_grid[i][j], "Checking if every space is correct"); + }} + + printf("Unit test for create_playing_field() executed.\n\n"); +} + From 8e9e7fa7bce677a4c5eff3ba67c0471115fad0fc Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:45:30 +0100 Subject: [PATCH 231/270] test 5 --- src/test/c/test_sudoku.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/test/c/test_sudoku.c b/src/test/c/test_sudoku.c index 92a9053..973b108 100644 --- a/src/test/c/test_sudoku.c +++ b/src/test/c/test_sudoku.c @@ -91,6 +91,29 @@ void test_create_playing_field_level_medium_two() { printf("Unit test for create_playing_field() executed.\n\n"); } +//4 + +// Unit test for printGrid() function +void test_printGrid() { + int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = { + {5, 3, 0, 0, 7, 0, 0, 0, 0}, + {6, 0, 0, 1, 9, 5, 0, 0, 0}, + {0, 9, 8, 0, 0, 0, 0, 6, 0}, + {8, 0, 0, 0, 6, 0, 0, 0, 3}, + {4, 0, 0, 8, 0, 3, 0, 0, 1}, + {7, 0, 0, 0, 2, 0, 0, 0, 6}, + {0, 6, 0, 0, 0, 0, 2, 8, 0}, + {0, 0, 0, 4, 1, 9, 0, 0, 5}, + {0, 0, 0, 0, 8, 0, 0, 7, 9} + }; + + printf("Sudoku Grid:\n"); + printGrid(Sudoku_grid); + //TEST_PASS(); + printf("Unit test for printGrid() executed.\n\n"); +} + + From 71c7290397890582388e822fff2adcc2a2a79c6c Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:45:52 +0100 Subject: [PATCH 232/270] test 6 --- src/test/c/test_sudoku.c | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/test/c/test_sudoku.c b/src/test/c/test_sudoku.c index 973b108..19f424b 100644 --- a/src/test/c/test_sudoku.c +++ b/src/test/c/test_sudoku.c @@ -114,6 +114,52 @@ void test_printGrid() { } +//5 + +// Unit test for check_if_Sudoku_solved() function +void test_check_if_Sudoku_solved_everything_correct() { + selected_difficulty = 1; + selected_level = 1; + int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = { + {4, 7, 3, 6, 2, 1, 8, 5, 9}, + {6, 8, 5, 9, 7, 4, 1, 3, 2}, + {9, 2, 1, 5, 3, 8, 7, 6, 4}, + {7, 6, 9, 3, 5, 2, 4, 8, 1}, + {8, 5, 4, 1, 9, 7, 6, 2, 3}, + {1, 3, 2, 4, 8, 6, 9, 7, 5}, + {2, 9, 7, 8, 1, 5, 3, 4, 6}, + {3, 4, 8, 2, 6, 9, 5, 1, 7}, + {5, 1, 6, 7, 4, 3, 2, 9, 8}}; + + + check_if_Sudoku_solved(Sudoku_grid); + TEST_ASSERT_TRUE(check_solved); + + + printf("Unit test for check_if_Sudoku_solved() executed.\n"); +} + +void test_check_if_Sudoku_solved_mistake_on_purpose() { + selected_difficulty = 1; + selected_level = 1; + int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = { + {4, 7, 3, 6, 2, 1, 8, 5, 9}, + {6, 8, 5, 9, 7, 4, 1, 3, 2}, + {9, 2, 1, 5, 3, 8, 7, 6, 4}, + {7, 6, 9, 3, 5, 2, 4, 8, 1}, + {8, 5, 4, 1, 9, 7, 6, 2, 3}, + {1, 3, 2, 4, 8, 6, 9, 7, 5}, + {2, 9, 7, 8, 1, 5, 3, 4, 6}, + {3, 4, 8, 2, 6, 9, 5, 1, 7}, + {5, 1, 6, 7, 4, 3, 2, 9, 3}}; + + + check_if_Sudoku_solved(Sudoku_grid); + TEST_ASSERT_FALSE(check_solved); + + + printf("Unit test for check_if_Sudoku_solved() executed.\n\n"); +} From 368b942bce5c9006a16144b3fad6311b8354282b Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:46:11 +0100 Subject: [PATCH 233/270] test 7 --- src/test/c/test_sudoku.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/c/test_sudoku.c b/src/test/c/test_sudoku.c index 19f424b..f3ff12d 100644 --- a/src/test/c/test_sudoku.c +++ b/src/test/c/test_sudoku.c @@ -162,5 +162,15 @@ void test_check_if_Sudoku_solved_mistake_on_purpose() { } +//6 + +void test_Game_loop_1(){ + test_help = true; + selected_difficulty = 1; + Game_loop(); + printf("Unit test for Game_loop() executed.\n\n"); +} + + #endif // TEST From 62d2090c48983eac5dc934f52dd779c7c23322f5 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:46:29 +0100 Subject: [PATCH 234/270] test 8 --- src/test/c/test_sudoku.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/c/test_sudoku.c b/src/test/c/test_sudoku.c index f3ff12d..0dfa07e 100644 --- a/src/test/c/test_sudoku.c +++ b/src/test/c/test_sudoku.c @@ -171,6 +171,27 @@ void test_Game_loop_1(){ printf("Unit test for Game_loop() executed.\n\n"); } +//7 + +void test_Level_Selection_2_2(){ + test_help = true; + int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]; + selected_difficulty = 1; + selected_level = 1; + + Level_Selection(Sudoku_grid); + + int expected = EMPTY; + + + for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; ++i) { + for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; ++j) { + TEST_ASSERT_EQUAL_INT_MESSAGE(expected, Sudoku_grid[i][j], "Checking if level gets initialized correctly"); + } + } + + printf("Unit test for Level_Selection() executed.\n\n"); +} #endif // TEST From 28b904b9ebce0b3a5bd52ba8fe3433e31904ff3e Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:46:47 +0100 Subject: [PATCH 235/270] test 9 --- src/test/c/test_sudoku.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/test/c/test_sudoku.c b/src/test/c/test_sudoku.c index 0dfa07e..4cbee9c 100644 --- a/src/test/c/test_sudoku.c +++ b/src/test/c/test_sudoku.c @@ -193,5 +193,30 @@ void test_Level_Selection_2_2(){ printf("Unit test for Level_Selection() executed.\n\n"); } +//8 + +void test_Player_actions_for_playing_print_and_solve(){ + test_help = true; + selected_difficulty = 1; + selected_level = 1; + + int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = { + {4, 7, 3, 6, 2, 1, 8, 5, 9}, + {6, 8, 5, 9, 7, 4, 1, 3, 2}, + {9, 2, 1, 5, 3, 8, 7, 6, 4}, + {7, 6, 9, 3, 5, 2, 4, 8, 1}, + {8, 5, 4, 1, 9, 7, 6, 2, 3}, + {1, 3, 2, 4, 8, 6, 9, 7, 5}, + {2, 9, 7, 8, 1, 5, 3, 4, 6}, + {3, 4, 8, 2, 6, 9, 5, 1, 7}, + {5, 1, 6, 7, 4, 3, 2, 9, 8}}; + + Player_actions_for_playing(Sudoku_grid); + TEST_ASSERT_TRUE(check_solved); + printf("Unit test for Player_actions_for_playing() executed.\n\n"); +} + + + #endif // TEST From ed058162096cc600b5d65177caec12a3654f2734 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:47:05 +0100 Subject: [PATCH 236/270] test 10 --- src/test/c/test_sudoku.c | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/test/c/test_sudoku.c b/src/test/c/test_sudoku.c index 4cbee9c..c5abf7f 100644 --- a/src/test/c/test_sudoku.c +++ b/src/test/c/test_sudoku.c @@ -218,5 +218,48 @@ void test_Player_actions_for_playing_print_and_solve(){ +//9 + +void test_giving_hints_to_player(){ + test_help = true; + int selected_difficulty = 1; + int selected_level = 1; + int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = + { + {5, 3, 0, 0, 7, 0, 0, 0, 0}, + {6, 0, 0, 1, 9, 5, 0, 0, 0}, + {0, 9, 8, 0, 0, 0, 0, 6, 0}, + {8, 0, 0, 0, 6, 0, 0, 0, 3}, + {4, 0, 0, 8, 0, 3, 0, 0, 1}, + {7, 0, 0, 0, 2, 0, 0, 0, 6}, + {0, 6, 0, 0, 0, 0, 2, 8, 0}, + {0, 0, 0, 4, 1, 9, 0, 0, 5}, + {0, 0, 0, 0, 8, 0, 0, 7, 9} + }; + int expected_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = + {{4, 7, 3, 6, 2, 1, 8, 5, 9}, + {6, 8, 5, 9, 7, 4, 1, 3, 2}, + {9, 2, 1, 5, 3, 8, 7, 6, 4}, + {7, 6, 9, 3, 5, 2, 4, 8, 1}, + {8, 5, 4, 1, 9, 7, 6, 2, 3}, + {1, 3, 2, 4, 8, 6, 9, 7, 5}, + {2, 9, 7, 8, 1, 5, 3, 4, 6}, + {3, 4, 8, 2, 6, 9, 5, 1, 7}, + {5, 1, 6, 7, 4, 3, 2, 9, 8}}; + + giving_hints_to_player(Sudoku_grid); + + // Check if the generated Sudoku grid is valid + for (int i = 0; i < SIZE_OF_GAMEBORD_AXIS_X; ++i) { + for (int j = 0; j < SIZE_OF_GAMEBORD_AXIS_Y; ++j) { + TEST_ASSERT_EQUAL_INT_MESSAGE(expected_grid[i][j], Sudoku_grid[i][j], "Checking if every space is correct"); + }} + + + printf("Unit test for giving_hints_to_player() executed.\n\n"); +} + + + #endif // TEST From 3f9a597d6aa37796e42e9f1e05d12175140abf55 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:47:22 +0100 Subject: [PATCH 237/270] test 11 --- src/test/c/test_sudoku.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/c/test_sudoku.c b/src/test/c/test_sudoku.c index c5abf7f..557f85d 100644 --- a/src/test/c/test_sudoku.c +++ b/src/test/c/test_sudoku.c @@ -260,6 +260,27 @@ void test_giving_hints_to_player(){ } +// 10 + +void test_write_userinput_into_Sudoku_9_into_empty(){ + test_help = true; + test_row_e = 1; + test_col_e = 1; + test_num = 9; + int Sudoku_grid[SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y]; + + + write_userinput_into_Sudoku(Sudoku_grid); + + TEST_ASSERT_EQUAL_INT_MESSAGE(test_num, Sudoku_grid[test_row_e -1][test_col_e -1], "Checking if number input is correct"); + + + + printf("Unit test for write_userinput_into_Sudoku() executed.\n\n"); +} + + + #endif // TEST From e24ce5f87f651fe51971bf00f021a4ac7dcf4d33 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:58:01 +0100 Subject: [PATCH 238/270] =?UTF-8?q?26=20Runde=20Z=C3=A4hlen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/TicTacToe.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 8f3df43..0622484 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -112,4 +112,5 @@ int mainx() { row -= 1; col -= 1; Zuege(Feld, row, col); + Zaehler++; } \ No newline at end of file From 67c2f31ce4307dbf745e871398494e726c50f314 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:58:55 +0100 Subject: [PATCH 239/270] =?UTF-8?q?27=20mehr=20Z=C3=BCge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/TicTacToe.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 0622484..37879ef 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -101,16 +101,19 @@ int mainx() { char Feld[3][3]; Brett(Feld); Bild(Feld); - if (Zaehler % 2 != 0) { - printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); + while (Winner(Feld) == 9) { + Bild(Feld); + if (Zaehler % 2 != 0) { + printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); + } + else printf("Spieler 2 gebe das Feld an wo du dein O setzen willst.\n"); + printf("Reihe:"); + scanf("%d", &row); + printf("Spalte:"); + scanf("%d", &col); + row -= 1; + col -= 1; + Zuege(Feld, row, col); + Zaehler++; } - else printf("Spieler 2 gebe das Feld an wo du dein O setzen willst.\n"); - printf("Reihe:"); - scanf("%d", &row); - printf("Spalte:"); - scanf("%d", &col); - row -= 1; - col -= 1; - Zuege(Feld, row, col); - Zaehler++; -} \ No newline at end of file +} From 08c90fe18d2ab44f37424493108a6cb59dd4d836 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:59:47 +0100 Subject: [PATCH 240/270] 28 Sieger bestimmen --- src/main/c/TicTacToe.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 37879ef..c8a72fb 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -116,4 +116,6 @@ int mainx() { Zuege(Feld, row, col); Zaehler++; } + Bild(Feld); + Winner(Feld); } From ce7048da4332ab1099d52d39b37eabafc870c02b Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:01:14 +0100 Subject: [PATCH 241/270] 29 Feldrand --- src/main/c/TicTacToe.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index c8a72fb..67733fd 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -113,6 +113,12 @@ int mainx() { scanf("%d", &col); row -= 1; col -= 1; + if (row > 3 || col > 3) { + printf("Das ist nicht mehr im Feld. Versuch es nochmal:"); + scanf("%d %d", &row, &col); + row -= 1; //Für Index eins kleiner + col -= 1; + } Zuege(Feld, row, col); Zaehler++; } From 563b1a9860719d1afda45ccfbaba01d237be31a9 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:03:32 +0100 Subject: [PATCH 242/270] 30 mehr Spiele --- src/main/c/TicTacToe.c | 53 ++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 67733fd..aa06372 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -99,29 +99,36 @@ int mainx() { int row; int col; char Feld[3][3]; - Brett(Feld); - Bild(Feld); - while (Winner(Feld) == 9) { - Bild(Feld); - if (Zaehler % 2 != 0) { - printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); - } - else printf("Spieler 2 gebe das Feld an wo du dein O setzen willst.\n"); - printf("Reihe:"); - scanf("%d", &row); - printf("Spalte:"); - scanf("%d", &col); - row -= 1; - col -= 1; - if (row > 3 || col > 3) { - printf("Das ist nicht mehr im Feld. Versuch es nochmal:"); - scanf("%d %d", &row, &col); - row -= 1; //Für Index eins kleiner + char Nochmal[50] = { "Weiter" }; + + while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { + Zaehler = 1; + Brett(Feld); + while (Winner(Feld) == 9) { + + Bild(Feld); + if (Zaehler % 2 != 0) { + printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); + } + else printf("Spieler 2 gebe das Feld an wo du dein O setzen willst.\n"); + printf("Reihe:"); + scanf("%d", &row); + printf("Spalte:"); + scanf("%d", &col); + row -= 1; col -= 1; + if (row > 3 || col > 3) { + printf("Das ist nicht mehr im Feld. Versuch es nochmal:"); + scanf("%d %d", &row, &col); + row -= 1; //Für Index eins kleiner + col -= 1; + } + Zuege(Feld, row, col); + Zaehler++; } - Zuege(Feld, row, col); - Zaehler++; + Bild(Feld); + Winner(Feld); + printf("Wollt ihr weiter spielen?\n[Weiter]\n[Ende]\n"); + scanf("%s", Nochmal); } - Bild(Feld); - Winner(Feld); -} +} \ No newline at end of file From 5b25802ccc428833e062aeac35826a134c93ed3a Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:05:57 +0100 Subject: [PATCH 243/270] =?UTF-8?q?31=20Z=C3=BCge=20O=20optimiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/TicTacToe.c | 49 +++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index aa06372..983e125 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -67,30 +67,34 @@ int Winner(char Feld[3][3]) { return 0; } void Zuege(char Feld[3][3], int row, int col) { - if (Zaehler % 2 == 0) { - if (Feld[row][col] == '_') { - Feld[row][col] = 'O'; - } - else { - printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); - printf("[Reihe Spalte]:"); - scanf("%d %d"); - row -= 1; - col -= 1; - Zuege(Feld, row, col); - } - } - else { - if (Feld[row][col] == '_') { - Feld[row][col] = 'X'; + if (Zaehler < 10) { + if (Zaehler % 2 == 0) { + if (Feld[row][col] == '_') { + Feld[row][col] = 'O'; + } + else { + printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); + printf("Reihe:"); + scanf("%d", &row); + printf("Spalte:"); + scanf("%d", &col); + row -= 1; + col -= 1; + Zuege(Feld, row, col); + } } else { - printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); - printf("[Reihe Spalte]:"); - scanf("%d %d"); - row -= 1; - col -= 1; - Zuege(Feld, row, col); + if (Feld[row][col] == '_') { + Feld[row][col] = 'X'; + } + else { + printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); + printf("[Reihe Spalte]:"); + scanf("%d %d"); + row -= 1; + col -= 1; + Zuege(Feld, row, col); + } } } } @@ -131,4 +135,5 @@ int mainx() { printf("Wollt ihr weiter spielen?\n[Weiter]\n[Ende]\n"); scanf("%s", Nochmal); } + return 0; } \ No newline at end of file From 51683ecbbc9b6cf27861b4addf5175cc446ef6d2 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:07:06 +0100 Subject: [PATCH 244/270] =?UTF-8?q?32=20Z=C3=BCge=20X=20optimiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/TicTacToe.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 983e125..beda977 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -89,8 +89,10 @@ void Zuege(char Feld[3][3], int row, int col) { } else { printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); - printf("[Reihe Spalte]:"); - scanf("%d %d"); + printf("Reihe:"); + scanf("%d", &row); + printf("Spalte:"); + scanf("%d", &col); row -= 1; col -= 1; Zuege(Feld, row, col); From fc06f65bf6c9a89fb905966e52af3859e0950b3a Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:08:55 +0100 Subject: [PATCH 245/270] 33 Spieler Name --- src/main/c/TicTacToe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index beda977..a544052 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -105,8 +105,10 @@ int mainx() { int row; int col; char Feld[3][3]; + char Spieler1[50], Spieler2[50]; char Nochmal[50] = { "Weiter" }; - + printf("Name der Spieler\[Spieler 1 Spieler2]\n"); + scanf("%s %s", Spieler1, Spieler2); while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { Zaehler = 1; Brett(Feld); From 90ace1c085933fd0d9f2f5903ee1b3888bdafa17 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:11:32 +0100 Subject: [PATCH 246/270] =?UTF-8?q?34=20Begr=C3=BC=C3=9Fung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/TicTacToe.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index a544052..e5b7a7f 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -112,6 +112,7 @@ int mainx() { while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { Zaehler = 1; Brett(Feld); + printf("\nWillkommen %s und %s. Eure Runde Beginnt jetzt.", Spieler1, Spieler2); while (Winner(Feld) == 9) { Bild(Feld); From b68205c26bf6a7307196cfc13995ed511d45ff49 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:12:59 +0100 Subject: [PATCH 247/270] 35 Sieger ausgabe --- src/main/c/TicTacToe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index e5b7a7f..0b8c6a1 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -136,7 +136,9 @@ int mainx() { Zaehler++; } Bild(Feld); - Winner(Feld); + if (Winner(Feld) == 1) { + printf("Der Sieger ist %s", Spieler1); + } printf("Wollt ihr weiter spielen?\n[Weiter]\n[Ende]\n"); scanf("%s", Nochmal); } From 4fb35bfa936378f6766a912b18b57af6a9522c79 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:14:19 +0100 Subject: [PATCH 248/270] 36 Sieger ausgabe 2 --- src/main/c/TicTacToe.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 0b8c6a1..a67fb06 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -139,6 +139,9 @@ int mainx() { if (Winner(Feld) == 1) { printf("Der Sieger ist %s", Spieler1); } + else if (Winner(Feld) == 2) { + printf("Der Sieger ist %s", Spieler2); + } printf("Wollt ihr weiter spielen?\n[Weiter]\n[Ende]\n"); scanf("%s", Nochmal); } From 97ba4fb289d694223db75790acb506f8165a0bb2 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:17:19 +0100 Subject: [PATCH 249/270] 37 Punktestand --- src/main/c/TicTacToe.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index a67fb06..4b50623 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -106,9 +106,12 @@ int mainx() { int col; char Feld[3][3]; char Spieler1[50], Spieler2[50]; + int Punkte1 = 0, Punkte2 = 0; char Nochmal[50] = { "Weiter" }; - printf("Name der Spieler\[Spieler 1 Spieler2]\n"); - scanf("%s %s", Spieler1, Spieler2); + printf("Name Spieler 1:"); + scanf("%s", Spieler1); + printf("Name Spieler 2:"); + scanf("%s", Spieler2); while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { Zaehler = 1; Brett(Feld); @@ -138,10 +141,13 @@ int mainx() { Bild(Feld); if (Winner(Feld) == 1) { printf("Der Sieger ist %s", Spieler1); + Punkte1++; } else if (Winner(Feld) == 2) { printf("Der Sieger ist %s", Spieler2); + Punkte2++; } + printf("%s - %d, %s - %d\n", Spieler1, Punkte1, Spieler2, Punkte2); printf("Wollt ihr weiter spielen?\n[Weiter]\n[Ende]\n"); scanf("%s", Nochmal); } From 49644b1093d32be9be29fd5ce8dd7ec92f412b34 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:18:07 +0100 Subject: [PATCH 250/270] 38 Entscheidung Zeichen --- src/main/c/TicTacToe.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 4b50623..7c7075a 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -107,14 +107,19 @@ int mainx() { char Feld[3][3]; char Spieler1[50], Spieler2[50]; int Punkte1 = 0, Punkte2 = 0; + char Name1[50], Name2[50]; char Nochmal[50] = { "Weiter" }; printf("Name Spieler 1:"); - scanf("%s", Spieler1); + scanf("%s", Name1); printf("Name Spieler 2:"); - scanf("%s", Spieler2); + scanf("%s", Name2); while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { Zaehler = 1; Brett(Feld); + printf("%s, Was willst du sein, X oder O: ", Name1); + scanf("%s", Spieler1); + strcpy(Spieler2, (Spieler1[0] == 'X') ? Name2 : Name1); + strcpy(Spieler1, (Spieler1[0] == 'X') ? Name1 : Name2); printf("\nWillkommen %s und %s. Eure Runde Beginnt jetzt.", Spieler1, Spieler2); while (Winner(Feld) == 9) { From 4e9e07b59d0809f57ff7a5a7860f3373bd171868 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:19:33 +0100 Subject: [PATCH 251/270] 39 Auswahl begrenzt --- src/main/c/TicTacToe.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 7c7075a..d92fbbf 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -118,6 +118,10 @@ int mainx() { Brett(Feld); printf("%s, Was willst du sein, X oder O: ", Name1); scanf("%s", Spieler1); + if (Spieler1[0] != 'X' && Spieler1[0] != 'O') { + printf("Ungültige Auswahl. Das Spiel wird beendet.\n"); + break; + } strcpy(Spieler2, (Spieler1[0] == 'X') ? Name2 : Name1); strcpy(Spieler1, (Spieler1[0] == 'X') ? Name1 : Name2); printf("\nWillkommen %s und %s. Eure Runde Beginnt jetzt.", Spieler1, Spieler2); From 9c15212cd2f38063e909734b1fadf068680669c6 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:20:34 +0100 Subject: [PATCH 252/270] 40 Farbe definieren --- src/main/c/TicTacToe.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index d92fbbf..a01df1b 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -3,6 +3,11 @@ #include #include +#define ANSI_COLOR_BRIGHT_RED "\x1b[91m" +#define ANSI_COLOR_BRIGHT_CYAN "\x1b[96m" +#define ANSI_COLOR_BRIGHT_YELLOW "\x1b[93m" +#define ANSI_COLOR_RESET "\x1b[0m" + int Zaehler = 1; // Funktion, um das Spielfeld zu initialisieren void Brett(char Feld[3][3]) { From e9c0a6ec86c96daae68477edb92e3b629dd85803 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:21:29 +0100 Subject: [PATCH 253/270] =?UTF-8?q?41=20Text=20einf=C3=A4rben?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/TicTacToe.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index a01df1b..c1f9a33 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -25,7 +25,15 @@ void Bild(char Feld[3][3]) { #endif for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - printf("%c ", Feld[i][j]); + if (Feld[i][j] == '_') { + printf(ANSI_COLOR_BRIGHT_YELLOW"%c "ANSI_COLOR_RESET, Feld[i][j]); + } + else if (Feld[i][j] == 'X') { + printf(ANSI_COLOR_BRIGHT_CYAN"%c "ANSI_COLOR_RESET, Feld[i][j]); + } + else { + printf(ANSI_COLOR_BRIGHT_RED"%c "ANSI_COLOR_RESET, Feld[i][j]); + } } printf("\n"); } From c202ab47be1bd9a9783104e164c592c4dd64122e Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:24:04 +0100 Subject: [PATCH 254/270] refactoring: Zaehler -> Runde --- src/main/c/TicTacToe.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index c1f9a33..8bbd2da 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -8,7 +8,7 @@ #define ANSI_COLOR_BRIGHT_YELLOW "\x1b[93m" #define ANSI_COLOR_RESET "\x1b[0m" -int Zaehler = 1; +int Runde = 1; // Funktion, um das Spielfeld zu initialisieren void Brett(char Feld[3][3]) { for (int i = 0; i < 3; i++) { @@ -80,8 +80,8 @@ int Winner(char Feld[3][3]) { return 0; } void Zuege(char Feld[3][3], int row, int col) { - if (Zaehler < 10) { - if (Zaehler % 2 == 0) { + if (Runde < 10) { + if (Runde % 2 == 0) { if (Feld[row][col] == '_') { Feld[row][col] = 'O'; } @@ -127,7 +127,7 @@ int mainx() { printf("Name Spieler 2:"); scanf("%s", Name2); while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { - Zaehler = 1; + Runde = 1; Brett(Feld); printf("%s, Was willst du sein, X oder O: ", Name1); scanf("%s", Spieler1); @@ -139,9 +139,8 @@ int mainx() { strcpy(Spieler1, (Spieler1[0] == 'X') ? Name1 : Name2); printf("\nWillkommen %s und %s. Eure Runde Beginnt jetzt.", Spieler1, Spieler2); while (Winner(Feld) == 9) { - Bild(Feld); - if (Zaehler % 2 != 0) { + if (Runde % 2 != 0) { printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); } else printf("Spieler 2 gebe das Feld an wo du dein O setzen willst.\n"); @@ -158,7 +157,7 @@ int mainx() { col -= 1; } Zuege(Feld, row, col); - Zaehler++; + Runde++; } Bild(Feld); if (Winner(Feld) == 1) { From 5eb24ac8e0f8ea27c31fd8e6edd2c0f0ad17a365 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:26:21 +0100 Subject: [PATCH 255/270] refactoring: Brett -> initializeBoard --- src/main/c/TicTacToe.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 8bbd2da..517be63 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -10,7 +10,7 @@ int Runde = 1; // Funktion, um das Spielfeld zu initialisieren -void Brett(char Feld[3][3]) { +void initializeBoard(char Feld[3][3]) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { Feld[i][j] = '_'; @@ -38,6 +38,7 @@ void Bild(char Feld[3][3]) { printf("\n"); } } + int Winner(char Feld[3][3]) { // Überprüfen Sieg // Überprüfen Reihen @@ -128,7 +129,7 @@ int mainx() { scanf("%s", Name2); while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { Runde = 1; - Brett(Feld); + initializeBoard(Feld); printf("%s, Was willst du sein, X oder O: ", Name1); scanf("%s", Spieler1); if (Spieler1[0] != 'X' && Spieler1[0] != 'O') { From b6a62a29618d4acb06aa7d95cb6daf55f35abafd Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:27:07 +0100 Subject: [PATCH 256/270] refactoring: Feld -> board --- src/main/c/TicTacToe.c | 66 +++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 517be63..2c87b2a 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -9,15 +9,15 @@ #define ANSI_COLOR_RESET "\x1b[0m" int Runde = 1; -// Funktion, um das Spielfeld zu initialisieren -void initializeBoard(char Feld[3][3]) { +// Funktion, um das Spielboard zu initialisieren +void initializeBoard(char board[3][3]) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - Feld[i][j] = '_'; + board[i][j] = '_'; } } } -void Bild(char Feld[3][3]) { +void Bild(char board[3][3]) { #ifdef _WIN32 system("cls"); #else @@ -25,26 +25,26 @@ void Bild(char Feld[3][3]) { #endif for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - if (Feld[i][j] == '_') { - printf(ANSI_COLOR_BRIGHT_YELLOW"%c "ANSI_COLOR_RESET, Feld[i][j]); + if (board[i][j] == '_') { + printf(ANSI_COLOR_BRIGHT_YELLOW"%c "ANSI_COLOR_RESET, board[i][j]); } - else if (Feld[i][j] == 'X') { - printf(ANSI_COLOR_BRIGHT_CYAN"%c "ANSI_COLOR_RESET, Feld[i][j]); + else if (board[i][j] == 'X') { + printf(ANSI_COLOR_BRIGHT_CYAN"%c "ANSI_COLOR_RESET, board[i][j]); } else { - printf(ANSI_COLOR_BRIGHT_RED"%c "ANSI_COLOR_RESET, Feld[i][j]); + printf(ANSI_COLOR_BRIGHT_RED"%c "ANSI_COLOR_RESET, board[i][j]); } } printf("\n"); } } -int Winner(char Feld[3][3]) { +int Winner(char board[3][3]) { // Überprüfen Sieg // Überprüfen Reihen for (int i = 0; i < 3; i++) { - if (Feld[i][0] == Feld[i][1] && Feld[i][1] == Feld[i][2] && Feld[i][0] != '_') { - if (Feld[i][0] == 'X') { + if (board[i][0] == board[i][1] && board[i][1] == board[i][2] && board[i][0] != '_') { + if (board[i][0] == 'X') { return 1; } else return 2; @@ -52,17 +52,17 @@ int Winner(char Feld[3][3]) { } // Überprüfen Spalten for (int j = 0; j < 3; j++) { - if (Feld[0][j] == Feld[1][j] && Feld[1][j] == Feld[2][j] && Feld[0][j] != '_') { - if (Feld[0][j] == 'X') { + if (board[0][j] == board[1][j] && board[1][j] == board[2][j] && board[0][j] != '_') { + if (board[0][j] == 'X') { return 1; } else return 2; } } // Überprüfen Diagonalen - if ((Feld[0][0] == Feld[1][1] && Feld[1][1] == Feld[2][2]) || (Feld[0][2] == Feld[1][1] && Feld[1][1] == Feld[2][0])) { - if (Feld[1][1] != '_') { - if (Feld[1][1] == 'X') { + if ((board[0][0] == board[1][1] && board[1][1] == board[2][2]) || (board[0][2] == board[1][1] && board[1][1] == board[2][0])) { + if (board[1][1] != '_') { + if (board[1][1] == 'X') { return 1; } else return 2; @@ -71,7 +71,7 @@ int Winner(char Feld[3][3]) { //Überprüfe Runde for (int k = 0; k < 3; k++) { for (int l = 0; l < 3; l++) { - if (Feld[k][l] == '_') { + if (board[k][l] == '_') { return 9; } } @@ -80,11 +80,11 @@ int Winner(char Feld[3][3]) { printf("Es ist ein Unendschieden\n"); return 0; } -void Zuege(char Feld[3][3], int row, int col) { +void Zuege(char board[3][3], int row, int col) { if (Runde < 10) { if (Runde % 2 == 0) { - if (Feld[row][col] == '_') { - Feld[row][col] = 'O'; + if (board[row][col] == '_') { + board[row][col] = 'O'; } else { printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); @@ -94,12 +94,12 @@ void Zuege(char Feld[3][3], int row, int col) { scanf("%d", &col); row -= 1; col -= 1; - Zuege(Feld, row, col); + Zuege(board, row, col); } } else { - if (Feld[row][col] == '_') { - Feld[row][col] = 'X'; + if (board[row][col] == '_') { + board[row][col] = 'X'; } else { printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); @@ -109,7 +109,7 @@ void Zuege(char Feld[3][3], int row, int col) { scanf("%d", &col); row -= 1; col -= 1; - Zuege(Feld, row, col); + Zuege(board, row, col); } } } @@ -118,7 +118,7 @@ void Zuege(char Feld[3][3], int row, int col) { int mainx() { int row; int col; - char Feld[3][3]; + char board[3][3]; char Spieler1[50], Spieler2[50]; int Punkte1 = 0, Punkte2 = 0; char Name1[50], Name2[50]; @@ -129,7 +129,7 @@ int mainx() { scanf("%s", Name2); while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { Runde = 1; - initializeBoard(Feld); + initializeBoard(board); printf("%s, Was willst du sein, X oder O: ", Name1); scanf("%s", Spieler1); if (Spieler1[0] != 'X' && Spieler1[0] != 'O') { @@ -139,8 +139,8 @@ int mainx() { strcpy(Spieler2, (Spieler1[0] == 'X') ? Name2 : Name1); strcpy(Spieler1, (Spieler1[0] == 'X') ? Name1 : Name2); printf("\nWillkommen %s und %s. Eure Runde Beginnt jetzt.", Spieler1, Spieler2); - while (Winner(Feld) == 9) { - Bild(Feld); + while (Winner(board) == 9) { + Bild(board); if (Runde % 2 != 0) { printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); } @@ -157,15 +157,15 @@ int mainx() { row -= 1; //Für Index eins kleiner col -= 1; } - Zuege(Feld, row, col); + Zuege(board, row, col); Runde++; } - Bild(Feld); - if (Winner(Feld) == 1) { + Bild(board); + if (Winner(board) == 1) { printf("Der Sieger ist %s", Spieler1); Punkte1++; } - else if (Winner(Feld) == 2) { + else if (Winner(board) == 2) { printf("Der Sieger ist %s", Spieler2); Punkte2++; } From 36e4e5f55d28f202296a93d89f09e88a1e46ac2e Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:27:50 +0100 Subject: [PATCH 257/270] refactoring: Bild -> displayBoard --- src/main/c/TicTacToe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 2c87b2a..422b99b 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -17,7 +17,7 @@ void initializeBoard(char board[3][3]) { } } } -void Bild(char board[3][3]) { +void displayBoard(char board[3][3]) { #ifdef _WIN32 system("cls"); #else @@ -140,7 +140,7 @@ int mainx() { strcpy(Spieler1, (Spieler1[0] == 'X') ? Name1 : Name2); printf("\nWillkommen %s und %s. Eure Runde Beginnt jetzt.", Spieler1, Spieler2); while (Winner(board) == 9) { - Bild(board); + displayBoard(board); if (Runde % 2 != 0) { printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); } @@ -160,7 +160,7 @@ int mainx() { Zuege(board, row, col); Runde++; } - Bild(board); + displayBoard(board); if (Winner(board) == 1) { printf("Der Sieger ist %s", Spieler1); Punkte1++; From 4d2a421e44f2f6e8236b605607884591d453543c Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:28:41 +0100 Subject: [PATCH 258/270] refactoring: Zuege -> makeMove --- src/main/c/TicTacToe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 422b99b..01f704b 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -80,7 +80,7 @@ int Winner(char board[3][3]) { printf("Es ist ein Unendschieden\n"); return 0; } -void Zuege(char board[3][3], int row, int col) { +void makeMove(char board[3][3], int row, int col) { if (Runde < 10) { if (Runde % 2 == 0) { if (board[row][col] == '_') { @@ -94,7 +94,7 @@ void Zuege(char board[3][3], int row, int col) { scanf("%d", &col); row -= 1; col -= 1; - Zuege(board, row, col); + makeMove(board, row, col); } } else { @@ -109,7 +109,7 @@ void Zuege(char board[3][3], int row, int col) { scanf("%d", &col); row -= 1; col -= 1; - Zuege(board, row, col); + makeMove(board, row, col); } } } @@ -157,7 +157,7 @@ int mainx() { row -= 1; //Für Index eins kleiner col -= 1; } - Zuege(board, row, col); + makeMove(board, row, col); Runde++; } displayBoard(board); From d08e371c2e6d83f74db85752db6c9a84da6632a8 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:30:17 +0100 Subject: [PATCH 259/270] refactoring: Nochmal -> Ende --- src/main/c/TicTacToe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 01f704b..6ee5c0e 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -122,12 +122,12 @@ int mainx() { char Spieler1[50], Spieler2[50]; int Punkte1 = 0, Punkte2 = 0; char Name1[50], Name2[50]; - char Nochmal[50] = { "Weiter" }; + char Ende[50] = { "Weiter" }; printf("Name Spieler 1:"); scanf("%s", Name1); printf("Name Spieler 2:"); scanf("%s", Name2); - while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { + while (Ende[0] == 'W' || Ende[0] == 'w') { Runde = 1; initializeBoard(board); printf("%s, Was willst du sein, X oder O: ", Name1); @@ -171,7 +171,7 @@ int mainx() { } printf("%s - %d, %s - %d\n", Spieler1, Punkte1, Spieler2, Punkte2); printf("Wollt ihr weiter spielen?\n[Weiter]\n[Ende]\n"); - scanf("%s", Nochmal); + scanf("%s", Ende); } return 0; } \ No newline at end of file From f246f8284abd6ae3a487f4b2f56202c8b6b3ea62 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:31:44 +0100 Subject: [PATCH 260/270] refactoring: Main Name --- src/main/c/TicTacToe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 6ee5c0e..bdcfcc4 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -115,7 +115,7 @@ void makeMove(char board[3][3], int row, int col) { } } // Hauptfunktion zum Spielen des Tic Tac Toe-Spiels -int mainx() { +int TicTacToe_ausfuehren() { int row; int col; char board[3][3]; From e481b36abdf214c629d05904bc1f8654b3d4f94b Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:32:23 +0100 Subject: [PATCH 261/270] refactoring: col -> column --- src/main/c/TicTacToe.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index bdcfcc4..baf3643 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -80,36 +80,36 @@ int Winner(char board[3][3]) { printf("Es ist ein Unendschieden\n"); return 0; } -void makeMove(char board[3][3], int row, int col) { +void makeMove(char board[3][3], int row, int column) { if (Runde < 10) { if (Runde % 2 == 0) { - if (board[row][col] == '_') { - board[row][col] = 'O'; + if (board[row][column] == '_') { + board[row][column] = 'O'; } else { printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); printf("Reihe:"); scanf("%d", &row); printf("Spalte:"); - scanf("%d", &col); + scanf("%d", &column); row -= 1; - col -= 1; - makeMove(board, row, col); + column -= 1; + makeMove(board, row, column); } } else { - if (board[row][col] == '_') { - board[row][col] = 'X'; + if (board[row][column] == '_') { + board[row][column] = 'X'; } else { printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); printf("Reihe:"); scanf("%d", &row); printf("Spalte:"); - scanf("%d", &col); + scanf("%d", &column); row -= 1; - col -= 1; - makeMove(board, row, col); + column -= 1; + makeMove(board, row, column); } } } @@ -117,7 +117,7 @@ void makeMove(char board[3][3], int row, int col) { // Hauptfunktion zum Spielen des Tic Tac Toe-Spiels int TicTacToe_ausfuehren() { int row; - int col; + int column; char board[3][3]; char Spieler1[50], Spieler2[50]; int Punkte1 = 0, Punkte2 = 0; @@ -148,16 +148,16 @@ int TicTacToe_ausfuehren() { printf("Reihe:"); scanf("%d", &row); printf("Spalte:"); - scanf("%d", &col); + scanf("%d", &column); row -= 1; - col -= 1; - if (row > 3 || col > 3) { + column -= 1; + if (row > 3 || column > 3) { printf("Das ist nicht mehr im Feld. Versuch es nochmal:"); - scanf("%d %d", &row, &col); + scanf("%d %d", &row, &column); row -= 1; //Für Index eins kleiner - col -= 1; + column -= 1; } - makeMove(board, row, col); + makeMove(board, row, column); Runde++; } displayBoard(board); From 8c61a7db7dfd73675f3496d496a025d5ebc830e5 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:34:18 +0100 Subject: [PATCH 262/270] refactoring: print rename --- src/main/c/TicTacToe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index baf3643..8ce9661 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -130,7 +130,7 @@ int TicTacToe_ausfuehren() { while (Ende[0] == 'W' || Ende[0] == 'w') { Runde = 1; initializeBoard(board); - printf("%s, Was willst du sein, X oder O: ", Name1); + printf("%s, Was willst du sein?\n[X/O]\n", Name1); scanf("%s", Spieler1); if (Spieler1[0] != 'X' && Spieler1[0] != 'O') { printf("Ungültige Auswahl. Das Spiel wird beendet.\n"); From 9adde5c98e58b9a196fc4fbc98a45d26c2fe97a4 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:35:57 +0100 Subject: [PATCH 263/270] Header aktualisiert --- src/main/c/TicTacToe.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/c/TicTacToe.h b/src/main/c/TicTacToe.h index 1e04a7d..645d5c3 100644 --- a/src/main/c/TicTacToe.h +++ b/src/main/c/TicTacToe.h @@ -1,7 +1,11 @@ #ifndef TICTACTOE_H #define TICTACTOE_H +void initializeBoard(char board[3][3]); +void displayBoard(char board[3][3]); int Winner(char board[3][3]); +void makeMove(char board[3][3], int row, int col); +int TicTacToe_ausfuehren(); #endif From 8aea03cf9826bf6db11a2dcfd9dbe91656befc02 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 17:48:21 +0000 Subject: [PATCH 264/270] Delete a.out --- src/main/c/a.out | Bin 10336 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100755 src/main/c/a.out diff --git a/src/main/c/a.out b/src/main/c/a.out deleted file mode 100755 index b6a2002109ba2d4eef443ffc2d731c453a0436f7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10336 zcmc&)e{5XGao)R=B8sFW>X$8&mic5$2$@>P<8RS!VM?S_%B2mLavTLw@OZp?BCk5$ zo!=cTS(0HkG7trJP+uV=0-RP#;2@Ndp!&msNx+EhC_o(42FDuh-rUkH@sCb`~Ew=}HHFp_~n$D$k zh8-bP!^ zX|Fl^Og86?H4i6J&B;XSgyVL$6D#%qc|6pg{i(Q{PQ($FO1Z6_!yunIwM4oj-7T#= z%AZ-yGC{I)%Q94{4XfZ3o-6S`unOL`3f{d6u2j(TkNg-=J>cc=SFsH=Yl4cySNnM# z5bB3aA!JRm?POv&W+zgKoU-lMsi+;zIj3~Nbw&~xKo`jIw0lBj+(asOTxDa?6yADl z6$y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Z3o4ZI)wsb8ynm&0r^)xu+hf|sH+?S$m3U_TPk?l<<$H!8K#*;~v1yi~BsFTe` zM;wLSO6KtdwiycdZm|7^h{G_Q)bH`)Hy1Vh233oe(~u zt*E0tx0GeyE!09iC28Mp|9;f{r$=7C8-&VwEbWW^S}9(Cfrsj(efcgCdRiEn`u$J) zF|tYI<-1Gh5X<@77yr?|jpPq7pL}--eaR!g4SBI&A^Cu00sr{ZzLDA& z`O^0kPn-#s6C(RfDgP}pgvt2GcY*w!kDuRf|92rvF)s4*{V>n%-%kEVklo~wFMVh5 z7WQ`Xv>&CuOZ&2)l)rD1zhk2LLrLrxy*~v;{u6omJC9jD2(VD+O(HMY&yn%U>x*)# z>{f7j*b_m|&?EVUoO<4qzz=LL}`UP?l7r&o%7UBRyiA1oZ@ s`9wtvkF+oI?_Yt5?Z}qWdEP(XEFmT%?Fu}P%u4bTyl=F9^T#j$-$UwV$N&HU From b121d09f06379868eb8efc490e4f86fe8217f50e Mon Sep 17 00:00:00 2001 From: fdai7715 Date: Wed, 7 Feb 2024 18:39:52 +0000 Subject: [PATCH 265/270] Update team.md --- team.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/team.md b/team.md index 76bf093..59c808e 100644 --- a/team.md +++ b/team.md @@ -1,7 +1,8 @@ -Joe Lukas Kalb, fdai7715 -Peter Wiebe, fdai7773 -Simon Hildebrandt, fdai7864 -Lucas Heil, fdai7356 -Celine Khazarian, fdai7781 -Ahmad Thaljeh, fdai7726 -Yasin Al Satouf, fdai7731 +- COMMITTER-NAME, FD-NUMMER +- Joe Lukas Kalb, fdai7715 +- Peter Wiebe, fdai7773 +- Simon Hildebrandt, fdai7864 +- Lucas Heil, fdai7356 +- Celine Khazarian, fdai7781 +- Ahmad Thaljeh, fdai7726 +- Yasin Al Satouf, fdai7731 From 76197e3e7bdb296c38db8591a380c1b076afa670 Mon Sep 17 00:00:00 2001 From: fdai7715 Date: Wed, 7 Feb 2024 19:09:21 +0000 Subject: [PATCH 266/270] Update team.md --- team.md | 1 - 1 file changed, 1 deletion(-) diff --git a/team.md b/team.md index 59c808e..50032ed 100644 --- a/team.md +++ b/team.md @@ -1,4 +1,3 @@ -- COMMITTER-NAME, FD-NUMMER - Joe Lukas Kalb, fdai7715 - Peter Wiebe, fdai7773 - Simon Hildebrandt, fdai7864 From 7cb7d7f32d42af612ef15f65cd6691038546f68b Mon Sep 17 00:00:00 2001 From: fdai7715 Date: Wed, 7 Feb 2024 22:08:01 +0000 Subject: [PATCH 267/270] Update team.md --- team.md | 1 + 1 file changed, 1 insertion(+) diff --git a/team.md b/team.md index 50032ed..59c808e 100644 --- a/team.md +++ b/team.md @@ -1,3 +1,4 @@ +- COMMITTER-NAME, FD-NUMMER - Joe Lukas Kalb, fdai7715 - Peter Wiebe, fdai7773 - Simon Hildebrandt, fdai7864 From 2fd811a54978f161ba12cb25c3d50acb040bf459 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Thu, 8 Feb 2024 16:23:57 +0100 Subject: [PATCH 268/270] something --- src/test/c/test_sudoku.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/c/test_sudoku.c b/src/test/c/test_sudoku.c index 557f85d..1fbe4e9 100644 --- a/src/test/c/test_sudoku.c +++ b/src/test/c/test_sudoku.c @@ -21,7 +21,6 @@ void tearDown(void) //1 // Unit test for Level_Pool() function -// Call the Level_Pool() function, prints 3 fixed lines and "Available levels for Difficulty " void test_Level_Pool_0() { selected_difficulty = 0; Level_Pool(selected_difficulty); From af29b81f51b12bcffbf46fc18b5971910a7fc0c1 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Thu, 8 Feb 2024 15:40:04 +0000 Subject: [PATCH 269/270] Update team.md --- team.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/team.md b/team.md index 59c808e..8a54816 100644 --- a/team.md +++ b/team.md @@ -4,5 +4,5 @@ - Simon Hildebrandt, fdai7864 - Lucas Heil, fdai7356 - Celine Khazarian, fdai7781 -- Ahmad Thaljeh, fdai7726 +- fdai7726, fdai7726 - Yasin Al Satouf, fdai7731 From 77b6c9715a682de12b917c2c5372e676acb3ec30 Mon Sep 17 00:00:00 2001 From: fdai7715 Date: Thu, 8 Feb 2024 16:12:36 +0000 Subject: [PATCH 270/270] Add new directory --- src/test/c/support/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/test/c/support/.gitkeep diff --git a/src/test/c/support/.gitkeep b/src/test/c/support/.gitkeep new file mode 100644 index 0000000..e69de29