From 8afbe9cc9acd1bf378da979025a7793ad41b4082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20S=2E=20Martins?= Date: Wed, 18 May 2016 17:41:06 +0100 Subject: [PATCH] Re-implement the word renewal mechanism to ensure better variety. --- crossword_generator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crossword_generator.py b/crossword_generator.py index bdffefe..3c0234b 100755 --- a/crossword_generator.py +++ b/crossword_generator.py @@ -200,10 +200,10 @@ def generate_grid(words, dim): occupancy = 0 while occupancy < 0.6: # Generate new possibilities, if needed - if not possibilities: + if len(possibilities) < 30: print("Getting new words!") sample = draw_words(words) - possibilities = generate_possibilities(sample, dim) + possibilities.extend(generate_possibilities(sample, dim)) # Add new possibility new = possibilities.pop(random.randint(0, len(possibilities)-1))