Question: In this game, the computer chooses 4 pegs each with one of 6 colors. This is the color - based predecessor to Wordle. The player
In this game, the computer chooses pegs each with one of colors. This is the colorbased predecessor to Wordle. The players 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 then give two numbers as feedback. The first number is how many pegs are the proper color and in the proper position. The second number is how many pegs are the proper color, but not in the correct position.
What you need to do:
Generate a random computer guess of four colors out of: 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 turns and they lose.
Allow the user to play the game multiple times
Generating random numbers in C is a twostep part. First, we need to seed the random number generator once per program. The idiom to do this is: srandunsigned inttimeNULL; When we need random numbers, we can use the rand function. It returns an unsigned integer between and RANDMAX. We can use modulus to reduce it to the range we need: int value randhigh low low;
Example:
Welcome to Mastermind!
Would you like to play? yes
Enter guess number : rrrr
Colors in the correct place:
Colors correct but in wrong position:
Enter guess number : rrgg
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
