[Solved]Torstoise Hare 1 Problem Ll Recreate One Truly Great Moments History Namely Classic Race T Q37270109


Program language: MATLABThe Torstoise and the Hare 1 In this problem, you’ll recreate one of the truly great moments in history, namely the classic race of the tortoise and the hare. You’ll use random number generation to develop a simu- lation for this memorable event. Our contenders begin the race at “square 1 of 70 square. 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 adjust the position of the animals according to the rules on Table 1. justing positions Table 1: Tortoise and hare rules for ad Animal Move Tvpe Percentage of the time Actual move 3 squares to the right 6 squares to the left 1 square to the right Tortoise Fast plod 50% Plod 20% 20% Big hop 20% Big slip 10% Small hop 30% Small slip 20% Slip Slows plod 30% No move at all 9 square to the right 12 squares to the left 1 square to the right 2 squares to the left Hare Sleep 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 letft before square 1, move the animal back to square 1. Generate percentages in the preceding table by producing a random integer, k, in the range 1 S k s 10. For the tortoise, perform a “fast plot” when 1 skS 5, a “slip” when 6 S k s 7, or a “slow plod” when 8 s k s 10. Use a similar technique to move the hare. Begin the race by printingx rand rand And they’re off!!! The line en, for each tick of the clock (i.e., each repetition of a loop), print a 70-position showing the letter T in the position of the tortoise and the letter H in the position of the hare. Occasionally, the contenders will land on the same square. In this case, the tortoise bites the hare and your program should print OUCHI!!l beginning at that position. All print positions other than the T, the H, or the OUCH!!! (in case of a tie) should be blank. After each line is printed, test whether either animal has reached or passed square 70. If so, then print the winner and terminate the simulation. Ifthe tortoise wins, print WINS!!! YAY!! ‘If the hare wins, print Hare wins. Yuch: If both animals win on the same tick of the clock, you may want to favor the turtle (the underdog), or you may want to print It’s a tie. If neither animal wins, perform the loop again to simulate the next tick of the clock. When you’re ready to run your program, assemble a group of fans to watch You’ll be amazed at how involved your audience gets. TORTOISE the race. Show transcribed image text The Torstoise and the Hare 1 In this problem, you’ll recreate one of the truly great moments in history, namely the classic race of the tortoise and the hare. You’ll use random number generation to develop a simu- lation for this memorable event. Our contenders begin the race at “square 1 of 70 square. 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 adjust the position of the animals according to the rules on Table 1. justing positions Table 1: Tortoise and hare rules for ad Animal Move Tvpe Percentage of the time Actual move 3 squares to the right 6 squares to the left 1 square to the right Tortoise Fast plod 50% Plod 20% 20% Big hop 20% Big slip 10% Small hop 30% Small slip 20% Slip Slows plod 30% No move at all 9 square to the right 12 squares to the left 1 square to the right 2 squares to the left Hare Sleep 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 letft before square 1, move the animal back to square 1. Generate percentages in the preceding table by producing a random integer, k, in the range 1 S k s 10. For the tortoise, perform a “fast plot” when 1 skS 5, a “slip” when 6 S k s 7, or a “slow plod” when 8 s k s 10. Use a similar technique to move the hare. Begin the race by printingx rand rand And they’re off!!!
The line en, for each tick of the clock (i.e., each repetition of a loop), print a 70-position showing the letter T in the position of the tortoise and the letter H in the position of the hare. Occasionally, the contenders will land on the same square. In this case, the tortoise bites the hare and your program should print OUCHI!!l beginning at that position. All print positions other than the T, the H, or the OUCH!!! (in case of a tie) should be blank. After each line is printed, test whether either animal has reached or passed square 70. If so, then print the winner and terminate the simulation. Ifthe tortoise wins, print WINS!!! YAY!! ‘If the hare wins, print Hare wins. Yuch: If both animals win on the same tick of the clock, you may want to favor the turtle (the underdog), or you may want to print It’s a tie. If neither animal wins, perform the loop again to simulate the next tick of the clock. When you’re ready to run your program, assemble a group of fans to watch You’ll be amazed at how involved your audience gets. TORTOISE the race.
Expert Answer
Answer to The Torstoise and the Hare 1 In this problem, you’ll recreate one of the truly great moments in history, namely the clas… . . .
OR

