NumberWordle is a numeric guessing game inspired by the classic Wordle. The player must guess a sequence of numbers based on feedback provided after each guess. The game incorporates entropy calculations to determine optimal guesses and strategies.
- Interactive gameplay where the user can guess numbers.
- Calculations for guessing patterns and hints using colored symbols:
- 🟢 - Correct number and correct position (Exact)
- ⚪ - Correct number but wrong position (Misplaced)
- ⚫ - Incorrect number (Wrong)
- Simulation of optimal gameplay with the ability to analyze guesses.
- Helper mode for aiding users in external NumberWordle games.
To use the NumberWordle game, you need to have Python 3.x and the following libraries installed:
pip install numpy scipy tqdmTo play the game, simply run the script:
python main.py- Play Interactive Game: Engage in an interactive guessing game.
- Simulate Game with Optimal Play: Test the game's mechanics against optimal guessing algorithms.
- Evaluate Strategy Performance: Assess the efficiency of different guessing strategies through simulations.
- Helper Mode: Get assistance in solving an external NumberWordle game.
- n: The range of numbers (1 to n).
- positions: The number of positions in the code (default is 4).
- max_attempts: Maximum number of attempts allowed to guess the sequence (default is 7).
You can start a game and be prompted to make guesses with feedback indicating the accuracy based on the symbols. The game will adapt based on user input and suggest the optimal next guesses using a strategy that maximizes potential correct outcomes based on calculated entropy.
- NumberWordle: Core class to manage the game state.
__init__(self, n=4, positions=4, max_attempts=7): Initializes the game with specified parameters.reset_game(self, answer=None): Resets the game.get_pattern(self, guess, answer=None): Evaluates the guess against the current answer.make_guess(self, guess): Registers a guess and updates the game state.is_won(self): Checks if the game has been won.is_lost(self): Checks if the game has been lost.
- Entropy Calculations:
get_entropies(allowed_guesses, possible_answers): Computes the entropy for each guess.optimal_guess(allowed_guesses, possible_answers): Determines the best guess based on expected scores.
- analyze_next_guesses(game, top_n=5): Recommends the best next guesses based on entropy analysis.
- play_interactive_game(n=4, positions=4): Starts an interactive game session.
- helper_mode(n=4, positions=4): Aids in solving an external NumberWordle game by analyzing user guesses and responses.
Contributions are welcome! If you find bugs or have suggestions for new features, please submit an issue or pull request.
This project is licensed under the MIT License - see the LICENSE file for details.