#game #guessing #cli

app number-guessing

A fun command-line number guessing game

1 stable release

new 1.0.0 Mar 23, 2025

#60 in Games

Download history 85/week @ 2025-03-18

85 downloads per month

MIT license

9KB
70 lines

🎯 The Number Guessing Game 🎮

📝 Description

Welcome to the Number Guessing Game! This is a simple and fun command-line game where you guess a randomly generated number within a specified range. The game provides hints to help you find the correct number, and you can play as many times as you like.

Table of Contents

Features ✨

  • Custom Range: Specify your own minimum and maximum values for the guessing range.
  • Colored Output: Enjoy a colorful command-line interface (can be disabled).
  • Hints: Get hints like "You're way too low!", or "You're way too high!" to guide your guesses.
  • Play Again: After winning, you can choose to play again or exit the game.

Installation 🛠️

Prerequisites

  • Rust installed on your system.

Steps

  1. Clone the repository:

    git clone https://github.com/dossdortival/number-guessing.git
    
  2. Navigate to the project directory:

    cd number-guessing
    
  3. Build the project:

    cargo build --release
    
  4. (Optional) Install the game globally:

    cargo install --path .
    

Usage 🚀

Running the Game

You can run the game in two ways:

  1. Locally (without installing):

    cargo run -- <min> <max>
    

    Example 1 (default):

    cargo run
    

    Example 2:

    cargo run -- 100 500
    
  2. Globally (after installing):

    number-guessing <min> <max>
    

    Example 1 (default):

    number-guessing
    

    Example 2:

    number-guessing 100 500
    
    

Command-Line Arguments

Argument Description Default
<min> The minimum number in the range. 1
<max> The maximum number in the range. 100
--no-color Disable colored output. false

Example with all options:

number-guessing 100 500 --no-color

How to Play 🎲

  1. Start the Game:

    • Run the game with your desired range (e.g., 10 500).
  2. Guess the Number:

    • Enter your guess when prompted.
    • The game will tell you if your guess is too small, too big, or correct.
  3. Use Hints:

    • If your guess is far to the secret number, you'll get a hint like "You're way too high or too low!".
  4. Win the Game:

    • When you guess the correct number, you'll see a victory message with the number of attempts it took.
  5. Play Again:

    • After winning, you can choose to play again or exit the game.

Contributing 🤝

We welcome contributions! If you'd like to contribute to this project, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Make your changes and commit them.
  4. Push your changes to your fork.
  5. Submit a pull request.

Please ensure your code follows the project's style and includes appropriate tests.

License 📄

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

Acknowledgments 🙏

  • Built with Rust.
  • Uses the clap crate for command-line argument parsing.
  • Inspired by the classic number-guessing game from "The Book".

Enjoy the game! 🚀 If you have any questions or feedback, feel free to open an issue or reach out.


Dependencies

~1.4–8.5MB
~70K SLoC