|
import streamlit as st |
|
from streamlit_extras.stateful_button import button |
|
import random |
|
from wordle_assistant_functions import * |
|
import plotly.express as px |
|
from plots import * |
|
|
|
|
|
from bs4 import BeautifulSoup |
|
|
|
|
|
from selenium import webdriver |
|
from selenium.webdriver.common.keys import Keys |
|
from selenium.webdriver.chrome.options import Options |
|
|
|
|
|
chrome_options = Options() |
|
chrome_options.add_argument("--headless") |
|
driver = webdriver.Chrome(options = chrome_options) |
|
|
|
url = "https://screenrant.com/wordle-answers-updated-word-puzzle-guide/" |
|
|
|
|
|
driver.get(url) |
|
|
|
|
|
html_content = driver.page_source |
|
|
|
soup = BeautifulSoup(html_content, "html.parser") |
|
for item in soup.find_all('a'): |
|
|
|
item_link = item['href'] |
|
|
|
link_prefix = "https://screenrant.com/todays-wordle-answer-hints" |
|
|
|
if item_link: |
|
|
|
if link_prefix in item_link: |
|
good_item = item |
|
break |
|
|
|
good_text = good_item.text |
|
target_word = good_text.split(" - ")[-1].lower() |
|
|
|
|
|
st.title("Wordle Wizard Assistant π§π") |
|
|
|
|
|
official_words = [] |
|
with open("data/official_words_processed.txt", "r", encoding = "utf-8") as f: |
|
for word in f.read().split("\n"): |
|
if len(word) == 5: |
|
official_words.append(word) |
|
f.close() |
|
|
|
|
|
sugg_words = [] |
|
for i in range(0, 20): |
|
ran_int = random.randint(0, len(official_words) - 1) |
|
word = official_words[ran_int] |
|
sugg_words.append(word) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
num_guesses = st.sidebar.selectbox( |
|
'How many guesses would you like to submit?', |
|
(1, 2, 3, 4, 5)) |
|
|
|
guesses = [] |
|
for i in range(num_guesses): |
|
input_guess = st.text_input(f"Guess #{i+1}", '') |
|
guesses.append(input_guess) |
|
st.write(f"Guess #1: {input_guess}") |
|
|
|
|
|
def is_alphanumeric_and_of_length_5(guess): |
|
stripped_guess = guess.strip() |
|
return stripped_guess.isalpha() and len(stripped_guess) == 5 |
|
|
|
|
|
valid_guesses = all(is_alphanumeric_and_of_length_5(guess) for guess in guesses) |
|
|
|
|
|
|
|
if button('Abracadabra', key = "button2"): |
|
|
|
|
|
if not valid_guesses: |
|
st.write("Please check again that each guess only contains letters and is 5 letters in length. Once you have, click 'Abracadabra' to get feedback.") |
|
|
|
else: |
|
|
|
|
|
for word in guesses: |
|
if word not in guesses: |
|
official_words.append(word) |
|
|
|
|
|
wordle_wizard_cheat(guesses = guesses, word_list = official_words, max_guesses = 6, |
|
target = target_word, |
|
random_guess = False, random_target = False, |
|
verbose = True, drama = 0, return_stats = False, record = False) |
|
|
|
|
|
st.write("Curious about what the number beside each word means? Click the button below to find out!") |
|
|
|
|
|
if button(label = "More info", key = "button3"): |
|
|
|
|
|
count_plot() |
|
|
|
st.write("This is a distribution of the frequencies of all letters in the Wordle word list used in this app. The higher a given letter's count is, the more likely it is that that letter will be able to tell us something about the target word in a Wordle puzzle.\n") |
|
st.write("The rating of each word corresponds to approximately the percentage of all words of the ~2300 words of the list used for this game in which the given word's letters appear. This means that, for a word with a rating of 30, its letters show up in 30\% of the words of the entire word list. Since we cannot possibly have all 26 letters of the English alphabet in one 5-letter word, this rating can only really be used to compare one word to another. Using more highly-rated words should generally result in getting to the target word in fewer guesses than using lower-rated words.\n") |
|
|
|
|
|
words_plot() |
|
|
|
st.write("By this same rating system, here are the top 5 words, the middle 5 words, and the worst 5 words of the entire Wordle word list in terms of their respective ratings.\n\n") |
|
st.write("If you're interested in learning more about the theory of how Wordle Wizard actually works, check out this blog post (https://medium.com/@kmaurinjones/how-i-beat-wordle-once-and-for-all-322c8641a70d), that describes everything mentioned here (and more!) in greater detail.\n") |
|
|
|
st.write("-----------------------------\n") |
|
|
|
st.write("\nThanks for checking out Wordle Wizard! If you have any feedback or requests for additions to this app, shoot me an email at kmaurinjones@gmail.com.") |