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

Offline TechSY730

  • Core Member Mark V
  • *****
  • Posts: 4,557
"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
  • Administrator
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,504
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 Park, Arcen Games Founder and Lead Designer
  • Administrator
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,226
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 Park, Arcen Games Founder and Lead Designer
  • Administrator
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,226
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!