Info

Codebreaker is a permutation of the old game family Mastermind/Cows and Bulls. The guess pegs come in 12 colors and 4 shapes, and there are 4 kinds of key pegs for the feedback phase. A bit more complicated than the standard variant with only 2 key pegs (black and white), but also more fun. I wrote my first version of this game back in the 80:s on my Atari ST (oh, the nostalgia...). The language was GFA Basic which was way better than the Atari's abysmal built-in Basic dialect. I missed the line numbers though; Basic without line numbers just doesn't feel right... :)

Long after that, I made a Java version as a course assignment during my education. Later came other versions with more elaborated rules and all sorts of configuration options. The latest iteration is this JavaScript program, which I wrote as a little exercise in DOM manipulation techniques.

The rules (assuming you are familiar with the ordinary Mastermind rules)

Duplicates are allowed, for instance 2 yellow squares or 6 magenta stars. Blanks, however, are not allowed; there will be no empty key holes in the solution code.

The four key pegs work like this:
key pegBlack: right color, right shape, right position.
key pegBlack-white: right color, wrong shape, right position.
key pegWhite: right color, right shape, wrong position.
key pegWhite-black: right color, wrong shape, wrong position.

If a guess matches two conditions, the above order is also the order in which the conflict will be solved. If, for instance, the solution code looks like this:

code
And the guess looks like this:
guess
Then "cyan square gets white key peg" has precedence over "cyan disc gets white-black key peg". Hence the white key peg in the feedback bar.

It takes some time to get used to the rules, but once you get the hang of it you'll be able to crack most codes within 12 tries. So good luck, and mind the sound effect at the end... :)

Codebreaker