Skip to content

Documentation

Main function that handles creating an instance and solving wordle.

solve(first_guess='')

Solve the wordle by selecting random 'best guesses'.

Args:
    first_guess (str, optional):
        The first guess the wordle solver will use.
        If blank, will just pick a random word. Defaults to "".

Raises:
    ValueError:
        Will raise a ValueError if provided an invalid first guess.
Source code in wordle_bot/__main__.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def solve(first_guess: str = "") -> None:
    """
    Solve the wordle by selecting random 'best guesses'.

        Args:
            first_guess (str, optional):
                The first guess the wordle solver will use.
                If blank, will just pick a random word. Defaults to "".

        Raises:
            ValueError:
                Will raise a ValueError if provided an invalid first guess.

    """
    # Solve wordle
    for _ in range(5):  # Attempts to solve wordle 5 times in case it fails
        wordle = Wordle(headless=True)
        solved = wordle.solve(first_guess=first_guess)
        if solved is True:
            break

    if os.getenv("GITHUB_WORKSPACE"):
        output_file(wordle)