The whole reason is that math.randomseed is not called at the beginning of [wiki]love.run[/wiki], because Löve has a better, OS-agnostic PRNG function, that does have its seed set at the start up of the program.
See: [wiki]love.math.random[/wiki] Edit: ninja'd
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Yes BUT, use love.math.random in one of the callbacks, like e.g. [wiki]love.load[/wiki], and not in the main body, because at the moment of running the main body it won't be initialized yet.
Wait, doesn't calling love.math.random twice let me use different numbers for the second and on calls? (Provided I'm doing that outside the love.load?)
Iirc that was only ever a dirty hack for the lua math.random call, because the generator used was so garbage, the first few values regardless of seed were always very similar.
A PRNG or pseudo-random number generator only guarantees these things: (or, it should, at least)
You have a function to set the seed, one to get it, and one to get back one value from the generator.
The PRNG somehow notes how many times it has been called for a value.
Using the same seed, you will get back the same values in the same order every time.
Of course, this can hinge on internals very much. If it uses float arithmetic for whatever reason, it might not be OS/Architecture/Whatever-compatible across vast computer configurations.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
4aiman wrote:Wait, doesn't calling love.math.random twice let me use different numbers for the second and on calls? (Provided I'm doing that outside the love.load?)
If I understand what you mean, the problem is that the sequence will always be the same. For me, this program:
That's not really random, in the sense that e.g. if you use these to generate enemies or the like, they will always be the same. It's a bit like this popular cartoon: https://xkcd.com/221/
pgimeno wrote:If I understand what you mean, the problem is that the sequence will always be the same. For me, this program: (...) in LÖVE 0.10 always prints (...) and in 0.9 it always prints (...)
That's not really random, in the sense that e.g. if you use these to generate enemies or the like, they will always be the same.
I'm guessing you mean with setting the seed to one specific value, right?
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Judging by given explanations, the seed for PRNG is set to something hardcoded and only during the love.load it is being set to is something random.
Okay... I guess.
Now, can I set a seed for PRNG prior love.load to get some PR results which will differ from the ones posted by pgimeno?
Or that won't work at all?
Ideally it would be cool to know whether those values generated by uninitialized generator differ from build to build (commit to commit).
I can't really test that myself due to having no access to a love2d-enabled device and a *very* slow and costly Internet.