Game Components
Core game logic and components for the Wordle Solver.
Game Engine
Game engine module for handling the game logic when the computer selects a target word.
- class src.modules.backend.game_engine.GameEngine(event_bus=None)[source]
Bases:
object
Handles the computer vs player game mode.
- __init__(event_bus=None)[source]
Initialize a new GameEngine instance.
The GameEngine maintains strict encapsulation by creating and controlling its own WordManager and StatsManager instances.
Game State Manager
Result Color
Enumeration of result colors for Wordle feedback.
- class src.modules.backend.result_color.ResultColor(value)[source]
Bases:
Enum
Enumeration of possible letter result colors in Wordle.
- GREEN = 'G'
- YELLOW = 'Y'
- BLACK = 'B'
- classmethod from_char(char)[source]
Convert a character representation to the corresponding ResultColor.
- Return type:
- classmethod is_valid_result_string(result)[source]
Check if a string contains only valid result characters.
- Return type:
- classmethod is_winning_result(result)[source]
Check if a result string represents a winning game (all green).
- Return type:
- classmethod result_to_emoji(result)[source]
Convert a result string to emoji representation for sharing.
- Return type:
- classmethod parse_result(result_str)[source]
Parse a string of result characters into a list of ResultColor objects.
- Return type:
Word Manager
Game History Manager
Game history management for reviewing previous games.
- exception src.modules.backend.game_history_manager.GameHistoryError(message='')[source]
Bases:
WordleError
Exception raised for game history related errors.
- class src.modules.backend.game_history_manager.GameHistoryManager(history_file_path=None)[source]
Bases:
object
Manages loading and processing game history data.
Stats Manager
Module for managing game statistics and history.
- class src.modules.backend.stats_manager.StatsManager(history_file='game_history.json', event_bus=None)[source]
Bases:
GameStateObserver
Handles game statistics and history storage/retrieval.
- notify(event)[source]
Called when a relevant event occurs.
- Parameters:
event – The event that occurred
- search_games(game_id=None, won=None, target_word=None, max_attempts=None)[source]
Search for games matching specific criteria.
- Parameters:
- Return type:
- Returns:
List of matching game records
Exceptions
Custom exception classes for the Wordle Solver application. This module defines specialized exceptions for different error conditions in the game.
- exception src.modules.backend.exceptions.WordleError(message='')[source]
Bases:
Exception
Base class for all Wordle-related exceptions.
- exception src.modules.backend.exceptions.GameStateError(message='')[source]
Bases:
WordleError
Raised when an operation is attempted in an invalid game state.
- exception src.modules.backend.exceptions.InvalidGuessError(guess, reason)[source]
Bases:
DebugLogMixin
,WordleError
Raised when a guess is invalid.
- exception src.modules.backend.exceptions.InvalidWordError(word)[source]
Bases:
InvalidGuessError
Raised when a word is not in the word list.
- exception src.modules.backend.exceptions.InvalidResultError(result, reason)[source]
Bases:
DebugLogMixin
,WordleError
Raised when a result pattern is invalid.
- exception src.modules.backend.exceptions.InvalidColorError(char)[source]
Bases:
DebugLogMixin
,WordleError
Raised when an invalid color character is used.
- exception src.modules.backend.exceptions.InputLengthError(input_type, actual_length, expected_length=5)[source]
Bases:
DebugLogMixin
,WordleError
Raised when input is not the correct length.