>> RU | Русский
Luck manipulation is the act of controlling how the game determines "random" results through input. It has many names, including "luck abuse", "randomness abuse", or "RNG abuse".
We should emphasize that the computer, being a deterministic machine, has no concept of randomness. All it does is follow instructions. To simulate a stream of effectively random numbers, the computer uses a pseudo-random number generator (often called random number generator and known as a RNG or PRNG). The game uses these RNG values to calculate random decisions, such as:
This is where luck-manipulation comes in. Luck manipulation is the act of controlling random decisions through input so that the results occur in your favor.

What you need to know about the RNG in the game

When does the game cycle the RNG?

In order to be of any use, the game must cycle the RNG at least once when determining random events. However, there are differing approaches to when the game cycles the RNG.

What seed value does the RNG use?

All RNGs must have a starting value, called the seed. This is what prevents the RNG from giving the same number sequence each time. It can come from a variety of sources and it is common that additional data is added on the fly to enhance randomness.

Which RNG does the game use for each action?

Games sometimes run multiple RNGs, using them for different purposes. It is important to know which RNG is used for which actions in the game.

When is the random value selected?

Let's say you are TASing Pokemon and your Pokemon, normally slower, is holding Quick Claw, so it has a 1/4 chance of going first. You try to manipulate by delaying before selecting the attack. However, no matter how many frames you delay, your Pokemon will never go first. What went wrong?
It is very important to find out when the game has decided the random action. Otherwise, you might be wasting rerecords trying to manipulate something that has been determined not to work.
In the case above, Quick Claw activation was decided before the menu appeared for your current turn. Since Quick Claw was already determined not to work, your Pokemon will always go second.
If a scenario appears where you can't manipulate an action that should be able to be manipulated, try searching backward (in the movie) until you discover when inputs can change the result.

The RNG formula

The pseudo-random number generator is just an algorithm that produces a sequence of numbers that is not easily predictable, for the purpose of the game. In general, determining the algorithm of the RNG is not easy, and finding out how the game uses these random numbers is even more difficult.
There are well-known algorithms for producing numbers such as:
There are some popular RNG formulas, but games on older systems tend to implement their own. On the flip side, modern games tend to use the runtime library provided one.
Common RNGs share a property with standard cryptographic code: certain key numbers tend to be used in many different implementations. A simple search in the code for the key number can reveal a common RNG implementation.
Less secure RNGs are often reversible, there is a formula to produce numbers in the exact opposite order. This is of limited use due to savestates, but the possibility exists none the less.

Linear congruential generators

The name of these kinds of functions is just a description in technical jargon of the steps involved. But it's very simple, so here's a full explanation:
That's it. X[n + 1] := (a*X[n] + c) % m.
The forum post "Finding and predicting RNG in practice (how to)" gives a detailed example of finding the address of a game's RNG, finding and disassembling the RNG function, and identifying the constants a, c, and m.
There's a mathematical quirk about LCGs with modulus parameters which are powers of 2 (which is common because it has near-zero computation cost, it's just a truncation) that can help you quickly identify when one is used: the generated numbers alternate odd and even. However, if the game devs noticed this, or they copied an implementation meant for cryptographic use, then they'd only use the most-significant bits outside the generator. (Further reading on English Wikipedia)

Tables and precomputation

Some random number generators do not use a formula at all. Instead they have a table of prepared random numbers that they read from in order. The seed in this case is where in the table the generator begins reading.
Higher end random number generators may use amortized algorithms. This means that they do some operations to generate data for future numbers in bulk and then hand out the pregenerated data until it runs out. For example, the RNG may be reseeded once every million times it is invoked using expensive to collect data.

Fake RNG

Games sometimes exhibit behavior that seems random, but is not tied to the RNG. Instead the behavior is tied to something that is close enough to randomness, such as the exact tick of the global game timer or the exact position of an entity.

Luck manipulation

How to manipulate the seed

Chances are, you can affect random decisions through input.
The GIF of Darkwing Duck on the right shows how delaying a frame each time causes a different drop.

AI

In games where decision-making is involved, the game will often have a decision-making process for the computer players, colloquially called "AI". You are limited by what the AI can do.
Say the AI can make a good move, and you want it to make some other move. If making that good move is the only result of the AI's decision, there is nothing you can do about it. The only thing you can do is to try to arrange a scenario where the AI is not in a position to make that move or regard it as a good move.
This also applies to flawed AI decisions that regard bad moves (to human players) as good moves. The only factor is the AI's insistence on making that move.

Other issues

Especially in games where enemy behavior is to be manipulated, check to make sure that the circumstance allows manipulation.
Remember that you can only bend a game as far as its game mechanics will allow. Some games use a damage mechanic, with some form of randomness. You can't do more damage than the maximum possible value calculated by the mechanic, even if randomness goes your way.

Rarity

While not technically a problem, rarity (usually on the order of 1/1000 or worse) of an event, or a sequence of events, can be perceived as one due to the non-occurrence of the event in any reasonable amount of time. There are ways to deal with it:

Tips for luck manipulation

Subdivision of a sequence of events

Suppose that you want to manipulate three events, each of which occur shortly after the other. Each event has 1/16 chance of occurring, so the total probability is (1/16)^3, or 1/4096, which isn't very high.
However, if it is possible to insert meaningful input (such as delays) between these events, then instead of one manipulation for three events, it becomes three manipulations, each for one event. This is much easier to manipulate because each event has probability 1/16.
It is much easier to manipulate many outcomes, if there is a high degree for which controllable input can manipulate these outcomes one block at a time.

RNG memory address, and monitoring

Wouldn't it help to know which actions cycle the RNG?
This is where monitoring the RNG in memory is useful. By observing when it changes and how, one can figure out if some action can be used to help manipulation.
For example, suppose the RNG in memory tends not to change, but changes whenever you shoot a particular weapon. Then you know that shooting this weapon is useful for luck manipulation. Furthermore, you witness some enemy behaviors changing the RNG as well. You know then that this behavior can be manipulated.
Even if the RNG always changes, sometimes some action causes it to change more than usual. This usually means that this action is useful for manipulation.
You need to find the RNG in memory first. See MemorySearch for details. Then watch it in memory.

Examples

One of the prime examples of luck manipulation is the Dragon Warrior movie. The player abuses luck in his movie of this game in different ways.

More reading


LuckManipulation last edited by Samsara on 8/7/2023 3:21 AM
Page History Latest diff List referrers View Source