Random Number Generator: Difference between revisions

m
Mass update links
m (Mass update links)
m (Mass update links)
Line 4:
For example, [[Role Playing Game|Role Playing Games]] will commonly use a random number generator to determine if a blow landed in combat. If so, the random number generator might then be called again to determine if it is a [[Critical Hit]] or not; then yet again to determine what percentage of the character's maximum attack power will be applied to the enemy.
 
Note that almost all computer systems are incapable of producing truly "random" numbers on their own. Some have [http://en.[wikipedia.org/wiki/Hardware_random_number_generator:Hardware random number generator|special hardware]] which can achieve this, but you'd be hard-pressed to find such hardware in a home computer. As such, the random number generator is usually producing a series of numbers based on an initial "seed" value. This "seed" is assumed to be "truly" random, and often will be the time of day (down to the microsecond) when the program started.
 
This works rather well with traditional computer systems, where the time will be different every time you start a program (making it very difficult for the user to predict the seed used, especially if a program re-picks one every time it calls the random number generator), but older video game consoles didn't ''know'' the time of day. So they had to use certain tricks.
Line 10:
One method commonly employed was to start a timer when the console powered up, then grab the current value from that as required. Another method was to modify the current random value by a number based on the controller input each frame. This would appear random to the user. However, through [[Emulation]], one can actually determine the algorithm in question by reverse-engineering and then provide controller input to get whatever random number you want. In tool-assisted speed running, this is known as "luck manipulation".
 
Some games look to other sources for a seed value. For example, the [[Game Boy Advance|GBA]] game ''[[Golden Sun (Video Game)|Golden Sun]]}'' based its [[Randomly Drops|random drops]] on the enemies you fought, how your party was equipped, the turn order throughout the battle, and so on - That is to say, if a player managed to win an item as a random drop using certain battle tactics - be it [[Vendor Trash]] or the [[Infinity+1 Sword]] - then repeating the battle against the same monsters with the same tactics would be ''guaranteed'' to give the same reward. This made the random number generator [[Game Breaker|far easier to exploit]] than one using the timer as a seed.
 
Whether a video game using a timer-based random number generator is more "random" than a real set of dice is debatable. In practise, so long as the program is using a fresh seed every time it starts, and the player doesn't know what that seed is ahead of time, there should be no way to consistently predicting the outcome of a decent-coded random number generator. If the seed ''is'' predictable, then the results of the random number generator are, too.