Welcome to the Guess the Number Game! This is a fun and interactive console-based game where you can test your luck and guessing skills. Choose a difficulty level, guess the number, and beat the challenge! 🚀
-
Choose Your Difficulty
- Easy: Guess a number between
1-50
. - Medium: Guess a number between
1-100
. - Hard: Guess a number between
1-200
.
- Easy: Guess a number between
-
Make Your Guess
- Enter your number to see if it's too high, too low, or spot-on!
- You get up to 10 attempts to guess the correct number.
-
Time & History
- Track how long it took you to guess the number.
- See all your guesses at the end of the game.
-
Exit Anytime
- Type
exit
to gracefully leave the game.
- Type
- 🧩 Three Difficulty Levels: Choose Easy, Medium, or Hard for different ranges of numbers.
- ⏱ Timer: Measures the time taken to guess correctly.
- 📜 Guess Tracking: Keeps a record of all your guesses for post-game analysis.
- 🔄 Error Handling: Robust handling of invalid inputs (e.g., letters, out-of-range numbers).
- 🎮 Interactive Gameplay: Smooth, user-friendly experience.
- Install Go (version 1.16 or later).
git clone https://github.com/yourusername/guess-the-number-game.git
cd guess-the-number-game
go run main.go
-
Difficulty Selection
The game prompts the user to choose one of three difficulty levels. -
Random Number Generation
Generates a random number within the range based on the chosen difficulty. -
Guess Validation
Ensures all guesses are valid integers and within acceptable limits. -
Game Loop
Iterates through guesses until the user either wins or runs out of attempts.
-
selectDifficulty()
Prompts the user for a difficulty level and validates their input. -
generateRandomNumber(difficulty int)
Generates a random number within a range based on the chosen difficulty. -
getUserGuess()
Prompts the user for a guess, validates the input, and handles exit commands. -
clearBuffer()
Clears any residual input from the buffer to ensure smooth gameplay.
Select Difficulty Level: 1 (Easy), 2 (Medium), 3 (Hard)
Enter your choice: 2
Enter your guess (or type 'exit' to quit): 50
Your guess is too low. Try again!
Enter your guess (or type 'exit' to quit): 75
Your guess is too high. Try again!
Congratulations! You guessed the number 67 correctly in 3 attempts.
It took you 15.23s to guess the correct number.
Your guesses: [50, 75, 67]
- Play solo or challenge your friends to see who can guess the fastest.
- Learn to improve your estimation and deduction skills.
- Works seamlessly in any terminal or command-line interface.
We welcome contributions! 🎉
- Fork the repository.
- Create your feature branch:
git checkout -b feature/YourFeature
. - Commit your changes:
git commit -m "Add some feature"
. - Push to the branch:
git push origin feature/YourFeature
. - Open a pull request.
This project is licensed under the MIT License.
Drop a star ⭐ on the repo and share it with your friends! 😊