MasterMind

Well I had some free time and my mom gave me the idea of making MasterMind!

Some screenshots:

PLAY!!

Rules and procedures:
This is a guessing and logic game.
There are 4 unique colors hidden. Your job is to guess them correctly. After you choose your 4 colors, you click on the arrow for that row to be evaluated. The 4 small holes on the right side are the results and they show how close to the right answer you were. A black hole means 1 of the 4 colors is placed in the correct spot. A white hole means 1 of the 4 colors is included in the answer but is not placed in the correct spot. The results are filled in no particular order. You win when you correctly guess all 4 colors. You lose when you cannot guess after 10 turns.
When you win, the results will show 1 blue hole.

How to play:
To place colors, you click on the desired color and then click on the desired hole.

Straight to some suggestions:
-automatic check after all four circles filled (no need arrow button)
-More colors, 4 out 6 is kinda easy 8)

And there is lag when I change color. That’s all. Cheers :slight_smile:

This was a fun little game, although it would be nice if the colors moved down with you, its a bit of a pain to have to go all the way up to change the color :stuck_out_tongue:

I didnt get any lag, but I dont think an automatic check would be that great, in case you misplace something.

  1. Automatic check won’t allow you to look over what you have placed. Too many times do I place a couple colors, look over everything, notice I did something wrong, and hit the “clear” button.
  2. This game was not invented by me, but it is actually an old classic. I may just add more colors for the fun of it but it would make MUCH harder.
  3. I don’t notice a lag O_o

Great suggestion! I don’t like the way it’s set up now either but I couldn’t think of anything better :stuck_out_tongue:
I’ll implement that and update it.

Thanks for playing!

EDIT: Here is a picture of the MasterMind board that I have:

http://4.bp.blogspot.com/_kSEMXAT4iWQ/TCzDvB1tqfI/AAAAAAAACsk/VJa2Kej977U/s1600/mastermind+4.jpg

  1. you may right.
  2. you can add a level chooser.
  3. yeah it did. Firefox 3.6.15 Win XP 1GHz 384MB.
  4. I just noticed that the JOptionPane is kinda different to usual Swing’s. It has glassy aero theme. But how?
  1. Good idea!
  2. 384MB RAM?!? O_O Well there is nothing in the color choosing code other than doing color.contains(point).
  3. It’s called the Nimbus Look and Feel. The default LAF (that you’re used to) is the Ocean (Metal) Look and Feel. This LAF is not in the public API but you can access it by doing:

UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");

or

UIManager.setLookAndFeel(new com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel());

pretty fun game!:smiley: I remember playing it when I was little, it was a great deal of fun!:slight_smile: I didn’t read your entire post so I had trouble understanding what the different color small circles meant, I thought white ones meant they were correct and black ones that they failed!:confused:

@r4king
oh crap why they need to put such long name to access that theme lol
you now, it’s so hard to find $2 DDR1 PC2700 RAM so I could add a bit from 256MB. If a game run smoothly in my pc, it should be too much performance-friendly :slight_smile:

If I’m not mistaken, the player hiding the pegs can also use more than one peg of the same colour.

For example they can use:
green green green black

Game seemed to work good for me. However when you win it should unveil the hidden pegs.

I did one for java 4k 2005 competition:

http://www.java4k.com/index.php?action=games&method=view&gid=24

It looks like that you shouldn’t be showed the hidden pegs since you won it afterall :smiley:

But that would make it 500x harder!
And there would be no logic, just guessing.

Oh and it does unveil the hidden pegs. Right before the dialog box pops up.

In the original MasterMind, you can have several time the same color (which is more harder).

Nice! Played real smooth. No complaints, except the distance travelled keeps increasing.

A couple ideas for that: Allow a click on a color of the previous row? Allow one to click the spot multiple times and have this rotate through the colors? A popup palette you can move around? Allow drag-and-drop?

A good friend of mine used to play a game called … omigod, I’ve forgotten it. It will come to me. It was a word-version of Mastermind. Each player picks a five-letter word, and they take turns making five-letter word guesses until they get it. We worked through some basic strategies like coming up with four five-letter words with no duplicate letters (used as a kind of elimination strategy). If I recall correctly, we eventually got good enough where just 5 or 6 guesses was often enough, and we’d spend a lot of time trying to come up with stumper words (glyph, aerie, queue, miaou, xylem), especially if you had a good notion of the strategy the other was using. (Example: if you know they are using an elim strategy and know their favorite wordset, pick one letter from each word in the word you make up. Then, the info they get from the four guesses is nearly worthless.)

Games could take as long as 40 - 50 minutes (for a single game). Nerds! ;D We used a LOT of scratch paper working on the logic.

But yeah, there definitely ARE strategies for dealing with Mastermind rounds with multiples having the same color! It’s hard but it is not random. Elimination strategies can work as there because it is easier to put up a guess with zero matches (very useful info).

Dang, I’m going to have to write my friend and ask him the name. Or, I’ll awaken at 4AM with it and add it here via an edit.

JOTTO! That was the name. (But unlike the wiki description, we gave scores for both exact hits and matches hitting letters that were out of place.)

Check out the wikipedia listing. Knuth had an algorithm to solve it, even with the duplicate pegs, in 5 or 6 turns!


It looks similar to what I was trying to do in Jotto.

Thanks for playing! I shall get around to implementing Swattkidd7’s suggestion of the palette moving down with you!

Jotto sounds amazingly hard, with all the number of possible 5 letter words!

And all those algorithms make my head hurt :o

I have updated the game making the color chooser go down with you, and I have added the ability to right click to change the current selected color.

Works fine but a little help would be great. I’ve to read the thread to understand what the white or black dots means.

Suggestions:

  • add more colors
  • allow to set the same color several times
  • perhaps a menu

Yeah I should really add an “Instructions” screen :S

  1. Yes sir!
  2. sob finneeeeee
  3. A menu for what?

well, in said menu you could have difficulty option, so that the people who want more colors are satisfied…

Good idea…since I have a Menus framework, this could be very easily implemented.