# Mastermind type versus system

I'm thinking of incorporating a versus/competitive system into my webgame ( ninjawars.net ), based off of the old "mastermind" game.

Let's call choosing the color dots in mastermind the "defensive" role, and determining what color dots were placed the "offense" role.

Mastermind is already competitive, but when creating the "color dots" there's a limited amount of added difficulty that you can create (e.g. all random color nodes using a random number generator is probably the most difficult you could get [I think that's true, random is the hardest case to crack, all one color is obviously the easiest]) but what I would like to do is be able to allow players to increase the difficulty from their defensive role by adding to the number of color dots that the defender can use. For example, instead of 4 dots, the defender could have, I don't know, 20 dots, much harder. Or only get to place 1 dot, so they have a much simpler defense.

So the question is, how do I determine good amounts of more dots to allow the defender? Some measure of the simplicity of determining 1 dot, all the way up to the difficulty of X (quite a few) of dots? I'd really like to be able to mathematically determine number of possible combinations, but I... ...guess I was asleep during that part of school...

What you seem to be looking for is a refresher in Probability and Statistics.

For instance, if a player can choose between 4 colors/symbols for 6 spots there are 4*4*4*4*4*4 or 4^6=4096 possible combinations. 4 colors/symbols for 20 spots is 4^20=1,099,511,627,776. With over a trillion possible combinations, that means the probability of a player guessing the 20 spot on the first try is worse than winning most lotteries.

In a game like Mastermind, each try eliminates possibilities (in Prob & Stats terms, tries are not "independent", unlike a game like "guess the coin flip"), improving the probabilities as the game continues. The more a player knows about the code from feedback (symbols locking, symbol match counts, and other feedback), the fewer combinations the player has remaining to check and the better the probability on the next check.

Hopefully that should be a good start to help you find some of the difficulty information you are looking for.

• That refresher is kinda what I was looking for thanks. I guess I wasn't sure how fast the combinations were added. – Kzqai Sep 23 '10 at 23:13

A good deal of research has been done for you, actually. The enjoyable problem is trying to see how few moves can be done to solve the problem. If you look up Mastermind_(board_game) in Wikipedia, you'll see that for a six-color four-slot game, there's a Six Guess algorithm, that Donald Knuth busted with a Five Guess algorithm, and later two more smart guys got it down to a little more than 4 guesses per game on average.

Letting the user know a little bit about the problem space can help make it a little easier: e.g., do you use a color more than once, is there a pattern, etc. Increasing the number of colors, or the number of slots, adds more complexity.

I'd also point out that the game goes by the name of "Bulls and Cows", "Codebreaker", and "Jotto" -- you may be able to find independent research papers under these names that are useful.

Playtesting. Make a bunch of variations (you could also vary difficulty by changing the number of available colors) and bug everyone you know to try them. Look at the win/loss ratios of the various versions and go from there.