MicroWorlds


Random

The random command is used when it is required to set a random number between 1 and the number set in the command. For example the command random 5 selects a number between 1 and 5. In the example below a random distance from 1 to 20 is selected and a random angle between 1 and 360 is selected by the computer. This allows the bee to move randomly in any direction which has the effect of random flight.

 

Type the following procedure in the procedures page and then hatch at least 5 turtles with the command line buzzbee and select many times.

to buzzbee
setsh "bee1
setsh "bee2
fd random 20
rt random 360
end

Click on the turtles and they should fly around the screen.

Save and have checked and then you can move on to Procedures and Variables 

 




 



Created by Geoff Adcock
Last Update: 23-Oct-2006