Sponsored By

PRNGs and Controlling Fate in Video Games

Randomness is an important aspect of games, but is often only understood at a surface level by players and designers. This article delves into the details of the properties of Pseudo Random Number Generators and how game designers can make use of them.

JohnLee Cooper, Blogger

December 13, 2018

17 Min Read
Game Developer logo in a gray background | Game Developer

Is Luck A Skill?

Just to quickly explain that video, and why it was worth starting with: That was a competitive match of Super Smash Brothers Melee, and Peach has a 1.7% chance of pulling a super strong turnip with one of her moves, and it’s very rare and very useful. So in this clip, the player does it twice in a row, with a taunt in between, and the crowd and commentators go nuts, because that’s unprecedentedly lucky. But my favorite thing about this clip is that Armada, the peach player, was interviewed afterwards about this moment and he says that he “Just knew.” There’s not really any way he could have known, right? That’s sort of the point of randomness, that it’s unpredictable and uncontrollable. So why is the way we talk about luck so active, or participatory? How do we end up with things like “the gambler’s fallacy” and good luck charms? How can people claim to be skilled at luck? There’s this compelling narrative of certain people being able to control fate, to be in total control over there life, but that’s not really possible, right?

Well, there’s this guy named Dominic LoRiggio, who calls himself “The Dominator”, and he consistently wins at craps (dice throwing). Above is an hour long BBC Documentary about him. You really only need to watch 30 seconds or so to get the idea. It’s not the most high end documentary, the video quality is bad and the dramatic reenactments are hilariously dramatic. He goes to a shady seminar and gets recruited to some sort of dice gang, they really play up the “fighting fate” narrative. The gist is that because craps relies on the laws of physics as it’s source of randomness, it can be controlled through careful throwing, and it isn’t technically cheating.

Now, it’s very possible that the controlled throwing seminar is a complete scam, none of the sources I’ve found are really sure, but it's an enticing thought. Not everything we think of as random is necessarily out of our control; dice are basically the icon for chance but they’re much more deterministic than we give them credit for, once you understand the rules they follow. When something seems random but is actually derived from deterministic rules, that’s called a Pseudo Random Number Generator, and that’s the main thing I want to talk about: how they work, the history of pseudorandomness in video games, and what that means to players. My goal in all of this is to make some suggestions for how designers might be able to better tap in to the experiential potential in “Controlling Fate”, because right now the majority of the interaction people have with randomness in games is very surface level, often banal. You can increase the drop chance of loot by wearing a jester hat in Dark Souls, or type in a swear word as a seed for a Minecraft world, but there’s very little thought by the player as to what that means, what they’re actually doing. And there’s a lot more depth of control available with PRNGs.

Properties of A PRNG

 

The people who care the most about PRNGs seem to be mathematicians and cyber security people (it’s very useful for security to be able to generate numbers that are unpredictable if you aren’t in the know, but knowable if you have the key). For one that makes a lot of the writing very dense and technical, but I’ve gone through the trouble of picking out the interesting stuff for us. This article by Eric Uner points out a variety of important properties that PRNGS are derived from, and I think it’s not a huge leap to try to attach some of these useful terms to input. These are the venues that we would be able to give players control over chance through.

Seed

Seed is an obvious one, it’s the starting point from which the rest of the sequence is derived, and inputting a different seed causes a different result. A lot of games that use procedural generation have this element exposed, such as the aforementioned Minecraft. But it’s not usually as a part of the central gameplay, it’s usually in the menus, or input before the proper game begins. The relationship between the seed and the outcome is also usually obfuscated to the point where the player can make no meaningful choices when inputting a seed, it’s just used as a way of getting repeat outcomes. If you type in “lava” as your Minecraft seed, you sadly do not receive a lava world, it’s a bit unintuitive.

Formula

