Spielerando

Odds and randomness

Learning paths through this topic

Scatter coins randomly on a level without piling them on top of each other

Dropping pickups at random spots gives clumps, overlaps and bare patches. Rejecting bad spots helps, until the area fills up and the search never ends. Here is a placement loop that keeps its spacing and always stops, even when the request cannot be met.

Searching ruins for hidden loot: the last spot should not be a coin toss

If every search has the same small chance of finding something, a player can search every spot and still come away with nothing, which feels like a cheat. This shows how to make searching fair, with each empty spot raising the chance that the next one pays off.

Shooting one more bullet changes what the next chest contains

With one shared random source, anything that draws a number shifts every number that comes after it. A player who reloads a save and plays slightly differently finds different loot, and a replay drifts apart. Splitting the source by purpose fixes both.

How likely does a shotgun blast kill when only some pellets hit?

Each pellet may hit or miss, and the enemy only drops if enough of them land. Designers guess this number and are then surprised by a gun that never kills or kills almost always. Here is how to get the true chance and one rounding trap that gives wrong answers.

Random pick keeps giving the same thing three times in a row

Plain random feels broken: streaks of the same enemy, the same song, the same loot. A shuffled bag fixes the streaks inside a round, but a nasty repeat can still sneak in exactly where the bag starts over. This entry covers that seam.

Let the game ease off after a hard fight instead of spawning at a flat rate

A constant stream of enemies tires players, and a stream that only reacts to kills lets them hide and farm. A small director with three moods builds pressure, holds a peak and then gives a breather. The hard part is how the peak ends when the player simply waits.

How many monsters will the area really hold once spawning and despawning settle?

Designers set a spawn rate and a despawn rate and guess the crowd size, but the area cap and the way monsters leave change the answer, and the result is often either an empty field or a packed one. This shows how to predict the crowd before you ship it.

Make a weapon get less accurate while firing and recover when you stop

Hold the trigger and the aim should loosen, let go and it should tighten again. Implementations tend to recover too soon, too late, or at a speed that changes with the frame rate. This entry gives the small state that behaves the same on every machine.

Random spawn times leave long empty stretches and then three enemies at once

Picking random times for enemies to appear gives bunches and quiet gaps that feel like bugs. A fixed rhythm is too predictable. Dividing the time up and varying only within each part keeps the unpredictability and rules out the worst bunches.

Three 30 percent dodge items must not add up to a 90 percent dodge

Players collect several items that each help them dodge. Adding the numbers makes the build untouchable, and ignoring the stack makes the items pointless. The right combination is a small formula, plus a floor and a ceiling so the game stays a game.

Make a 25 percent critical hit feel like 25 percent without long dry spells

Fixed chances produce hits in clumps and long droughts that players blame on the game. A chance that grows after each miss evens it out, but only if you pick the growth number so the long-run rate still matches what you promised.

Make enemy fire come in streaks without changing how often it hits

Real fights feel like bursts of hits and bursts of misses, while independent rolls look too even. Adding streaks is easy, but a naive version also shifts the overall hit rate, so the weapon tuned for a certain accuracy suddenly plays differently. The two numbers must be chosen together.