Random

Revision as of 05:31, 21 May 2024 by -u ndefined- (talk | contribs) (Make an infobox, and rework page)

A random number generator.

Random
Random.png
TypeScript block
ColliderNone
FolderMath
Ports
Inputs Min
Max
Outputs Random

Notes

  • Port inputs default to 0 and 1 respectively.
  • The Min input is included while the Max input is excluded, meaning: if the min and max inputs are 0 and 5 respectively, it may generate a number within 0 to 5, possibly 0, but never 5.
  • The random block will generate a new value every time it is executed. To reuse the same random value, it should be stored in a variable.
  • Note that the output would be in decimal. To avoid this use a rounding operation, ideally floor and secondarily round. Ceiling also works but is scarcely used.
  • The random block behaves inconsistently when used with wire splits:  

Examples

Either generate -1 or 1.

 

Output a random integer with equal probability.

 

Related