File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -339,19 +339,33 @@ def main():
339339 lives = 3
340340 round_num = 1
341341 still_playing = True
342+ used_words = set ()
342343
343344 while lives > 0 and still_playing :
344- settings = DIFFICULTY_LEVELS [difficulty ]
345345 valid_words = []
346+
346347 for category , words in WORD_BANK .items ():
347- filtered_words = [w for w in words if settings ["min_length" ] <= len (
348- w ) <= settings ["max_length" ]]
349- if filtered_words :
350- valid_words .append ((category , filtered_words ))
351-
348+ available_words = [
349+ w for w in words [tier ]
350+ if w not in used_words
351+ ]
352+
353+ if available_words :
354+ valid_words .append ((category , available_words )
355+
356+ if not valid_words :
357+ used_words .clear ()
358+
359+ for category , words in WORD_BANK .items ():
360+ available_words = words [tier ]
361+ if available_words :
362+ valid_words .append ((category , available_words ))
363+
352364 category , words = random .choice (valid_words )
353365 word = random .choice (words )
354366
367+ used_words .add (word )
368+
355369 letters = list (word )
356370 scrambled = ""
357371 for _ in range (100 ):
@@ -492,4 +506,4 @@ def main():
492506
493507
494508if __name__ == "__main__" :
495- main ()
509+ main ()
You can’t perform that action at this time.
0 commit comments