diff --git a/Start_Windows/game.c b/Start_Windows/game.c index d8cc133..727fb98 100644 --- a/Start_Windows/game.c +++ b/Start_Windows/game.c @@ -13,6 +13,73 @@ // 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 searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount) { + /* + wordSalad: char wordSalad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN] -> bereits definiert + searchFieldLen: SALAD_SIZE = 20 + words: words_array + wordcount: Anzahl der eingelesen Wörter + + */ + + /* + // 1. Schritt: Alle Felder mit zufälligen Zahlen befüllen + srand(time(NULL)); //Seed zufällig ändern + int size_word; + int placed_words; + + for(int m = 0; m < searchFieldLen; m++) //m Zeilen + { + for(int n = 0; n < searchFieldLen; n++) //n Spalte + { + salad[m][n] = 'A' + rand() % 26; //ASCII-Form + } + } + + */ + // 2. Schritt: Wörter in das Array überschreiben + + for(int i = 0; i < wordCount && i < searchFieldLen; i++) //eingelesen Wörter zählen + Länge des Feldes nicht überschreiten + { + size_t len = strlen(words[i]); //Größe des Wortes ermitteln + + if (len < searchFieldLen) + return -1; //ERROR, falls Wort größer als Größe des Feldes, unnötig, da bei worteingabe bereitsüberprüft + + unsigned int succesfully_placed = 0; + unsigned int tries = 0; + + while(succesfully_placed == 0 && tries < MAX_RAND_TRIES_PER_WORD) + { + // zufälliger Startpunkt + int row = rand() % searchFieldLen; // Reihe + int col = rand() % searchFieldLen; // Spalte + + // zufällige Richtung auswählen + int direction = rand() % 2; // 0 = VERTIKAL, 1 = HORIZONTAL + + // Prüfen der Länge in Richtung, sodass Feld nicht überschritten + int fitsin = 1; + + for(int t = 0; t < len; t++) + { + if(direction = 0) + + + } + + // Prüfen, ob bereits buchstaben in dem Feld sich befinden, bzw. der Buchstabe mit dem anderen übereinstimmt + + + + if(xxx) + { + succesfully_placed = 1; // erfolgreich eingefügt + } + + } + + return placedWords; + } } @@ -21,3 +88,4 @@ void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], { } + diff --git a/Start_Windows/input.o b/Start_Windows/input.o index 86299a0..1c29d73 100644 Binary files a/Start_Windows/input.o and b/Start_Windows/input.o differ diff --git a/Start_Windows/runTests.exe b/Start_Windows/runTests.exe new file mode 100644 index 0000000..f3ebba8 Binary files /dev/null and b/Start_Windows/runTests.exe differ diff --git a/Start_Windows/unity/unity.o b/Start_Windows/unity/unity.o new file mode 100644 index 0000000..c4ffece Binary files /dev/null and b/Start_Windows/unity/unity.o differ