• As part of the relaunch of Skullheart, ALL previous threads have been archived. You can find them at the bottom of the forum in the Archives (2021) section. The archives are locked, so please use the new forum sections to create new discussion threads.

How Random is 'Random'?

Choose Goose

#sadboys
Joined
Sep 3, 2013
Messages
256
Reaction score
284
Points
63
Age
33
Valentine Ms. Fortune Double
Just curious if anyone knows how the random options in training mode are done (from a technical standpoint).

Default rand()? I Ching?? Mike Z throwing darts???
 
_seed = _seed * 1103515245 + 12345; // want to keep ALL this information
unsigned toReturn = (unsigned int)(_seed/65536) % 32768; // want to return a controlled number

srand(time) at some point to start with. I don't remember why any of it.

[edit]Not really srand, but y'know start-the-seed-with-it, because it's our own rng and seed. There are a bunch of different RNGs instantiated for different things.
 
(unsigned int)(_seed/65536) % 32768;
There's nothing I don't like about this operation.
 
_seed = _seed * 1103515245 + 12345; // want to keep ALL this information
unsigned toReturn = (unsigned int)(_seed/65536) % 32768; // want to return a controlled number

srand(time) at some point to start with. I don't remember why any of it.

So after googling that first line, you get http://en.wikipedia.org/wiki/Linear_congruential_generator with an entry listing common parameters. So that matches that. Then 65536 is the largest value a unsigned short can handle, 32768 is the largest for a signed short.

You go from 16-30 bits to 16 then modulo to end up with a number between 0 and 32767. Can I see an example of what would use this value~

tl;dr you didn't know what to do and googled it lel
 
You know it. Random enough for someone else is random enough for me! We only use ranges like 0-1000 ever anyway.
 
Someone write an article and title it "Google Supported Development of Skullgirls".

Thanks again Mike!