CS 0447 – Project 1: Mastermind

Due: Sunday, June 17, 2012 by 11:59pm

Description

Your first project is to implement the game of Mastermind. In this game, the computer chooses 4 pegs that can each be one of 6 colors.  The player’s job is then to guess the colors that the computer has chosen in the proper order. After each guess by the player, the computer will give two numbers as feedback:

1.       The first number is how many pegs are the proper color and in the proper position.

2.       The second number is how many pegs are the proper color, but not in the correct position.

The player wins when they guess the exact string of colors that the computer guessed. The player must guess correctly in 10 or fewer guesses, otherwise the player loses.

What you need to do:

·         Generate a random computer guess of four pegs out of these 6 colors:

o   Red, Orange, Yellow, Green, Blue, Purple

·         Read a guess from the user as a string of colors (see example below)

·         Score the guess, and report the two values back to the user

·         Allow the user to continue to guess until they get it correct, or reach 10 turns and they lose.

·         Allow the user to play the game multiple times

Example:

Welcome to Mastermind!

 

Enter guess number 1:

rrrr

Colors in the correct place: 1

Colors correct but in the wrong position: 0

 

Enter guess number 2:

 

You win!

Would you like to play again? yes

Hints:

Submission

Create a zip file of your source code and a README.txt text file that has your name, your Pitt username and any notes for the TA to help with grading.

You will upload the zip file to a website whose URL will be posted on the class website shortly before the due date.