wordle_buddy package

Submodules

wordle_buddy.solver module

Functions for game calculations.

wordle_buddy.solver.calculate_entropy(input_word: str, word_list: List[str]) float

Given an input word and a list of possible solutions (word_list), calculates the expected information gain from the guess:

sum{c in color_patterns} [-P(c) * Log2(P(c))]

where P(c) is the probability that the input word yields color pattern c.

wordle_buddy.solver.get_color_pattern(input_word: str, solution: str) str

Given an input word and a solution, generates the resulting color pattern.

wordle_buddy.solver.safe_log2(x: float) float

Returns the base-2 logarithm if x > 0, else returns 0

wordle_buddy.utilities module

Functions for downloading and reading word lists

wordle_buddy.utilities.download_word_lists() None

Downloads both word lists from 3blue1brown’s github page

wordle_buddy.utilities.get_words(list_name: str)

Reads the given word list from file into a list of capitalized words

wordle_buddy.wordle module

Front end and game logic

class wordle_buddy.wordle.Cell(row, col)

Bases: object

delete_letter()
draw()
set_active(active)
set_in_active_row(active)
set_letter(n)
class wordle_buddy.wordle.Grid

Bases: object

draw()
class wordle_buddy.wordle.Row(row)

Bases: object

activate_row()
deactivate_row()
draw()
class wordle_buddy.wordle.Wordle(mode='play', solution=None)

Bases: object

autoplay()
backspace()
check()
click(clicked_row, clicked_col)
decrement_letter()
enter()
enter_letter(n)
get_current_color_pattern()
get_random_solution()
get_suggestions()
increment_letter()
n_guesses = 0
n_simulations = 0
print_suggestions()
trim_word_list()
class wordle_buddy.wordle.WordleGame(mode='play')

Bases: pyglet.window.BaseWindow

Front end interface for the game

get_cell_at_position(x, y)
on_draw()

The window contents must be redrawn.

The EventLoop will dispatch this event when the window should be redrawn. This will happen during idle time after any window events and after any scheduled functions were called.

The window will already have the GL context, so there is no need to call switch_to. The window’s flip method will be called after this event, so your event handler should not.

You should make no assumptions about the window contents when this event is triggered; a resize or expose event may have invalidated the framebuffer since the last time it was drawn.

New in version 1.1.

Event

on_key_press(symbol, modifiers)

A key on the keyboard was pressed (and held down).

In pyglet 1.0 the default handler sets has_exit to True if the ESC key is pressed.

In pyglet 1.1 the default handler dispatches the on_close() event if the ESC key is pressed.

Parameters
symbolint

The key symbol pressed.

modifiersint

Bitwise combination of the key modifiers active.

Event

on_mouse_press(x, y, button, modifiers)

A mouse button was pressed (and held down).

Parameters
xint

Distance in pixels from the left edge of the window.

yint

Distance in pixels from the bottom edge of the window.

buttonint

The mouse button that was pressed.

modifiersint

Bitwise combination of any keyboard modifiers currently active.

Event

on_window_close(window)
run()

Starts the game

Module contents