Math.randomseed()
ចំណែកមួយនេះវិញប្រើដើម្បីបញ្ចូល X ជា Seed សំរាប់ pseudo random generator: equal seeds produce equal sequences of numbers
Syntax: math.randomseed (x)
X(តំរូវការ) វាជាចំនួនលេខ
សូមមើលកូដះ
math.randomseed(1234)
print (math.random(), math.random(), math.random()) ----> 0.31763056866714 0.416967588671 0.97426279353642
math.randomseed(1234)
print (math.random(), math.random(), math.random()) ----> 0.31763056866714 0.416967588671 0.97426279353642
math.randomseed( os.time() ) ----> a different sequence each time if there is a long enough time between invocations
No comments:
Post a Comment