So does this function, but you shouldn't use it:
Code: Select all
function math.betterrandom() return 4 end
Indeed, neither of the two PRNG-s are cryptographically secure either, but there are properities one does want from their generators, even for games... idk about you but i'd be pissed off if i expected uniformity and did not receive that... or if it straight out didn't return specific numbers... or always returning a sequence like 5,24,163,5,24,163,...
Must be why old games had shitty bot ai, huh?BrotSagtMist wrote: ↑Fri Sep 17, 2021 7:24 pm This solution would work fine for bots in games, so in practice i would use it if needed.
Well, you didn't counter jack though; luajit can not support multiple PRNG-s using the two functions it offers, math.random and math.randomseedBrotSagtMist wrote: ↑Fri Sep 17, 2021 7:24 pm But really, its not that i thought long about it, just meant to counter the "doesn't even have an equivalence" part.
Yes. besides the upvalue thing, which kinda would be a decent solution in and of itself, and the speed which i don't care about that much, the implementation itself is flawed... pretty sure i did say this before as well. You can't just save the output of the math.random call and think "oh, this is going to be the next seed!", it won't work as expected, and since there's no way to get the current seed/internal state of the luaJIT PRNG, you can't save and restore that state in any way whatsoever.
But it's still going to work wrong and not do what you want; you can not save the PRNG's state.BrotSagtMist wrote: ↑Sat Sep 18, 2021 1:26 am Obviously its slower, but the whole point was not to show that loves version is superior but that it is possible to get away without using it with only little effort in pure lua/jit.
There is none, it's not possible... unless you re-implement the prng yourself in a way that can create separate generator objects, but that was not what the discussion was about.BrotSagtMist wrote: ↑Sat Sep 18, 2021 1:26 am Now for the sake of closing this thread: show me a _not horrid_ solution in stock lua/jit.
The original post's problem wasn't really about which prng they used, that was you opening your post with that opinion about it being better debug-able like that...BrotSagtMist wrote: ↑Sat Sep 18, 2021 1:26 am In THIS very case hitting replace straight forward raises the error, thus it would lead to the fastest solving of THIS problem. Other claims are interpreted into it.
Yeah, i didn't check the file because the issue was already solved; and yes, i am indeed correcting the eponymous someone who is actually dead wrong on the internet; hope no hard feelings though, i'm enjoying the banter myself.BrotSagtMist wrote: ↑Sat Sep 18, 2021 1:26 am Seeing that the file has only 3 downloads, i gather you are giving an opinion without even having looked at the file. For what?
Such fuss about a badly phrased tip.... on the bright side nothing is as instructive as a few pages of "someone is wrong on the internet!".