Difference between revisions of "Random Number Generators"
From SDA Knowledge Base
(Created the page mostly as a placeholder; more information and examples to come.) |
(→Random Number Generators) |
||
Line 13: | Line 13: | ||
While these are the main types of RNGs, they are not necessarily distinct from each other. For example, consider the RNG system used in Super Punch-Out, which relies on user inputs to seed a per-frame RNG. Suikoden II advances its RNG only when called for some periods of time before shifting to a per-frame version after timed "grace periods" have elapsed. Figuring out what type of RNG your game uses can be somewhat tricky, and a short guide is available in the [[Reverse Engineering]] section. | While these are the main types of RNGs, they are not necessarily distinct from each other. For example, consider the RNG system used in Super Punch-Out, which relies on user inputs to seed a per-frame RNG. Suikoden II advances its RNG only when called for some periods of time before shifting to a per-frame version after timed "grace periods" have elapsed. Figuring out what type of RNG your game uses can be somewhat tricky, and a short guide is available in the [[Reverse Engineering]] section. | ||
+ | |||
+ | ===Exploiting Random Number Generators=== | ||
+ | |||
+ | Since game RNGs are part of deterministic systems, it is possible to force the same events to occur by performing the exact same actions. What it means for actions to be "exactly the same" varies from game to game, but in a tool-assisted environment it is easy to manipulate and predict subsequent RNG values. It is not nearly as simple to do in real-time, but is still possible in a number of cases. | ||
+ | |||
+ | It is important to note that manipulating the RNG does not necessarily mean always getting the correct outcome. There are a number of cases where just understanding the RNG can better inform your decisions about which actions are most likely to succeed. Even if you can't guarantee 100% success rate, being able to improve a 5% chance to a 25% chance is a huge boon to sanity for many runners. Even a tendency of an RNG to produce certain outcomes 1% more often is valuable knowledge for routing. | ||
+ | |||
+ | First, consider the category of RNG that is present in a given game. Per-frame RNGs are typically not manipulable in real-time unless you can be sure it resets to a certain value after certain events or can adequately buffer all required actions. Per-call RNGs are much easier to work with, but determining or forcing a good starting seed value is not trivial. This is also true of event-driven systems, where the player can control when or how to perform certain events to get a favorable outcome. Input-driven RNGs are slightly less difficult to manipulate than per-frame RNGs, but can still be challenging or impossible in real-time. | ||
+ | |||
+ | Second, figure out if there are any nuances to how the RNG operates. Does it change during any other actions? Does it reset between stages? What happens on a death or a game over? How about a reset? Is it ever overwritten? This step just aims to figure out the range of options you have in trying to manipulate it. | ||
+ | |||
+ | Finally, determine what is actually used from the RNG value for your event of interest. In many cases the full value from the RNG is not needed; it will only take a small sample of the bits and use those to determine an action. Every game and event may deal with this differently though. The best way to determine this is to dig into the assembly code and determine the exact conditions for certain events, but this requires some special knowledge and skills. Alternatively, one could simply observe the RNG values and draw conclusions based on patterns of the bits and observed outcome. This is not advised for events that have many possible outcomes however (such as item drops in an RPG). As a rule of thumb, count the number of possible outcomes and then look for patterns in the square root of that number of bits, rounding up. Thus, 4 outcomes would be based on 2 bits, 6 would be 3 bits, and 20 would be 5 bits. | ||
+ | |||
+ | ==Examples== | ||
+ | Coming soon. | ||
+ | ===Hagane=== | ||
+ | ===Robotrek=== | ||
+ | ===Super Punch-Out!!=== |
Revision as of 12:59, 23 July 2013
Contents
Random Number Generators
A Random Number Generator (RNG) is a system which produces seemingly random values based on an initial sequence and other sources of entropy. It is important to note that RNGs in games are not "truly" random; the same sequence of inputs and conditions will always produce the same results (and thus these constructs are technically Pseudo-Random Number Generators, or PRNGs). This means that in some cases a game's RNG can be manipulated to produce favorable results. The TASVideos page discusses RNGs in more detail, but this page is meant to discuss real-time strategies for manipulating RNGs to produce favorable outcomes.
Categories of Random Number Generators
Different games will require varying amounts of randomness and with different frequency. For example, consider a platformer such as Donkey Kong Country and a dungeon crawler such as Swords & Serpants. There might be very little randomness in DKC since most enemies move in fixed patterns, but nearly every action in Swords & Serpants has some element of randomness to it. Different RNG systems take different information as inputs as well. In general, game RNGs can be boiled down to a few types of categories. These categories have been adapted from the listing on TASVideos.
- Per-frame RNGs. This type changes every frame regardless of the actions taking place in the game. Events that require the RNG will use whatever value is available when they need it.
- Per-call RNGs. This type of RNG changes its value ("state") only when it is called for an event. This type of RNG is common in RPGs where significant randomness is needed only when deciding actions and in calculations for damage etc.
- Input-driven RNGs. This type collects entropy from player inputs to use as either the seeds or direct values for the RNG. This is uncommon, but can be used in games which expect input-heavy actions to drive the gameplay.
- Event-driven RNGs. Similar to input driven and per-call RNGs, event-driven RNGs advance on certain required actions in the gameplay even if the action has no randomness component to it. For example, some RPGs might advance the RNG each time a step is taken, regardless of whether or not the player is susceptible to random encounters.
While these are the main types of RNGs, they are not necessarily distinct from each other. For example, consider the RNG system used in Super Punch-Out, which relies on user inputs to seed a per-frame RNG. Suikoden II advances its RNG only when called for some periods of time before shifting to a per-frame version after timed "grace periods" have elapsed. Figuring out what type of RNG your game uses can be somewhat tricky, and a short guide is available in the Reverse Engineering section.
Exploiting Random Number Generators
Since game RNGs are part of deterministic systems, it is possible to force the same events to occur by performing the exact same actions. What it means for actions to be "exactly the same" varies from game to game, but in a tool-assisted environment it is easy to manipulate and predict subsequent RNG values. It is not nearly as simple to do in real-time, but is still possible in a number of cases.
It is important to note that manipulating the RNG does not necessarily mean always getting the correct outcome. There are a number of cases where just understanding the RNG can better inform your decisions about which actions are most likely to succeed. Even if you can't guarantee 100% success rate, being able to improve a 5% chance to a 25% chance is a huge boon to sanity for many runners. Even a tendency of an RNG to produce certain outcomes 1% more often is valuable knowledge for routing.
First, consider the category of RNG that is present in a given game. Per-frame RNGs are typically not manipulable in real-time unless you can be sure it resets to a certain value after certain events or can adequately buffer all required actions. Per-call RNGs are much easier to work with, but determining or forcing a good starting seed value is not trivial. This is also true of event-driven systems, where the player can control when or how to perform certain events to get a favorable outcome. Input-driven RNGs are slightly less difficult to manipulate than per-frame RNGs, but can still be challenging or impossible in real-time.
Second, figure out if there are any nuances to how the RNG operates. Does it change during any other actions? Does it reset between stages? What happens on a death or a game over? How about a reset? Is it ever overwritten? This step just aims to figure out the range of options you have in trying to manipulate it.
Finally, determine what is actually used from the RNG value for your event of interest. In many cases the full value from the RNG is not needed; it will only take a small sample of the bits and use those to determine an action. Every game and event may deal with this differently though. The best way to determine this is to dig into the assembly code and determine the exact conditions for certain events, but this requires some special knowledge and skills. Alternatively, one could simply observe the RNG values and draw conclusions based on patterns of the bits and observed outcome. This is not advised for events that have many possible outcomes however (such as item drops in an RPG). As a rule of thumb, count the number of possible outcomes and then look for patterns in the square root of that number of bits, rounding up. Thus, 4 outcomes would be based on 2 bits, 6 would be 3 bits, and 20 would be 5 bits.
Examples
Coming soon.