? Random Numbers ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Random Numbers

RND( [ channel , ] range ) - Returns a random integer from 0 to range-1 - range: Integer. Number of values to choose from. - channel: Integer 0-7 (Optional, defaults to 0). Randomizer channel to use. (SB has 8 independent randomizer "channels". Usually you'll just use the default channel, 0.) RNDF( [ channel ] ) - Returns a random number from 0 to 1 - channel: Integer 0-7 (Optional, defaults to 0). Randomizer channel to use. RANDOMIZE channel [ , seed ] - Sets the randomizer seed. - channel: Integer 0-7. Randomizer channel to re-seed. - seed: Integer (Optional, defaults to 0). The seed to use. (If 0, a random seed will be chosen).

Examples:

Print a random number from 1 to 6: PRINT RND(6)+1 This should be 0.20871972: RANDOMIZE 0,398 PRINT RNDF()
Author
12Me21
Updated
Rating
1 vote
Categories
Keywords
  • rnd
  • rndf
  • randomize
  • random
  • rand
  • seed
  • randomizer
1 Comment(s) Minxrod Minxrod Summer 2016 Contest Participant I participated in the SmileBASIC Source Summer 2016 Contest! Programming Contest Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Pokemon Is Awesome! I love Pokemon! Express Yourself Do you think you could add a note about syncing RNG in multiplayer? Like how you must make sure to use the same seed & channel or else games can desync? This has happened to me before, as it isn't an obvious problem.