BigMaster is better in principle but I was too lazy to give it a useful input routine. Works, though.
I have saved a few posts from usenet regarding mastermind and its variations. In short: optimal solutions are known. Also, here's analysis of Mastermind from a game-theoretic [average strategy] perspective.
I don't mean to suggest here that I've thought over the issue with any great detail. You can get some more information and suggestions for further reading by looking at some old USENET posts I saved, in particular an encoding of a simple automated solver. (This program does _not_ encode an optimal strategy.)
You can play mastermind across the net:
I received mail from a programmer who advertises "a free Mastermind game in which the computer can also guess your selection so that you can play against it and try to beat its average score over 10 or more games." See http://www.homestead.com/beat_computer_mastermind/mastermind.html
This page is
http://www.math.niu.edu/~rusin/uses-math/games/mastermind/index.htmlLast modified 2000/06/09 by Dave Rusin, rusin@math.niu.edu