Fundamentals 6 min read

Understanding Random Number Generation and the Linear Congruential Method for Game Gacha Systems

This article explains how linear congruential generators produce pseudo‑random numbers, demonstrates their use with step‑by‑step examples, visualizes the distribution of generated values, and applies the method to design a simple gacha system while discussing its statistical properties and practical limitations.

NetEase LeiHuo UX Big Data Technology
NetEase LeiHuo UX Big Data Technology
NetEase LeiHuo UX Big Data Technology
Understanding Random Number Generation and the Linear Congruential Method for Game Gacha Systems

Many games use a 5% chance to obtain an SSR item, but how is this probability actually implemented? The article starts from basic number‑theory concepts and shows how to manually generate pseudo‑random numbers using simple modular arithmetic, requiring only elementary school math.

1. Remainder properties – By choosing three numbers A=4, B=7, M=9 and a seed X₀=3, the formula (A * X + B) mod M produces a sequence of remainders that eventually contains every integer from 0 to 8 exactly once, illustrating that remainders can behave like random values.

2. Generating 0‑1 random numbers – Scaling up the parameters to A=1664525, B=1013904223, M=2³² and using the same seed, the linear congruential generator (LCG) yields large integers whose division by M gives a uniform distribution in the interval [0,1). Visualizations of 1,000 and 100,000 generated values confirm the uniformity expected from the law of large numbers.

3. Building a pure‑random gacha system – Using the LCG, the article outlines a three‑step process: (1) set A, B, M and generate a fresh seed X₀ (often derived from a timestamp or player ID), (2) compute a 0‑1 random number, and (3) map the number to SSR (0‑0.05), SR (0.05‑0.15), or R (0.15‑1) based on the desired probabilities.

A simulation of 10,000 players each performing 100 draws shows the expected distribution: on average each player receives about 5.0146 SSRs, but many receive none while a few obtain many, highlighting the inherent variance of random draws.

The article concludes that while the LCG provides a simple and statistically sound method for random number generation, using a static seed makes the sequence predictable; therefore, dynamic seeds (e.g., timestamps or unique player IDs) are essential to maintain unpredictability in real‑world applications.

simulationprobabilityalgorithm fundamentalsgacha systemlinear congruential generatorRandom Number Generation
NetEase LeiHuo UX Big Data Technology
Written by

NetEase LeiHuo UX Big Data Technology

The NetEase LeiHuo UX Data Team creates practical data‑modeling solutions for gaming, offering comprehensive analysis and insights to enhance user experience and enable precise marketing for development and operations. This account shares industry trends and cutting‑edge data knowledge with students and data professionals, aiming to advance the ecosystem together with enthusiasts.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.