random random value

random [x, y, z] chooses a random value.

The following program may produce a different result each time:

write random [3, 5, 7]

Random can be used on a range of numbers. The returned number will be greater than or equal to the first number, and less than the second one:

write random 1, 101

Or on a list of strings:

write random [
  "apple pie"
  "ice cream"
  "cookie"
]

If called with no arguments, do random gives a number between zero and one:

write do random

There are some special arguments for random: color (saturated color), gray (gray level), position (screen location), normal (normally distributed number).

moveto random position
dot(
  random(color),
  abs(random(normal) * 50)
)