Random To

From StarLogo Nova Wiki
Revision as of 18:17, 16 August 2023 by FuzzyBot (talk | contribs) (Updating to match new version of source page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Other languages:
The random to block

A random number between and including the limits.

random [_] to [_] is a code block part of the Math drawer.

Usage

random [_] to [_] defines the upper and lower bounds of a range from which a random number is generated. The number is generated between and including the set limits.

Syntax

The Random to Block

Inputs in this block:

  1. defines the lower limit
  2. defines the upper limit for the range of the generated random number.

Common Uses

  • The random [_] to [_] block is most commonly used for random movement. When inserted into a Movements block such as the left by [_] degs combined with the forward[_] block, an agent will wander throughout Spaceland in a random direction.

Example

Random To example gif
Random To example code

One of the most common uses of the ‘random to’ block is for random movement. As shown above, creating a random turn, and combining that with a forward block, allows an agent to wander throughout spaceland in a random direction.

Related Blocks