A simple and fun command-line-based number guessing game written in C#. The computer randomly selects a number between 1 and 100, and the player must guess it within a limited number of chances based on the selected difficulty level. Sample solution for the Number Guessing Game challenge from roadmap.sh.
- Difficulty Levels: Choose between Easy, Medium, and Hard, which determine the number of attempts allowed:
- Easy: 10 chances
- Medium: 5 chances
- Hard: 3 chances
- Random Number Generation: The game generates a random number between 1 and 100 for each round.
- Hints and Feedback: Players receive feedback on their guess, whether it is too high or too low. A hint is provided when the player has only one chance left.
- Timer: Tracks how long it takes to guess the correct number.
- High Score Tracking: The game keeps track of the fewest attempts it took to guess the number across rounds.
- Multiple Rounds: Play as many rounds as you like until you decide to quit.
- .NET SDK installed on your system. You can download it from Microsoft's .NET Download page.
- Clone this repository:
git clone https://github.com/yourusername/NumberGuessingGame.git
- Navigate to the project directory:
cd NumberGuessingGame
- Build the project:
dotnet build
To start playing the game, use the following command:
dotnet run
- Welcome Message: When the game starts, you'll see a welcome message with the rules.
- Select Difficulty: You will be prompted to choose a difficulty level (Easy, Medium, or Hard).
- Make Your Guesses: The game will ask you to input a number between 1 and 100 to make your guess.
- If your guess is incorrect, you will be informed whether the target number is greater or less than your guess.
- If you are down to your last chance, a hint will be provided (whether the number is odd or even).
- Win or Lose: If you guess the correct number within the given chances, you'll receive a congratulatory message and the time it took to guess.
- If you run out of chances, the correct number will be revealed.
- Play Again: After each round, you have the option to play again or quit.
Program.cs
: The main file containing the game logic, including user input handling, random number generation, and game loop.
Some possible features to implement in the future:
- Custom difficulty settings to allow players to set their own number of chances.
- Enhanced hint system that provides clues based on proximity to the target number.
- Saving and loading high scores across multiple sessions.
If you enjoy my work or want to support what I do, feel free to Buy Me a Coffee!
Feel free to submit a pull request or report issues to help improve the project!
This project is licensed under the MIT License - see the LICENSE file for details.
For any questions or support, please reach out via GitHub Issues.
Enjoy playing and have fun improving your number guessing skills!