ScratchData LogoScratchData
Back to Tutor-42's profile

The Tortoise and the Hare

TUTutor-42•Created August 16, 2019
The Tortoise and the Hare
2
1
68 views
View on Scratch

Instructions

Who will win the race - The Tortoise or the Hare? Look at their code, then choose your answer. A. The Tortoise (who will move 3x faster than the Hare) B. It will be a tie. (they will move at the same speed) C. The Hare (who will move 3x faster than the Tortoise) D. The Hare (who will move 4x faster than the Tortoise) Green Flag to check. The answer is below. Answer: D. The Hare runs 4x faster and wins. Explanation ---------------- When Scratch projects run, scripts take turns. (otherwise you would get stuck in a forever loop). Scripts "yield" execution to let other scripts run each time they reach the end of a loop. The scripts resume again at their next turn. To move 3 steps, the Tortoise script yields 4 times: three times at the end of the repeat loop after moving 1 step, and once at the end of the forever loop. To move 3 steps, the Hare script yields once at the end of the forever loop. So the Hare moves 4 times as fast as the Tortoise. Note that the Hare still wins in Turbo Mode although the race is much faster. A fuller explanation about Scratch "yield points" and fixes to this project is in this tutorial: https://scratch.mit.edu/discuss/post/3680398/ "Best Fix" project for The Tortoise and the Hare: https://scratch.mit.edu/projects/324480363/ (includes a "run without screen refresh" custom block and "broadcast and wait" between Moves).

Description

This tutorial discusses "yield points" then further down explains The Tortoise and the Hare and solutions: https://scratch.mit.edu/discuss/post/3680398/ "Best Fix" project for The Tortoise and the Hare: https://scratch.mit.edu/projects/324480363/ (includes a "run without screen refresh" custom block and "broadcast and wait" between Moves). Tortoise and Hare pictures from the wonderful project "The Hare and the Tortoise" by Guadalupe and Yakov: https://scratch.mit.edu/projects/380302/

Project Details

Project ID324376904
CreatedAugust 16, 2019
Last ModifiedNovember 29, 2019
SharedSeptember 12, 2019
Visibilityvisible
CommentsAllowed