Gave the wordle face the ability to give random guesses on the first word

This commit is contained in:
David Volovskiy
2024-08-17 11:36:35 -04:00
parent 1675af6449
commit 1e76022146
4 changed files with 80 additions and 36 deletions

View File

@@ -982,6 +982,11 @@ def list_of_valid_words(letters, words=legal_list):
return legal_words
def rearrange_words_by_uniqueness(words):
unique = [word for word in words if len(word) == len(set(word))]
duplicates = [word for word in words if len(word) != len(set(word))]
return unique + duplicates, len(unique)
def capitalize_all_and_remove_duplicates(arr):
for i,word in enumerate(arr):
arr[i] = word.upper()
@@ -1001,6 +1006,7 @@ def print_valid_words(letters=alphabet):
legal_words = capitalize_all_and_remove_duplicates(legal_words)
random.shuffle(legal_words)
# Just in case the watch's random function is too pseudo, better to shuffle th elist so it's less likely to always have the same starting letter
legal_words, num_uniq = rearrange_words_by_uniqueness(legal_words)
print("static const char _valid_letters[] = {", end='')
for letter in letters[:-1]:
@@ -1035,6 +1041,8 @@ def print_valid_words(letters=alphabet):
i+=1
print('')
print("};")
print(f"\nstatic const uint16_t _num_unique_words = {num_uniq}; // The _legal_words array begins with this many words where each letter is different.")
def get_sec_val_and_units(seconds):