HOW to develop a program that plays the game of Mastermind by C programming?
The Game of Mastermind
Mastermind is a simple code-breaking board game for two players, i.e., a codemaker and a
codebreaker, invented in 1970 by Mordecai Meirowitz.
The codemaker secretly creates a code consisting of four colors selected from the set
{red, white, green, blue, black, yellow}, with duplicates allowed. The codebreaker tries to
guess the colors as well as the positions of the colors in the secret code. For each guess that
the codebreaker makes, the codemaker provides feedback in the following form:
1. The number of “black hits”, indicating the number of colors that are correct and in the
correct position.
2. The number of “white hits”, indicating the number of colors that are correct but in the
wrong position.
For instance, suppose we use the digits 0, 1, 2, 3, 4 and 5 to form the code. If the secret code
created by the codemaker is 0123 and the guess by the codebreaker is 0011, the codemaker
should provide a feedback of one black hit (B = 1) and one white hit (W = 1). Once feedback
is received, another guess is made by the codebreaker. The players continue to alternate turns
until the codebreaker guesses correctly.
Your Task
Develop a program that plays the game of Mastermind.
The user should be given the options to play the roles of codemaker and codebreaker. A game
is complete when the codebreaker succeeds in determining the secret code created by the
codemaker. Once a game has been completed, the user should be prompted for new games.
More games should be played until the user chooses to end the game.