This brings us to the next property, the formula, which is what converts the seed into whatever it is you’re outputting: level generation, item drops, etc. This part is always there under the hood in any PRNG, but I think exposing it, making it editable or learnable, could be valuable. A game that makes it’s formula slightly more digestible is Conway’s Game of Life, which has a more visual rule set that is still deep enough to produce securely unpredictable results.

It doesn't let you change the formula at all, at least in any implementations I’ve seen, but it does expose it and help it make sense by dressing it in the analogy of over and under population. The game is also very open and encourages experimentation with little risk, which really lets players take the time to learn the rules for themselves.

Step Frequency

Step Frequency refers to how often the operation, the shuffling and dealing if it were playing cards, is repeated. This is something that gets more use in games, but usually in the form of grinding. To bring it back to the opening clip, there is one way for Peach players to get better turnips more frequently, it’s pretty simple they just have to find more opportunities to pull. Even that small, inherent amount of control has had effects on the metagame though. Players have developed a method (shown above) to most optimally farm through turnips, thereby mitigating some of the luck with skill (the method is quite technically difficult). A similar example in shooters would be critical hits, the frequency of crits would be naturally be higher on a weapon with a higher fire rate.

Distribution

Distribution is another related term, it refers to how varied the results can be. A random number generator that only gives you 4s and 1s has a lower distribution than one that gives you a number from 1–100. Project M, a competitive Super Smash Brothers Brawl mod, adds some foresight, if not total control, of the distribution of Mr. Game and Watch’s Judgement move. The move, in other games, is completely random and displays a number from 1 to 9. Project M adds a visual indicator that lets players know whether the next hammer will be even or odd, thus limiting the distribution and allowing players to make more informed decisions. Since the hammer can also not be the same as the previous 2 numbers, it’s possible to lower the odds of a getting a 9 (the strongest one) down to ⅓, and also be aware of what the other two options will be.

 

Security and The Middle Square Method

All of these properties (and there are more in the article for the curious) can be, or have been, linked to game mechanics, but as I said it’s often been very surface level. I think part of the reason for this is that modern PRNGs are often too complicated to be able to teach to players, especially when a lot of games tend to take a very long time just to get across basic movement mechanics.

Unfortunately because of the cryptographic focus of most PRNG writing, most Pseudo Random Number Generators are designed to be hard to interact with for security reasons, while as designers we would probably be aiming for a pleasant sweet spot of intuitiveness and challenge. I’ve found the closest thing to what we would want in PRNG literature comes from older formulas, which are generally pretty terrible for what the math people want.

One such method is the middle square method, by Jon Von Neumann.

It’s simple enough to be essentially a game on it’s own. You take a number as your seed, and you pick a number of digits, thats k. You square the first number, and then the middle k digits of the square is your new step. You then square that and repeat.

So here’s a puzzle, if the first number is 12345, and the 3rd number is 225625, what’s k? The answer is upside down below, like a newspaper puzzle:

xᴉs ʎʇɟᴉɟ pǝɹpunɥ uǝʌǝs puɐsnoɥʇ ɹnoɟ ʎʇɟᴉɟ = ɹǝʍsuɐ

I’ll admit it isn’t a very fun game, it’s really just math, but it serves as a hopeful example that the sweet spot we want can exist, where, given the proper understanding of the formula, something unpredictable to a layman becomes obvious to someone skilled. So how would we make this genuinely fun, something that people would actually play?

 

Historical Implementations and Speedrunners

Well, one way to find that out is to look at a particular sect of players, who’ve been finding ways to “control fate” even in games where the developers didn’t want them to be able to. Speedrunners, and to an even greater extent TASers (tool assisted speedruns, played frame by frame), are quite dedicated in their unraveling of game engines in order to beat the games as fast as possible. In certain games, usually older ones with more limited computational power, randomness was determined in strange ways, still designed to obfuscate but often tied to player input for lack of a better source of chaos. The tie to player input lets dedicated players do incredible, empowering things .

 logo in a gray background |

