Regular API function

sim.getRandom

Description Generates a random value in the range between 0 and 1. The value is generated from an individual generator attached to the calling script (i.e. scripts do not share a common generator as is the case with Lua's math.random function). sim.getRandom has however also been wrapped inside of two new Lua functions, in order to mimic Lua's math.random and math.randomseed:
function math.random2(lower,upper) local r=sim.getRandom() if lower then local b=1 local d if upper then b=lower d=upper-b else d=lower-b end local e=d/(d+1) r=b+math.floor(r*d/e) end return r end function math.randomseed2(seed) sim.getRandom(seed) end
C/C++
synopsis
C/C++
parameters
C/C++
return value
Lua
synopsis
float randomValue=sim.getRandom(int seed=nil)
Lua
parameters
seed: an optional number that can be used to seed/reseed the random number generator. Leave empty or set to nil if the generator should not be reseeded.
Lua
return values
randomValue: a random number in the range of 0 and 1
Python
synopsis
float randomValue=sim.getRandom(int seed=None)