MasterMind Game

Description:

Mastermind is a code-breaking game that challenges the user to guess a randomly generated secret code. This C++ project generates a code consisting of a combination of four colors. The objective for the player is to guess the code correctly based on clues provided after each guess attempt.

Game Mechanics and Clues:

  • The computer generates a four-color secret code at random.
  • After each guess, the game provides clues to help the user narrow down the correct combination.

    • “R”: Indicates that the chosen color is in the correct position in the secret code.
    • “W”: Indicates that the chosen color is present in the secret code, but the position in the user’s guess is incorrect.
    • ”-“: Indicates that the chosen color is not present in the secret code.

Key Features and Responsibilities:

  • Random Code Generation 🎲: The game randomly generates a four-color code from a predefined list of colors each time a new game begins.
  • Clue System 🔍: Implemented a feedback system that displays “R,” “W,” or “-“ clues for each color in the user’s guess to guide them toward the correct answer.
  • Game Logic Implementation 🧩: Designed the game logic entirely in C++ to manage the code generation, input validation, and display of clues.
  • User Interface: Created a text-based UI that prompts users for guesses and displays clues after each attempt, making the game accessible and straightforward.

Learning Outcomes:

This project helped me strengthen my understanding of algorithm design, conditional logic, and arrays in C++. I also learned how to effectively structure a simple game loop in a command-line environment, making it a fun and educational experience.

Technology Used:

  • Programming Language: C++
  • Development Environment: Command-Line Interface (CLI)

Play Instructions:

The player must enter their guess of the four-color combination. After each guess, clues will be provided. The game continues until the user correctly guesses the code or decides to exit.

This project was a fun challenge and a great opportunity to delve deeper into C++ programming while implementing game logic and randomization techniques.

MasterMind Game Interface:

MasterMind Game Interface

Link to GitHub Repo: GitHub Link