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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 10:30, tommyaberman
Would a ps4 wired controller work on an xbox one
Answers: 1
image
Computers and Technology, 23.06.2019 13:30, carolelai08
Stops: using the information learned in this course, explain three things you will not do when driving. a. b. c. explain why you will not do these things when driving. starts: using the information learned in this course, explain three things you will do when driving. a. b. c. explain why you will do these particular things when driving. explain one thing you will stop doing as a passenger. explain one thing you will start doing as a passenger.
Answers: 3
image
Computers and Technology, 23.06.2019 14:00, LuvIsRage2
Technician a says that with self-adjusting clutch systems, the release bearing constantly rotates. technician b says that the ball bearing portion of the release bearing should be lubricated with high-temperature grease during routine maintenance. which technician is correct?
Answers: 2
image
Computers and Technology, 23.06.2019 15:00, abelxoconda
1. which of the following statements are true about routers and routing on the internet. choose two answers. a. protocols ensure that a single path between two computers is established before sending packets over it. b. routers are hierarchical and the "root" router is responsible for communicating to sub-routers the best paths for them to route internet traffic. c. a packet traveling between two computers on the internet may be rerouted many times along the way or even lost or "dropped". d. routers act independently and route packets as they see fit.
Answers: 2
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 in other subjects:

Konu
Business, 04.02.2021 16:40