I think it’s kind of beautiful that that just by linking their PRNGs to player input these old games accidentally have such added richness. It’s like a hidden power in the player character that can only be brought out through determination and perseverance. That’s exactly the kind of power narrative some designers love to try to invoke and here they were doing it completely by accident. Possibly the best example of this secret power is in The Legend of Zelda Oracle of Ages / Seasons. The engine is only stepped (shuffled) during certain actions in game: screen transitions, digging, sword slashes. This limited iteration allows more fine control from players but the best part is this: the pitch of the sword slash sound effect in the games is determined by the PRNG, and as such acts as useful feedback (essentially the inverse of Security) for players. Specific series of sounds allow players to confirm their setups and locate themselves in the generator. These factors allow this RNG manipulation to be viable for real time play, while in other games where it’s less accessible it can be too difficult to perform. And if it’s possible for developers to make RNG manipulation playable by accident, I’m fairly confident we can make it better than playable, fun even, if we actually do it deliberately, taking into account all these factors.

So to reiterate, for luck manipulation to become a useful game mechanic, it needs to be tied to player input in some way, and it needs feedback so players can understand the system. It needs to be simplified compared to cybersecurity PRNGs, so that the relationship (formula) between seed and outcome can be understood. Maybe it would be good to let players tamper directly with the formulas, allowing room for creativity. We’ve also learned a variety of ways in which someone could interact with a PRNG, and each can result in different feelings of interaction. Controlling step frequency might be farming for a higher frequency or dodging triggers in order to avoid shuffling. Controlling range might look like wearing certain charms to invoke certain behaviours in NPCs or the weather.

The requirements for players being able to conquer these systems can be varied as well. It can be execution difficulty, like “The Dominator” and his controlled throws. Maybe it’s just a knowledge gate: learning the value of K. Or maybe it’s about learning a system through experimentation, like figuring out what shapes in Conway’s Game Of Life are stable.

 

Hypothetical Design

So what would a game look like that takes all these things into consideration? Let’s design, hypothetically, a game centered around the mechanic of manipulating chance. Firstly, we need to select a what kind of seed we want, and what formula we want to apply to it. In order to help players understand and manipulate the formula easily I want to make it something very visual and tangible.

Taking inspiration again from Game of Life, let’s have the seed be a small grid of pushable blocks that represent different elements in the game. The blocks can be connected to characters in a game world (let’s say it’s blocks with faces) and their coordinates in the push-block grid can correspond to the locations of the characters on the larger map. So you essentially get to place players in different locations and then go out into the world and find them there. Characters could react differently in different areas or when adjacent to other characters. This relationship is nice and intuitive, but it’s probably too controllable right now to be considered random.

This is where we need the formula, some operation to conduct on the blocks at set intervals to make the arrangement change in complicated ways. The formula could be movement patterns that each block has, denoted by arrows on the block: one character might move left and down alternatingly, or one might circle clockwise. Players could try to set the initial positions such that these moving blocks collide with each other several steps later to be in the positions the player needs.

Step Frequency then comes into play. How often do the blocks move, and how often can the player reset them? Let’s say that the game runs on a day night cycle, with blocks moving every hour on the hour. The player can only reset the positions at midnight. Tying step frequency to time makes sense aesthetically, but as we’ve learned it might be interesting to tie the progress of time to the player’s input, via their progress through the map. If the map is split into individual screens like Zelda 1, time could pass an hour every time the player changes screens. Thanks to the visual feedback of a UI clock updating or the light changing it becomes less of an arbitrary connection as it was in the Oracle games.

The skill being tested with this would be of the ‘understanding the system variety’. New players presented with the grid likely won’t understand it and will get a slew of unpredictable and unfavorable placements of characters throughout the day. They can continue shuffling the blocks about randomly each day and seeing what they get, and observant players could hopefully start making deliberate choices and planning more and more steps ahead to get more and more specific outcomes.

Of course this is a very rough outline of a game idea, and a lot of the success of it would depend on the execution and clarity of the feedback, and the complexity of interactions between characters and locations. But hopefully you get the idea, that if you design with these properties in mind you can arrive at some strange, unique ways of interacting with a game that can still be approachable and fit in with standard game tropes.

