subject

In the land of Puzzlevania, Aaron, Bob and Charlie had anargument over which one of them was the greatest puzzler of alltime. To end the argument once and for all, they agreed on a duelto the death. Aaron is a poor shooter and only hits his target witha probability of 1/3. Bob is a bit better and hits his target witha probability of 1/2. Charlie is an expert marksman and nevermisses. A hit means a kill and the person hit drops out of the duel. To compensate for the inequities in their marksmanshio skills, it is decided that the contestants would fire in turns startingwith Aaron, followed by Bob, and then by Charlie. The cycle wouldrepeat until there was one man standing. And that man would beremembered as the greatest puzzler of all time.

Required:
a. Write a function to simulate a single shot. It should use the following declaration: void shoot (bool&targetAlive, doubleaccuracy); This would simulate someone shooring attargetAlive with the given accuracy by generating a random number between 0 and 1. If the random number is less than accuracy, then the target is hit and targetAlive should be set to false. For example, if Bob is shooting at Charlie, this could be invoked as: shoot(charlieAlive, 0.5);

b. An obvious strategy is for each man to shoot at the most accurate shooter still alive on the grounds that this shooter is the deadliest andhas the best chance of hitting back. Write a second function named startDuel that uses the shootfunction to simulate an entire duel using this strategy. It should loop until only one contestant is left, invoking hte shoot function with the proper target andprobability of hitting the target according to who isshooting. The function should return a variable that indicate who won the duel.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 09:50
Suppose you are an ad-serving company and you maintain a log of cookie data for ads you serve to the web pages for a particular vendor (say amazon). a. how can you use this data to determine which are the best ads? b. how can you use this data to determine which are the best ad formats? c. how could you records of past ads and ad clicks to determine which ads to send to a given ip address? d. how could you use this data to determine how well the technique you used in your answer to part c was working? e. how could you use this data to determine that a given ip address is used by more than one person? f. how does having this data give you a competitive advantage vis-à-vis other ad-serving companies?
Answers: 2
question
Computers and Technology, 24.06.2019 16:00
How are roger williams, james oglethorpe, and william penn similar?
Answers: 3
question
Computers and Technology, 25.06.2019 01:30
What controls can be found on the file tab of microsoft word
Answers: 1
question
Computers and Technology, 25.06.2019 02:00
What type of multimedia is a game cd? game cds are examples of multimedia
Answers: 1
You know the right answer?
In the land of Puzzlevania, Aaron, Bob and Charlie had anargument over which one of them was the gre...
Questions
question
Mathematics, 26.06.2020 16:01
question
Mathematics, 26.06.2020 16:01
question
Mathematics, 26.06.2020 16:01
question
Mathematics, 26.06.2020 16:01