From ad2984a80822e30908fabbf55769c839ccd1d28a Mon Sep 17 00:00:00 2001 From: zidanmo99094 Date: Fri, 30 Oct 2026 00:52:24 +0100 Subject: [PATCH] test --- Startcode/game.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Startcode/game.c b/Startcode/game.c index f1601c6..70d25c6 100644 --- a/Startcode/game.c +++ b/Startcode/game.c @@ -3,7 +3,7 @@ #include #include -#define MAX_RAND_TRIES_PER_WORD 100 +#define MAX_RAND_TRIES_PER_WORD 10 #define EMPTY_CHAR 0 // TODO: Spiellogik implementieren: @@ -13,14 +13,7 @@ // Creates the word salad by placing words randomly and filling empty spaces int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int wordCount, char **words) { - // Zufallsgenerator einmalig initialisieren - static int seeded = 0; - if (!seeded) { - srand((unsigned int)time(NULL)); - seeded = 1; - } - - // 1. Spielfeld vollständig mit EMPTY_CHAR (0) initialisieren + // 1. Spielfeld vollständig mit EMPTY_CHAR initialisieren for (int r = 0; r < MAX_SEARCH_FIELD_LEN; r++) { for (int c = 0; c < MAX_SEARCH_FIELD_LEN; c++) { salad[r][c] = EMPTY_CHAR; @@ -36,7 +29,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi int len = (int)strlen(words[i]); if (len == 0 || len > MAX_SEARCH_FIELD_LEN) continue; - // Versuche bis zu MAX_RAND_TRIES_PER_WORD (10) Mal, eine freie Position zu finden + // Versuche bis zu MAX_RAND_TRIES_PER_WORD Mal, eine freie Position zu finden for (int attempt = 0; attempt < MAX_RAND_TRIES_PER_WORD; attempt++) { // 0 = Horizontal, 1 = Vertikal int dir = rand() % 2;