fix solution word error
This commit is contained in:
parent
619021cf59
commit
2dc194cd81
@ -159,7 +159,10 @@ def create_word_grid(w: int, h: int, lang_code: str = "en", target_density: floa
|
|||||||
if char not in locations:
|
if char not in locations:
|
||||||
locations[char] = []
|
locations[char] = []
|
||||||
|
|
||||||
locations[char].append([y, x])
|
if [y,x] not in locations[char]:
|
||||||
|
locations[char].append([y, x])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
remove_digits = str.maketrans('', '', digits)
|
remove_digits = str.maketrans('', '', digits)
|
||||||
n_words = len(list_words)
|
n_words = len(list_words)
|
||||||
@ -298,7 +301,7 @@ def create_word_grid(w: int, h: int, lang_code: str = "en", target_density: floa
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_solution_word(min_length=8, max_length=100):
|
def get_solution_word(min_length=10, max_length=100):
|
||||||
word = get_word(min_length=min_length, max_length=max_length)
|
word = get_word(min_length=min_length, max_length=max_length)
|
||||||
|
|
||||||
# search for matching characters in locations
|
# search for matching characters in locations
|
||||||
@ -365,7 +368,7 @@ def create_word_grid(w: int, h: int, lang_code: str = "en", target_density: floa
|
|||||||
|
|
||||||
current_density = density()
|
current_density = density()
|
||||||
|
|
||||||
solution_word_locations = get_solution_word()
|
solution_word_locations = get_solution_word(min_length=min(min_shape//2, 15))
|
||||||
|
|
||||||
logging.info("crossword generation done after %s iterations", str(i))
|
logging.info("crossword generation done after %s iterations", str(i))
|
||||||
return grid, word_hints, solution_word_locations
|
return grid, word_hints, solution_word_locations
|
||||||
|
Loading…
Reference in New Issue
Block a user