Question: In C++: Complete 8.12 in your textbook, Simulation: The Tortoise and the Hare . F or full credit, you must use pointer-based pass-by-reference functions (Use

In C++: Complete 8.12 in your textbook, Simulation: The Tortoise and the Hare. For full credit, you must use pointer-based pass-by-reference functions (Use func(int*) not func(int&)) which are described in chapter 8.4, and random number generation (Use randomInt(engine) not rand()) described in chapter 6.9. In C++: Complete 8.12 in your textbook, Simulation: The Tortoise and the

8.12 (Simulation: The Tortoise and the Hare) In this exercise, you'll re-create the classic race of the tortoise and the hare. You'll use random number generation to develop a simulation of this memorable event. Our contenders begin the race at square 1" of 70 squares. Each square represents a possible position along the race course. The finish line is at square 70. The first contender to reach or pass square 70 is rewarded with a pail of fresh carrots and lettuce. The course weaves its way up the side of a slippery mountain, so occasionally the contenders lose ground. There is a clock that ticks once per second. With each tick of the clock, your program should use function move Tortoise and moveHare to adjust the position of the animals according to the rules in Fig. Animal Move type Percentage of the time Actual move Tortoise Hare Fast plod Slip Slow plod Sleep Big hop Big slip Small hop Small slip 50% 20% 30% 20% 20% 10% 30% 20% 3 squares to the right 6 squares to the left 1 square to the right No move at all 9 squares to the right 12 squares to the left 1 square to the right 2 squares to the left Fig. 8.18 Rules for moving the tortoise and the hare. 1 8.12 (Simulation: The Tortoise and the Hare) In this exercise, you'll re-create the classic race of the tortoise and the hare. You'll use random number generation to develop a simulation of this memorable event. Our contenders begin the race at square 1" of 70 squares. Each square represents a possible position along the race course. The finish line is at square 70. The first contender to reach or pass square 70 is rewarded with a pail of fresh carrots and lettuce. The course weaves its way up the side of a slippery mountain, so occasionally the contenders lose ground. There is a clock that ticks once per second. With each tick of the clock, your program should use function move Tortoise and moveHare to adjust the position of the animals according to the rules in Fig. Animal Move type Percentage of the time Actual move Tortoise Hare Fast plod Slip Slow plod Sleep Big hop Big slip Small hop Small slip 50% 20% 30% 20% 20% 10% 30% 20% 3 squares to the right 6 squares to the left 1 square to the right No move at all 9 squares to the right 12 squares to the left 1 square to the right 2 squares to the left Fig. 8.18 Rules for moving the tortoise and the hare. 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!