From ad956cdb3dd29cee867b7b9b997b818f9866f21b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20S=2E=20Martins?= Date: Thu, 19 May 2016 09:22:58 +0100 Subject: [PATCH] Fix a bug where the seed word would not be added to the appropriate lists. --- crossword_generator.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crossword_generator.py b/crossword_generator.py index 1cc6f6e..97636c3 100755 --- a/crossword_generator.py +++ b/crossword_generator.py @@ -227,11 +227,13 @@ def generate_grid(words, dim): # Add seed word (should be large) seed = possibilities.pop(random.randint(0, len(possibilities)-1)) - while len(seed["word"]) < 9: + while len(seed["word"]) < min(9, dim[0], dim[1]): seed = possibilities.pop(random.randint(0, len(possibilities)-1)) add_word_to_grid(seed, grid) print("Seed:") print(seed) + added_words.append(seed) + added_strings.append(seed["word"]) # Fill in grid occupancy = 0 @@ -406,7 +408,7 @@ if __name__ == "__main__": words = read_word_list("words.txt") # Generate grid - grid = generate_grid(words, [20, 20]) + grid = generate_grid(words, [5, 5]) # Show grid print("Final grid:")