No BSD License  

Highlights from
Mastermind!

4.71429

4.7 | 7 ratings Rate this file 9 Downloads (last 30 days) File Size: 9.14 KB File ID: #11798
image thumbnail

Mastermind!

by Geoff Boynton

 

26 Jul 2006 (Updated 28 Jul 2006)

Crack the code!

| Watch this File

File Information
Description

Matlab implementation of the 'Mastermind (R)' board game
 
 mastermind([number of colors],...
            [number of columns],...
            [number of rows])
 
 default values: mastermind(6,4,10)
 
 Click on pegs on the right to choose the color.
 Click on the empty peg boxes to place a peg
   (keep clicking to cycle through colors).
 Click on 'GO' to get results for that row.
 
 White indicates correct color, but not correct location
 Black indicates correct color in the correct location
 
 Note: you can cheat by clicking on the boxes in the top row to reveal the hidden pegs.

MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (8)
28 Jul 2006 John D'Errico

Buggy code should be tested before submission.

Most of the buttons on this gui work. The one button which fails is the "go" button. Its a rather important
one. That button does absolutely nothing. Perhaps "stop",
or "pause" may be a better label for it. ;-)

I'd normally give code with serious bugs a "poor" rating, but I'll choose to give it no numerical rating at all in hopes the author will correct it, since the rest of the gui seems to work.

30 Jul 2006 Ernold Blatford  
02 Aug 2006 Eduard van der Zwan

I don't understand where John is talking about. The "go" button works perfectly. I realy like the option non default parameters

05 Aug 2006 John D'Errico

Interesting. I dowloaded a new version. The go button now works. I don't know why. Given a fully working version, this now generally works properly in my tests, except...

There is one silly constraint - that the number of colors cannot be less than the total number of pegs. There is absolutely no reason why this cannot be. Unless you look more carefully at the code. The author has written the code to choose a solution that samples the peg colors WITHOUT replacement.

This behavior is undocumented, and it will likely result in some additional tests by users who might consider the possibility of replicated colors. Its trivial however to generate a solution that allows replicates. Looking more deeply into the code finds the real reason. The author has written the test for the number of pegs that match in a non-optimal manner, that apparently will not handle replicated colors in the solution.

Its too bad too. You might find it fun to try a game with only 2 peg colors, but many pegs. mastermind(2,10,10) An interesting question is, can you design a strategy that will always identify the solution for the mastermind(2,n) problem in less than n+1 tests?

10 Aug 2006 Krishna Lalith

the way the program was written was excellant.

29 Nov 2006 Cedric Zoppolo

Really simple and neat program. Quite like the original game board. Although there isn't an option for repeated colours...

15 May 2007 Christophe Morell

Good game. Well programmed and simple to use.

29 May 2007 Aman Siddiqi

This runs fantastic. And well written

Please login to add a comment or rating.
Updates
28 Jul 2006

Correcting an error in the help file

28 Jul 2006

fixed bug so that repeated colors can be entered.

28 Jul 2006

User no longer needs to select a color at beginning of game.

Tag Activity for this File
Tag Applied By Date/Time
games Geoff Boynton 22 Oct 2008 08:33:32
mastermind Geoff Boynton 22 Oct 2008 08:33:32
matlab Geoff Boynton 22 Oct 2008 08:33:32
game Geoff Boynton 22 Oct 2008 08:33:32

Contact us at files@mathworks.com