Project 2: Mastermind
Project Due: Tuesday, Feb. 19, Midnight
NO CREDIT AFTER THE DEADLINE

Write the game Mastermind using Python. Here's the rules for Mastermind. You may use any set of colors you want, but it should be clear to the player of the game how to proceed.

Besides the rules, here are some additional specifications:

1. The game should be one player, user versus the computer. The computer program you write will generate the secret code and provide feedback for each guess. The secret code should be randomly generated for each new game. You can import the module 'random' and then call:

        random.randint(0,5)

to get a number between 0 and 5 inclusive. Then you'll need to convert that into a color (e.g., 'red') using an if-else clause.

2. If you'd like, the player can enter letters to denote each color. So 'RBYB' would be a guess of red, blue, yellow, blue. You can also have them enter full colors (e.g., Red) on different lines.

3. Print out the number of black pegs and the number of white pegs as the feedback for each guess, e.g.,

    2 whites, 1 black.

Note that the feedback only says how many exact and partial matches, and nothing about which slots are matching.

4. The system should perform error-handling and let the user know when she has entered an invalid color. The user should be allowed to try again until she enters a valid guess.

5. The system should have clear instructions so that someone (like your teacher) can sit down and play without asking the programmer (you) any questions.

6. You must write the program using functions for getGuess, generateSecretCode, computeExactMatches and computePartialMatches (you may combine the latter two into computeMatches, but splitting them is actually easier).

7. Write the program in a file called mastermind.py

Iterative Process

You should always develop software iteratively, that is, get a little part done, test it to make sure it works, then add a little bit, test, add a bit, test, until the software is complete.

Here is an iterative plan for this project.  Follow it, not only as a good way to complete a project, but because you'll be given partial credit for the project (15 points) for each iteration you complete.

1. Write the getGuess function that allows the player to enter four colors into a list. Use the function 'raw_input' to get the player's input. Print the list in main to make sure the colors are in the list correctly.

2. Write computeExactMatches, a function that compares a 'guess' list with a 'secretCode' list and increments a counter each time there is an exact match. Note that this code can be written and tested separately from (1). To test, just create guess and secret code lists with fixed values and compare them.

3. Write computePartialMatches so that it also compares a 'guess' list with a 'secretCode' list and increments a counter each time there is a partial match.

4. Write your main code with a loop so that the player can repeatedly enter guesses and received feedback from the system. At this point, the secretCode can be fixed, e.g., secretCode=['red','green','yellow','blue']

5. Add code so that, when the player enters a correct guess (all exact matches), the system prints out a congratulations and tells the user how many guesses were required.

6. Write generateSecretCode, which generates a random secret code

Extra Credit

Allow the user, when starting a new game, to choose the number of colors, up to ten. You can use a pre-defined set of colors (5)
Allow the user, when starting a new game, to choose the number of slots in a secret code or guess. (5)
Something cool (0-5)