To solve the below programming ask, please use C++. For some context, I had shared this same with a Bartleby expert but the code shared did not compile. Hence, I am resending this request again so you can resend another C++ solution for it. Thanks   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 the function moveTortoise and moveHare to adjust the position of the animals according to the rules in Fig. 8.18 (attached). These functions should use pointer-based pass-by-reference to modify the position of the tortoise and the hare.   Use variables to keep track of the positions of the animals (i.e., position numbers are 1–70). Start each animal at position 1 (i.e., the “starting gate”). If an animal slips left before square 1, move the animal back to square 1. Generate the percentages in Fig. 8.18 by producing a random integer i in the range 1≤i≤10. For the tortoise, perform a “fast plod” when 1≤i≤5, a “slip” when 6≤i≤7 or a “slow plod” when 8≤i≤10. Use a similar technique to move the hare. Begin the race by displaying   BANG !!!!! AND THEY'RE OFF !!!!! For each tick of the clock (i.e., each iteration of a loop), display a 70-position line showing the letter T in the tortoise’s position and the letter H in the hare’s position. Occasionally, the contenders land on the same square. In this case, the tortoise bites the hare and your program should display OUCH!!! beginning at that position. All positions other than the T, the H or the OUCH!!! (in case of a tie) should be blank. After displaying each line, test whether either animal has reached or passed square 70. If so, display the winner and terminate the simulation. If the tortoise wins, display TORTOISE WINS!!! YAY!!! If the hare wins, display Hare wins. Yuch. If both animals win on the same clock tick, you may want to favor the tortoise (the “underdog”), or you may want to display It's a tie. If neither animal wins, perform the loop again to simulate the next tick of the clock.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

To solve the below programming ask, please use C++.

For some context, I had shared this same with a Bartleby expert but the code shared did not compile. Hence, I am resending this request again so you can resend another C++ solution for it. Thanks

 

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 the function moveTortoise and moveHare to adjust the position of the animals according to the rules in Fig. 8.18 (attached)These functions should use pointer-based pass-by-reference to modify the position of the tortoise and the hare.

 

Use variables to keep track of the positions of the animals (i.e., position numbers are 1–70). Start each animal at position 1 (i.e., the “starting gate”). If an animal slips left before square 1, move the animal back to square 1.

Generate the percentages in Fig. 8.18 by producing a random integer i in the range 1≤i≤10. For the tortoise, perform a “fast plod” when 1≤i≤5, a “slip” when 6≤i≤7 or a “slow plod” when 8≤i≤10. Use a similar technique to move the hare.

Begin the race by displaying

 

BANG !!!!!

AND THEY'RE OFF !!!!!

For each tick of the clock (i.e., each iteration of a loop), display a 70-position line showing the letter T in the tortoise’s position and the letter H in the hare’s position. Occasionally, the contenders land on the same square. In this case, the tortoise bites the hare and your program should display OUCH!!! beginning at that position. All positions other than the T, the H or the OUCH!!! (in case of a tie) should be blank.

After displaying each line, test whether either animal has reached or passed square 70. If so, display the winner and terminate the simulation. If the tortoise wins, display TORTOISE WINS!!! YAY!!! If the hare wins, display Hare wins. Yuch. If both animals win on the same clock tick, you may want to favor the tortoise (the “underdog”), or you may want to display It's a tie. If neither animal wins, perform the loop again to simulate the next tick of the clock.

**Fig. 8.18 Rules for Moving the Tortoise and the Hare**

This table outlines the rules for determining the movements of the tortoise and the hare in a race scenario. Each animal has different movement types that occur with specified probabilities, affecting their position on the race track.

### Tortoise Movements:
- **Fast plod:** Occurs 50% of the time, resulting in the tortoise moving 3 squares to the right.
- **Slip:** Occurs 20% of the time, causing the tortoise to move 6 squares to the left.
- **Slow plod:** Occurs 30% of the time, advancing the tortoise 1 square to the right.

### Hare Movements:
- **Sleep:** Happens 20% of the time, with no movement occurring.
- **Big hop:** Happens 20% of the time, moving the hare 9 squares to the right.
- **Big slip:** Happens 10% of the time, moving the hare 12 squares to the left.
- **Small hop:** Happens 30% of the time, moving the hare 1 square to the right.
- **Small slip:** Happens 20% of the time, moving the hare 2 squares to the left.

This structured approach allows for a probabilistic simulation of the race, emphasizing the unpredictability and varied pacing of each animal.
Transcribed Image Text:**Fig. 8.18 Rules for Moving the Tortoise and the Hare** This table outlines the rules for determining the movements of the tortoise and the hare in a race scenario. Each animal has different movement types that occur with specified probabilities, affecting their position on the race track. ### Tortoise Movements: - **Fast plod:** Occurs 50% of the time, resulting in the tortoise moving 3 squares to the right. - **Slip:** Occurs 20% of the time, causing the tortoise to move 6 squares to the left. - **Slow plod:** Occurs 30% of the time, advancing the tortoise 1 square to the right. ### Hare Movements: - **Sleep:** Happens 20% of the time, with no movement occurring. - **Big hop:** Happens 20% of the time, moving the hare 9 squares to the right. - **Big slip:** Happens 10% of the time, moving the hare 12 squares to the left. - **Small hop:** Happens 30% of the time, moving the hare 1 square to the right. - **Small slip:** Happens 20% of the time, moving the hare 2 squares to the left. This structured approach allows for a probabilistic simulation of the race, emphasizing the unpredictability and varied pacing of each animal.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY