# Mastermind Game

Classic Mastermind code-breaking game. The computer picks a secret color code; you guess row by row. Black pegs = right color and position; white pegs = right color, wrong position.

> Canonical page: https://elysiatools.com/en/tools/mastermind-game

- **Category:** Games

- **Keywords:** mastermind, code breaking, bulls and cows, logic, deduction, puzzle, colors, game

## Overview

Play the classic Mastermind code-breaking game directly in your browser. Challenge your logical deduction skills as you guess the computer's secret color code row by row, using black pegs for exact matches and white pegs for partial matches.

## Inputs

- **Difficulty** (select)

## When to use

- When you want to practice logical deduction and pattern recognition with a classic board game.
- When you need a quick, engaging mental break or brain teaser during work or study.
- When teaching basic deductive reasoning, probability, or logic concepts to students.

## How it works

- Select your preferred difficulty level to set the number of colors, slots, maximum tries, and whether duplicate colors are allowed.
- Submit your guess row by row by selecting colors for each slot.
- Analyze the feedback pegs: black pegs indicate a correct color in the correct position, while white pegs indicate a correct color in the wrong position.
- Use the feedback to refine your next guess and crack the secret code before you run out of attempts.

## Use cases

- Exercising deductive reasoning and logical thinking skills.
- Playing a quick, ad-free puzzle game to pass the time.
- Demonstrating basic algorithmic logic and feedback loops in educational settings.

## Frequently asked questions

### What is the difference between a black peg and a white peg?

A black peg means a color is correct and in the right position. A white peg means a color is correct but in the wrong position.

### Can the secret code contain duplicate colors?

Yes, duplicate colors are allowed in Standard and Hard difficulties, but are disabled in Easy difficulty.

### How many attempts do I get to crack the code?

You get 12 attempts on Easy, 10 attempts on Standard, and 8 attempts on Hard difficulty.

### Does the order of the feedback pegs match the order of my guess?

No, the feedback pegs are displayed in no particular order to keep the deduction challenging.

### How do I win the Mastermind game?

You win by guessing the exact color code, resulting in all slots receiving black pegs before running out of tries.

## Related tools

- [Hangman Game](https://elysiatools.com/en/tools/hangman-game): Classic hangman word-guessing game. Guess the hidden word letter by letter; six wrong guesses ends the game. Three difficulty levels, with general, animals, food, and science categories.
- [Magic 8 Ball](https://elysiatools.com/en/tools/magic-8-ball): The classic Magic 8 Ball. Ask any yes-or-no question, shake, and get one of 20 traditional answers (yes / no / uncertain). Classic English phrases or localized translations.
- [Tic-Tac-Toe](https://elysiatools.com/en/tools/tic-tac-toe): Classic 3×3 tic-tac-toe against a random AI, an unbeatable minimax AI, or a friend. Keeps score across rounds.
- [Rock Paper Scissors](https://elysiatools.com/en/tools/rock-paper-scissors): Classic rock-paper-scissors with a random opponent or an adaptive AI that learns your patterns. Shake animation, running score, and history.
- [Deck Shuffler](https://elysiatools.com/en/tools/deck-shuffler): Shuffle a standard deck of playing cards
- [Sudoku Solver](https://elysiatools.com/en/tools/sudoku-solver): Solve Sudoku puzzles instantly
- [Minesweeper](https://elysiatools.com/en/tools/minesweeper): Classic minesweeper with beginner, intermediate and expert presets, or custom boards. First click safe, flood-fill, right-click flags, chord on numbers.
- [Trivia Quiz](https://elysiatools.com/en/tools/trivia-quiz): Test your knowledge with a trivia quiz. Random questions from a built-in English bank across science, history, geography, and general topics. Pick 1 of 4; get your score and accuracy at the end.

## Samples

- [Bevy Game Engine Samples](https://elysiatools.com/en/samples/bevy-samples): Bevy Rust game engine examples with ECS, 2D/3D graphics, audio, and game mechanics implementations
- [Android Image Processing Java Samples](https://elysiatools.com/en/samples/android-image-processing-java): Android Java image processing examples including reading/saving images, scaling, and format conversion
- [Android Image Processing Kotlin Samples](https://elysiatools.com/en/samples/android-image-processing-kotlin): Android Kotlin image processing examples including reading/saving images, scaling, and format conversion
- [Web Image Processing Python Samples](https://elysiatools.com/en/samples/web-image-processing-python): Web Python image processing examples using PIL/Pillow including reading, saving, resizing, and format conversion

## Related content

- [Classic Browser Games and Quick Puzzles](https://elysiatools.com/en/hubs/classic-browser-games): Pick an instant browser game for a short break, from 2048 and Minesweeper to trivia and two-player classics.
