/mastermind-cli

Command-line version of the classic strategy game Mastermind

Primary LanguageRubyMIT LicenseMIT

๐ŸŽฎ Mastermind CLI

Welcome to Mastermind CLI, a command-line version of the classic strategy game Mastermind. In this game, you can play as either a Code Breaker or a Code Maker, challenging yourself or letting the computer do the thinking!

๐ŸŽฎ How to Play

You can play Mastermind CLI either on Replit or locally on your machine.

Play on Replit (Online)

Run on Repl.it

  1. Create an Account: Sign up on Replit to get started.
  2. Enter Name and Details: Fill in your information to personalize your experience.
  3. Click on Import: Import the project into your Replit account.
  4. Click on Run: Start the game and enjoy the challenge!

This is a one-time process. After you've played once, you can come back to your Replit account anytime and enjoy the challenge.

Play Locally

Prerequisites

  • Ruby: Ensure you have Ruby installed on your machine. You can download it from ruby-lang.org.

Installation

  1. Clone the repository:

    git clone https://github.com/Udbhav227/mastermind-cli.git
  2. Navigate to the project directory:

    cd mastermind-cli
  3. Run the game

    ruby main.rb

โœจ Features

  • Two Play Modes:
    • Code Breaker: Crack the computer-generated code in 10 moves or less.
    • Code Maker: Create your own 4-digit code and let the computer try to break it in 5 moves or fewer.
  • ๐Ÿค– AI-Driven Guessing: The computer uses a sophisticated minimax algorithm inspired by Donald Knuth's method to efficiently guess the code.
  • ๐Ÿ’ป Command-Line Interface: Simple and easy-to-use interface for an engaging experience.

๐Ÿ› ๏ธ How It Works

Code Breaker Mode

  • The computer generates a secret 4-digit code.
  • You have 10 moves to guess the code.
  • After each guess, you'll receive hints to help narrow down your options.

Code Maker Mode

  • You create a 4-digit code.
  • The computer uses a minimax algorithm to break your code in 5 moves or less.

๐Ÿค Contributing

Contributions are welcome! If you have suggestions, bug reports, or improvements, please feel free to contribute. Hereโ€™s how you can help:

  1. Fork the Repository: Create your own copy of the project by forking the repository.
  2. Create a Branch: Create a new branch for your changes.
  3. Make Changes: Implement your changes or additions.
  4. Submit a Pull Request: Push your changes and submit a pull request with a description of what youโ€™ve done.

If you encounter any issues or have questions, open an issue on the GitHub repository.

๐Ÿ“œ License

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

๐Ÿ“š Acknowledgments

  • Donald Knuth: For his foundational work on algorithm analysis, which inspired the AI in this project. You can read his seminal paper on the Mastermind algorithm here.