A terminal-based implementation of the classic Mastermind game developed in Python.
This project was created to learn how python handles core programming concepts such as:
- functions
- loops
- input validation
- dictionaries and lists
- game logic
- algorithmic thinking
The computer generates a secret combination of colors.
Your objective is to guess the correct sequence within a limited number of attempts.
After each guess, the game provides feedback:
- Correct position → correct color in the correct spot
- Incorrect position → correct color in the wrong spot
Colors can be repeated in the secret code.
| Letter | Color |
|---|---|
| R | Red |
| G | Green |
| B | Blue |
| Y | Yellow |
| W | White |
| O | Orange |
Welcome to Mastermind, you have 10 tries to guess the code!
The valid colors are: R G B Y W O
Type guess: R G B Y
Correct position: 2 | Incorrect position: 1
- Python 3
- Standard Library (
random)
git clone https://github.com/texlucas/mastermind-python.gitcd mastermind-pythonpython game.pymastermind-python/
│
├── game.py
└── README.md
- Random code generation
- Input validation
- Duplicate color handling
- Attempt tracking
- Feedback system for guesses
- Replayable terminal game
- Difficulty levels
- Colored terminal output
- Replay option
- Score system
- Unit tests
- GUI version using Tkinter or Pygame
- Multiplayer mode
Developed by Lucas Teixeira as a learning project while studying Python fundamentals.