Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Simulation ( The Tortoise and the Hare ) , You will use a random generator and pointers to develop a simulation of this race. Our
Simulation The Tortoise and the Hare You will use a random generator and pointers to develop a simulation of this race.
Our players begin the race at "square of squares. A square is a position along the race course. The finish line is at square The course weaves up the side of a mountain, so the players might lose ground.
Every loop iteration tick per second should use the functions moveTortoise and moveHare to change the position of the players according to the following rules, the functions should use POINTERbase PASSByReference to modify the position of both players.
Player Move Type Percentage of time Actual move
Tortoise Fast Plod squares to the right
Slip squares to the left
Slow Plod square to the right
Hare Sleep No move at all
Big Hop squares to the right
Big slip squares to the left
Small Hop square to the right
Small slip squares to the left
Write the program to simulate the above by using variables to keep track of the players' positions Start each player at position Produce a random integer for the percentage called i in the range
fast plod i slip i slow plod i
sleep i Big Hop i Big slip i Small Hop i Small slip i
For each iteration, show a line of positions showing T for the position of the Tortoise and H for the Hare. If they have the same position, use the letter O for OUCH. Use a star for the rest of the positions. points
Display who is the winner. If the game is a tie, then display It is a tie". If there is no winner, then display No Winner". Stop the program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started