Skip to content

NumberWordle is a numeric guessing game inspired by Wordle. Players guess a sequence of numbers based on feedback in the form of exact matches and misplaced numbers. The game features interactive gameplay, optimal guessing strategies using entropy calculations, and a helper mode for external games. Challenge your number guessing skills!

License

Notifications You must be signed in to change notification settings

fqx/NumberWordle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

NumberWordle

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.

Features

  • 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.

Installation

To use the NumberWordle game, you need to have Python 3.x and the following libraries installed:

pip install numpy scipy tqdm

Usage

To play the game, simply run the script:

python main.py

Game Modes

  1. Play Interactive Game: Engage in an interactive guessing game.
  2. Simulate Game with Optimal Play: Test the game's mechanics against optimal guessing algorithms.
  3. Evaluate Strategy Performance: Assess the efficiency of different guessing strategies through simulations.
  4. Helper Mode: Get assistance in solving an external NumberWordle game.

Game Parameters

  • 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).

Example

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.

Functions

Main Classes and Methods

  • 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.

Utility Functions

  • 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.

Helper Functions

  • 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.

Contributing

Contributions are welcome! If you find bugs or have suggestions for new features, please submit an issue or pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

NumberWordle is a numeric guessing game inspired by Wordle. Players guess a sequence of numbers based on feedback in the form of exact matches and misplaced numbers. The game features interactive gameplay, optimal guessing strategies using entropy calculations, and a helper mode for external games. Challenge your number guessing skills!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages