This contest is a variation on the classic Mastermind® game. Each puzzle is an unknown sequence of colored pegs and the object is to guess which pegs they are. On each round of the game, you make a guess at the puzzle and receive feedback in the form of black and white pegs to let you know how many of your pegs are correct. To get a feel for the game, click here for a java implementations that you can play on the web.
Download and unzip these files to get started: mastermind.zip. Most notable of these files is "solver", the file that contains the actual contest entry that you write, and "runcontest", that you can run to test your entry. More details on these functions follow.
A row vector of positive integers represents the sequence of pegs, e.g. [4 2 4 7 3]. Each puzzle can have any number of pegs (length of vector) and any number of possible colors (maximum integer). Your submission returns its best guess for this sequence. It earns a black peg for each peg that is exactly right and a white peg for each peg that is in the solution, but in the wrong position (for scoring purposes, a black peg is worth twice as much as a white peg). For example:
Before returning its final answer, your submission can make a limited number of guesses to narrow down the possibilities. This corresponds to a row in the board game. It makes the guess by calling scoreme, which has this signature:
[black, white, numCallsMade]=scoreme(guess,puzzleID);
Your entry can only call scoreme me a limited number of times, and this limit is not the same for each puzzle.
Your submission needs to have the following signature:
Each entry must complete the entire test suite in less than two minutes, or it will fail. The faster it completes the suite, the lower (better) the score.
Let's take a closer look at the example included in the zipfile mentioned at the beginning of this page. If you download and uncompress the zipfile mentioned earlier, you will have the files used below.
function finalAnswer=solver(numPegs,numColors,guessLimit,puzzleID) % sample entry numCallsMade=0; bestScore=-Inf; while numCallsMade < guessLimit guess=floor(numColors*rand(1,numPegs)+1); [black, white, numCallsMade]=scoreme(guess,puzzleID); score=2*black+white; if score > bestScore finalAnswer=guess; bestScore=score; end if black == numPegs % perfect score, so return finalAnswer=guess; return end end
A few points to keep in mind about this function and your contest entries:
Internally, we keep track of how many times you've called scoreme to make sure that you don't use too many guesses. But we're only interested in your final answer, and that's what your function should return.
To test this funciton using the testsuite we've included in the zipfile, at the MATLAB prompt you can all the "runcontest" function:
>> [results, message] = runcontest
The first column of results will contain your "pegscore", that's 2*numBlackPegs + numWhitePegs, and the second column will give you an estimate of the runtime. message will contain a string describing the overall statistics of your submission.
It's also useful to visualize what you entry is doing; you can do this by passing runsuite an input of 1:
>> [results, message] = runcontest(1)
After you entry has completed each test in the testsuite, a graphical display of the Mastermind board is shown, with the correct answer at the top and your guesses listed below (your first guess is at the bottom).
Here are the factors, in order of importance, that affect your score:
This list indicates relative weighting; it's possible that very strong performance in a less important area can make up for slightly weaker performance in a more important area.
Once an entry has been submitted, it cannot be changed. However, any entry can be viewed, edited, and resubmitted as a new entry. You are free to view and modify any entries in the queue. The contest server maintains a history for each modified entry. If your modification of an existing entry improves its score, then you are the "author" for the purpose of determining the winners of this contest. We encourage you to examine and optimize existing entries.
We also encourage you to discuss your solutions and strategies with others. We have provided a ink to an online chat room so that you can chat about the contest and see who else is watching. You can also post to a comp.soft-sys.matlab thread that we've started from our newsreader.
The allowable functions are those contained in the basic MATLAB package available in $MATLAB/toolbox/matlab, where $MATLAB is the root MATLAB directory. Functions from other toolboxes will not be available. Entries will be tested against MATLAB version 6.1 (R12.1).
The following are prohibited:
Check our FAQ for answers to frequently asked questions about the contest.
Mastermind is a registered trademark of Pressman Toy Corporation.
Contests are divided into segments where some or all of the scores and code may be hidden for some users. Here are the segments for this contest: