Mastermind is a code-breaking game between two players, the codemaker (in this case the computer) and the codebreaker (the player).
How to Play
See the following videohttps://www.youtube.com/watch?v=XwuwWTH39ac.
Project Requirements
The goal of the project is to implement a text-based/menu-drivenMastermindgame.
The game will include a menu from which the user will choose:
1. See Rules
2. Play Game
3. See Highest Score
4. Quit
- When the user chooses to play a game, the computer will generate a three-position code using five colors (Red/Blue/White/Yellow/Green).
The player will try to break the code by choosing a color for each of the three positions available - color repeats are allowed. Example: R G B (Red-Green-Blue)
The computer will provide feedback using three pins (one for each color) placed in non-related order:
·
o
Red Pin (R)– A color is part of the code and has been placed on the right position.
o
White Pin
(W)– A color is part of the code but has been placed on the wrong position.
o
No Pin (O)– The color is incorrect.
The game ends when either:
·
o The player wins. Breaks the code – three colors on the exact positions as initially generated by the computer. The player’s score is the round when the code was broken (1-10).
o The player loses. No code is broken after ten attempts. No score is awarded.
Assume the computer has generated the following code:
R G B
A possible output at the end of the second round could be:
Colors Pins
R R R R O O
R B Y R W O
- At the end of each game, the system will read in the score stored in “highscore.txt”.
- If the file does not exist, it will create one with the current player as the high score (name & score).
- If the user has scored higher than the value in the file, it will replace the text file with the current player’s name and score.
- Otherwise, the text file will remain intact.
· The user should be able to play as many times as he/she wishes.
Notes about Functionality, Implementation & Program Requirements:
1. The program should validate the information entered by the user and display the appropriate error messages.
2. The code should be self-documented, including:
1.
1.
§ Descriptive Comment indicating
§ Author
§ Program Summary
§ IPO Chart
§ Appropriate comments throughout the code that highlight, among other things, the implementation of the algorithm.
§ Adequate use of spaces and indentation so the source code is easy to read when printed out.
3. Functional decomposition implementation of the algorithm. Must define at least four different functions. Make sure to include functions that exemplify void vs. return-type, and value vs. reference parameters.
4. Two-Dimensional array implementation. The mastermind color & pin boards must be implemented using parallel two-dimensional arrays.
Grading Rubric
Documentation & Algorithm (5) ______
Menu-Driven interface (10) ______
See Rules (5) ______
Game Implementation (25) ______
- Generate code
Random function seeding & color generation
- Prompt player for guess
- Provide feedback
- Determine win/lose
- Loop up to ten rounds
Array Implementation (20) ______
- Two-Dimensional Arrays
- Parallel Arrays
File Manipulation (20) ______
- See highest score
- Create/Update highscore.txt
Functional Decomposition (20) ______
Game Interface (5) ______
Total (110/100)