Turtle Racing Example

Turtle Racing Example


We can generate random numbers in a range:

Consider the following. Try it out:


We want to make the turtles race each other. How? We can use the randrange function to pick a random number and go forward that much. Try it.

Use Functions

1. We can make the code nicer by breaking it into functions: https://repl.it/@JimSkon/LeafyPushyVirtualmachines

Now see if you can make the turtles race each other moving at the same time!

2. Can you print out who the winner is on the turtle window?

3. Can you make it work with 3 turtles?

4. Can you make the turtles race around a track of some sort? Can you ask at the beginning for the number of laps to finish?


This topic: Main > WebHome > IntroToCSS2020 > TurtleRacingExample
Topic revision: r1 - 2020-01-23 - JimSkon
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback