Author Topic: "Random" Number Generator  (Read 1477 times)

Offline TechSY730

  • Core Member Mark V
  • *****
  • Posts: 4,570
"Random" Number Generator
« on: January 14, 2011, 04:13:36 pm »
In the 4.067 release notes:
Quote
Fixed a surprisingly longstanding (but heretofore unrecognized) bug that was making the random number generator sometimes be highly non-random. This was leading to things like a very odd default pattern of collision offsetting.

Obligatory XKCD link anyone?

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: "Random" Number Generator
« Reply #1 on: January 14, 2011, 04:16:23 pm »
Interestingly, 4 is the exact number of distinct results random.Next(0,360) was producing when picking a random angle (in degrees) for collision offsetting.  Not on every starting seed, but on a fair number of them, it seemed.
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Re: "Random" Number Generator
« Reply #2 on: January 14, 2011, 04:21:26 pm »
Even more interestingly, "surprisingly longstanding" means "as long as Mersenne Twister has been used in the game" or "since prior to 1.0, sometime before license keys existed for the game."  That's crazy long, and I'm shocked this hasn't been more of an issue before.
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Re: "Random" Number Generator
« Reply #3 on: January 14, 2011, 04:31:35 pm »
Going back and looking at the logs, I now see why this was never a problem: I got rid of the float conversion the very day I implemented Mersenne Twister here, which was March 6, 2009.  Well before I even thought of adding license keys.
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!