# Difference: TurtleRacingExample (1 vs. 5)

#### Revision 52019-02-12 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="IntroToCSF2018"

Line: 6 to 6

# Turtle Racing Example

We can generate random numbers in a range:
Changed:
<
<
<iframe frameborder="0" height="500px" src="https://repl.it/@JimSkon/StarkFuzzyConsultant?lite=true" width="100%"></iframe>
>
>
Consider the following. Try it out:

#### Revision 42018-09-20 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="IntroToCSF2018"

Line: 6 to 6

# Turtle Racing Example

We can generate random numbers in a range:
Changed:
<
<
>
>
<iframe frameborder="0" height="500px" src="https://repl.it/@JimSkon/StarkFuzzyConsultant?lite=true" width="100%"></iframe>
Consider the following. Try it out:
Changed:
<
<
>
>
<iframe frameborder="0" height="500px" src="https://repl.it/@JimSkon/DisgustingHumbleCharactercode?lite=true" width="100%"></iframe>
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

Line: 25 to 25
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?
>
>
Solution

 META FILEATTACHMENT attachment="r37L2zhYXG-8.png" attr="" comment="" date="1537310405" name="r37L2zhYXG-8.png" path="r37L2zhYXG-8.png" size="39402" user="JimSkon" version="1"

#### Revision 32018-09-19 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="IntroToCSF2018"

>
>

# Turtle Racing Example

Changed:
<
<
We can generate random numbers in a range:
>
>
We can generate random numbers in a range:

Line: 13 to 13

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

Changed:
<
<
We can make the code nicer by breaking it into functions: https://repl.it/@JimSkon/LeafyPushyVirtualmachines
>
>
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!
Changed:
<
<

>
>
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?

 META FILEATTACHMENT attachment="r37L2zhYXG-8.png" attr="" comment="" date="1537310405" name="r37L2zhYXG-8.png" path="r37L2zhYXG-8.png" size="39402" user="JimSkon" version="1"

#### Revision 22018-09-18 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="IntroToCSF2018"

Changed:
<
<
>
>

# Turtle Racing Example

We can generate random numbers in a range:

Line: 15 to 17
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!

>
>

 META FILEATTACHMENT attachment="r37L2zhYXG-8.png" attr="" comment="" date="1537310405" name="r37L2zhYXG-8.png" path="r37L2zhYXG-8.png" size="39402" user="JimSkon" version="1"

#### Revision 12018-09-18 - JimSkon

Line: 1 to 1
>
>
 META TOPICPARENT name="IntroToCSF2018"

# 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.

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!

Copyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback