Skip to main content

如何玩破解密碼

逐步教學

第 1 步,共 7 步

簡介

Welcome to Code Breaker (Mastermind)! This is a two-player deduction game.

One player is the Codemaker -- they create a secret 4-color code. The other player is the Codebreaker -- they must deduce the code within 10 guesses.

There are 6 colors available: Red, Blue, Green, Yellow, Purple, and Orange. Colors can be repeated in the code. That means there are 6^4 = 1,296 possible codes!

第 2 步,共 7 步

設定密碼

The game begins with the Codemaker choosing a secret 4-color code. The code is hidden from the Codebreaker.

The Codemaker can use any combination of the 6 colors, including duplicates. For example: Red-Red-Blue-Green is a valid code.

In this example, the Codemaker has set the secret code to Red, Green, Blue, Yellow. The Codebreaker cannot see this -- they only see a hidden code indicator.

Now the guessing begins!

第 3 步,共 7 步

進行猜測

The Codebreaker submits a guess of 4 colors. After each guess, they receive feedback:

- Black pegs (exact matches): A color that is in the correct position.

- White pegs (color matches): A color that exists in the code but is in the wrong position.

In this example, the secret code is Red-Green-Blue-Yellow. The Codebreaker guessed Red-Blue-Yellow-Green.

- Red is in position 1 (correct!) = 1 black peg

- Blue is in the code but not position 2 = 1 white peg

- Yellow is in the code but not position 3 = 1 white peg

- Green is in the code but not position 4 = 1 white peg

Result: 1 exact, 3 color matches.

第 4 步,共 7 步

解讀回饋

Understanding feedback is crucial for narrowing down the code:

- 4 exact, 0 color = You cracked the code!

- 0 exact, 0 color = None of your colors are in the code

- 2 exact, 1 color = Two colors are in the right spot, one more is present but misplaced

The feedback does NOT tell you which specific pegs are correct -- only the counts. You must deduce which positions are right based on patterns across multiple guesses.

In this example, Guess 1 got (0 exact, 2 color) and Guess 2 got (2 exact, 0 color). Comparing these results helps the Codebreaker narrow the possibilities.

第 5 步,共 7 步

推理策略

Good Codebreakers use systematic strategies:

- Start broad: Use your first guesses to identify which colors are in the code. Try all 6 colors across your first two guesses.

- Process of elimination: If a guess with 4 new colors gets 0 matches, none of those colors are in the code.

- Swap positions: If you know a color is present but misplaced, try it in different positions on subsequent guesses.

- Confirm exact matches: Once you suspect a color is in the right spot, keep it there in future guesses.

This example shows a methodical approach: Guess 1 tests Red-Blue-Green-Yellow, Guess 2 tests Purple-Orange-Red-Blue. Comparing results reveals which colors appear.

第 6 步,共 7 步

破解者獲勝

The Codebreaker wins by guessing the exact code within 10 guesses. When a guess receives 4 exact matches (4 black pegs), the code is cracked!

In this example, the Codebreaker systematically narrowed down the possibilities over 5 guesses and finally cracked the code: Red-Green-Blue-Yellow.

Experienced players can typically crack the code in 4-5 guesses using optimal strategies. The mathematically proven minimum worst-case is 5 guesses using Knuth's algorithm.

第 7 步,共 7 步

出題者獲勝

If the Codebreaker uses all 10 guesses without cracking the code, the Codemaker wins! The secret code is then revealed.

As a Codemaker, choosing a code with repeated colors often makes it harder to crack. A code like Purple-Purple-Orange-Orange is more deceptive than one with all different colors, because the Codebreaker may not expect duplicates.

Tips for Codemakers:

- Use duplicates to confuse the Codebreaker

- Avoid obvious patterns like all one color or a rainbow sequence

- Mix common and uncommon colors to throw off deduction

準備好玩破解密碼了嗎?