General Application

Obviously not every game can afford to be about luck manipulation, they don’t need to be. But these concepts can be applied with more subtlety to preexisting genres and formats to easily add richness to current systems.

Take the loot drop rates of an RPG, Dark Souls for example. Dark Souls’ only way of interacting with its luck engine is being able to slightly increase the overall chance of drops. Dark Souls loves to obfuscate it’s mechanics and I wouldn’t want to take away from that by completely opening the hood on the underlying randomness. But you could add some subtle depth by allowing some more specific control over the range (Distribution) of drops; Players already wearing parts of an armour set could have raised chances to find the remaining parts, or there could be specific rings that increase the drop chances of specific categories of items (swords, healing items, ‘warm and fuzzy’ items, etc.) Players might even be completely unaware of these mechanics depending on how obvious the effects are, but it would still flavour each player’s experience differently and more deliberately than purely random variations.

I think Esports games in particular can also benefit from this school of thought, I know many already do to one degree or another. But frustration surrounding RNG mechanics in MOBAs, Shooters, Platform Fighters, etcetera is definitely still prevalent. People get frustrated by random crits, but headshots are adored because they’re skill based. Being able to reinforce every luck mechanic with skill or strategy could help mitigate these complaints and add more competitive depth to a character. If a character’s chance for crits increases gradually so long as they never stop moving, that can encourage a certain style of play and require players develop a certain skill. You could have another character have the opposite, where staying stationary is rewarded by their RNG engine.

 logo in a gray background |

Conclusion

I think a better working understanding of randomness and the potential therein for emergent stories and deep, compelling gameplay is useful for any designer. It lets both designers and players have more control over certain aspects of play and can mitigate feelings of unfairness or non-interactivity. And I think it’s worth our time to play with this more, collectively. Maybe it could spur a new genre, or subgenre, with wholly different skills and knowledge bases to most games currently available, kind of like the many randomized games that emerged following Rogue. All it would take is one shining, trendsetting example. In real life, it might not be possible to “Control Fate” but when you’re designing a game you get to decide what we can control, and why not explore that fantasy?

 

Citation

Blayd92. YouTube, YouTube, 6 Apr. 2013, www.youtube.com/watch?v=4GXb2Da1Rak.

Hull, T E, and A R Dobell. “Random Number Generators.” Source For Industrial and Applied Mathematics, epubs-siam-org.library.sheridanc.on.ca/doi/10.1137/1004061.

Kendall, Graham. “How to Cheat at Dice — from an Expert in Games.” The Conversation, The Conversation, 8 Nov. 2018, theconversation.com/how-to-cheat-at-dice-from-an-expert-in-games-96320.

“Luck Manipulation.” TASVideos, tasvideos.org/LuckManipulation.html.

Machicao, Marina Jaeneth, et al. “Chaotic Encryption Method Based on Life-Like Cellular Automata.” Https://Arxiv.org/Pdf/1112.6326.Pdf.

Martin, Edwin. John Conway’s Game of Life, bitstorm.org/gameoflife/.

Myst, Vestboy. “Guide — Postmodern RNG Tactics (Knitting & Panning Theory Discussion).” Smashboards, smashboards.com/threads/postmodern-rng-tactics-knitting-panning-theory-discussion.414626/.

O, dragonc. YouTube, YouTube, 18 Apr. 2017, www.youtube.com/watch?v=Zp0jd2I7fPI.

“Oracle of Ages.” Zelda.SpeedRuns.com, zelda.speedruns.com/ooa/ooatt/rng-manipulation.

“Random Generators.” TASVideos, tasvideos.org/RandomGenerators.html.

Uner, Eric. “Generating Random Numbers.” Embedded, www.embedded.com/design/configurable-systems/4024972/Generating-random-numbers.

Read more about:

Featured Blogs
Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like