osu-web icon indicating copy to clipboard operation
osu-web copied to clipboard

Add FastRandom PRNG

Open cl8n opened this issue 4 years ago • 6 comments

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...

cl8n avatar Sep 11 '20 00:09 cl8n

Algorithm needs to be documented somewhere else; link is no longer live.

notbakaneko avatar Sep 17 '20 06:09 notbakaneko

Just remove the link and rely on the lazer one, it's been proven accurate.

peppy avatar Sep 17 '20 06:09 peppy

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.

peppy avatar Sep 17 '20 06:09 peppy

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 >.>)

nekodex avatar Sep 17 '20 06:09 nekodex

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.

peppy avatar Sep 17 '20 06:09 peppy

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

cl8n avatar Sep 17 '20 20:09 cl8n