Turtle Racing Example

Turtle Racing Example

r37L2zhYXG-8.png
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!


Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng r37L2zhYXG-8.png r1 manage 38.5 K 2018-09-18 - 22:40 JimSkon  
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r2 - 2018-09-18 - JimSkon
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 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