Concept explainers
Mastermind is a code-breaking game for two players.
In the original real-world game, one player A selects 4 pegs out of 6 colors and puts them in a certain fixed order; multiples of colors are possible (for example, red-green red-green). His opponent B does not know the colors or order but has to find out the secret code. To do so, B makes a series of guesses, each evaluated by the first player. A guess consists of an ordered set of colors which B believes is the code. The first player A evaluates the guess and feeds back to B how many positions and colors are correct. A position is correct ("black") if the guess and the secret code have the same color. Additional colors are correct ("white"), if they are in the guess and the code, but not at the same location. For example
1 2 3 4
secret: red-green red green
guess: red blue green purple
results in one correct position ("black = 1") for the red peg at position one and one additional correct color ("white=1") for the green peg in the guess. Note that one "green" in the guess matches only one of the two "greens" in the secret code.
There are versions of mastermind with more or fewer positions than four, and more or fewer colors than six. Instead of colors use numbers in your code; ie the codes should be stored in N-element arrays of integers in the range from 1 to M.
The task: Write code that implements mastermind with N positions and M colors (encoded by numbers from 1 to M). N and M should be parameters of the code; the code should work for any positive choice of N and M (up to a maximum value of M=9). The code should take the role of player A in the description above, such that the user has to guess a secret code (role B); ask the user for N and M at the beginning, and then enter the main loop that iteratively starts new games until the user indicates an exit-condition (the code may ask the user if he wants to play again).
In a game, the computer generates a random secret according to the chosen values of N and M, and then iteratively asks the user for guesses. A guess would be evaluated and the results printed, i.e., the number of correct positions "black", and the number of additional correct 'colors' "white". The program would recognize if the secret code has been correctly identified, print a message, and start again.
I need this console game in C#
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
- Python : Make a hangman with this condition Make a hangman game (must show the user how many guesses they have left) Draw the hangman using matplotlibarrow_forward2) scrooge.py Scrooge McDuck is letting you into his vault full of pennies, nickels, dimes and quarters. He will let you play the following game: you can pick 8 coins at random, and if they sum to at least a dollar, you win, and can keep your money! But if you lose, you don't get to keep the money, AND have to pay Scrooge a dollar. (Each coin you pick is equally likely to be a penny, nickel, dime, or quarter.) Your job: using a simulation, estimate 1. the probability that you win (meaning your coins sum to more than a dollar), and 2. if you play this game over and over, the average amount you will win (where the amount you win in a game could be negative). Here is a bit more direction: you should simulate 100,000 plays of this game. Each simulated play should involve picking 8 different random numbers - each one should be .01, .05, .10, or .25, with each value equally likely - which represent the 8 coins being chosen; these should be summed each time. As you proceed through these…arrow_forwardYou roll a number cube numbered from 1 to 6. You then spin a spinner with 3 sections each with a different color. The spinner has the colors yellow, pink, and green. P(not green and not 2).arrow_forward
- In the Dice Roll game, the player begins with a score of 1000. The player is prompted for the numberof points to risk and a second prompt asks the player to choose either high or low. The player rollstwo dice and the outcome is compared to the player’s choice of high or low. If the dice total is between2 and 6 inclusive, then it is considered “low”. A total between 8 and 12 inclusive is “high”. A total of7 is neither high nor low, and the player loses the points at risk. If the player had called correctly, thepoints at risk are doubled and added to the total points. For a wrong call, the player loses the points atrisk. Create a DiceRollGame application that uses a DRPlayer object based on this specification. TheDRPlayer object should have two Die member variables that represent the dice. The Die class shoulduse a random number generator to determine the outcome in a roll() method. Application outputshould look similar to:arrow_forwardGiven code: int s=0; for ( int i=1; i<5; i++ ){ s = s + i ; } Which one is correct, after running the code. Group of answer choices s=1 s=15 s=10 s=5arrow_forwardQ2: A mercury thermometer having a time constant of 0.1 min is placed temperature bath at 100°F and allowed to come to equilibrium with the bath. At time t= 0, the temperature of the bath begins to vary sinusoidally about its average temperature of 100°F with an amplitude of 2°F If the frequency of oscillation is 10/π cycles/min, What is the phase lag? In terms of the symbols used T = 0.1 <0 120 f = 10 元 s=100 x(t) = 100+ 2 sin(wt)) يسيفر نظارت دقت السائل SLOWarrow_forward
- In the Dice Roll game, the player begins with a score of 1000. The player is prompted for the numberof points to risk and a second prompt asks the player to choose either high or low. The player rollstwo dice and the outcome is compared to the player’s choice of high or low. If the dice total is between2 and 6 inclusive, then it is considered “low”. A total between 8 and 12 inclusive is “high”. A total of7 is neither high nor low, and the player loses the points at risk. If the player had called correctly, thepoints at risk are doubled and added to the total points. For a wrong call, the player loses the points atrisk. Create a DiceRollGame application that uses a DRPlayer object based on this specification. TheDRPlayer object should have two Die member variables that represent the dice. The Die class shoulduse a random number generator to determine the outcome in a roll() method. Application outputshould look similar to:arrow_forwardFlashback to Probability: Determine the odds of rolling TWO 6-sided dice, and getting a total between the two dice that is a multiple of three.arrow_forwardSubstitution ciphers are encryption/decryption algorithms that replace one letter or number with another. The first attested use of a substitution cipher in military affairs was by Julius Caesar, described by him in Gallic Wars (cf. Kahn pp83-84). In caesar cipher , you replace each letter by 3rd letter on. If it is out of bound (later than Z), then round to the head (letter A) and continue the shift. For example:meet me after the toga party PHHW PH DIWHU WKH WRJD SDUWB Please write a program in Java to implement the Caesar Cipher: a. Implement the encryption algorithm. Ask the user to input one all lower case normal sentence (called plaintext) using the nextLine method, and then output the encrypted text (called ciphertext). b. Implement the decryption algorithm. Ask the user to input one encrypted sentence (i.e. ciphertext) using the nextLine method, and then output the decrypted text (i.e. plaintext).arrow_forward
- A "mad-lib" is a fill-in-the blank game. One player writes a short story in which some words are replacedby blanks. For each word that is removed, the appropriate part of speech is noted: e.g. noun (person/-place/thing), adjective (word that describes a noun), verb (an action, e.g. eat), adverb (modifies a verb, e.g.quickly). Then, before reading the story, the story-writer asks the other player to write down a word of theappropriate part of speech for each blank without knowing the context in which it will be used. In this way,a humorous (sometimes) or non-sensical (usually) story is created a)arrow_forwardExplain why this scenario requires the use of a loop structure. Scenario: Angel wants to find the first instance of a prime number greater than 999,999.arrow_forwardA fish-finder is a device used by anglers to find fish in a lake. If the fish-finder finds a fish, it will sound an alarm. It uses depth readings to determine whether to sound an alarm. For our purposes, the fish-finder will decide that a fish is swimming past if:there are four consecutive depth readings which form a strictly increasing sequence (such as 3 4 7 9) (which we will call "Fish Rising"), orthere are four consecutive depth readings which form a strictly decreasing sequence (such as 9 6 5 2) (which we will call "Fish Diving"), orthere are four consecutive depth readings which are identical (which we will call "Constant Depth").All other readings will be considered random noise or debris, which we will call "No Fish."Create a Python program called "fishfinder_firstname_lastname" that takes 1 input of string of 4 numbers separated with comma. Your program must display "Fish Rising", "Fish Diving.", "Fish At Constant Depth" or "No Fish".Example:30,10,20,20 Must display No…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education