osu-web
osu-web copied to clipboard
Add FastRandom PRNG
will be required for logic of selecting bundled maps, and maybe more stuff in the future since this is used for a few different things in the osu client. there's a lot of weird bit masking going on here because PHP doesn't have the data types for fastrandom...
Algorithm needs to be documented somewhere else; link is no longer live.
Just remove the link and rely on the lazer one, it's been proven accurate.
Honestly we could go without this implementation and rely on PHP's instead, if that's a decided direction. The client will eventually be updated to be server-dependent to get this bundled listing, so this is temporary at best.
I'm confused as to why we need to port over the exact PRNG algorithm from lazer? Do the results need to be exactly identical to lazer for some reason? We already have a seeded shuffle (see seeded_shuffle
in helpers.php
) that could be used if a deterministic randomisation is required?
(edit: thanks to github for not auto-updating the page with the response above until after I posted >.>)
It's to match what stable is using to decide on bundled maps. This allows server and client to match without making changes to stable.
May be future use cases as this is our go-to seeder for lazer and stable alike.
well that's a very unhelpful diff since I moved stuff around. I renamed nextInt
=>nextInt32
and nextNonnegativeInt
=>nextInt31
, because "nonnegative" makes it seem like nextInt
produced negative values, but that only happens on 32bit php which I assume nobody is using
so now the names make sense on every environment. also I made all of the tests pass for 32/64, didn't bother with nextdouble on 32 so marked as skipped