Site News
Warning: This wiki containsspoilers. Read at your own risk!

Social media: If you would like, please joinour Discord server, and/or follow us onX (Twitter),Bluesky, orTumblr!

Random number generator

From Fire Emblem Wiki, your source on Fire Emblem information. By fans, for fans.

Namespaces

More

  • More
"RNG" redirects here; for the stat abbreviated as "Rng", seerange.

This page has been marked as astub. Please help improve the page by adding information.

Therandom number generator (orRNG) is a system that randomly generates numbers. Randomness is present in almost every game in theFire Emblem series, primarily in the results of combat. As with most computer systems, random numbers inFire Emblem are not truly random butpseudorandom—they simulate randomness with a deterministic series of numbers. When and how random numbers are generated changes from game to game.

Events that use random numbers include:

  • Attacking or being attacked
  • Leveling up
  • Creating a unit with randomly leveled-up stats
  • Creating one of several possible "diagonal" paths

Generation

In the first three games, random numbers are "burned", and change each frame; while in later games they only change once they are used. In most cases, only a single random number is used to determine the outcome of a random event. However, in games that usetrue hitThe Binding Blade being the first of which—two random numbers are used and averaged to determine whether an attack hits.

Shadow Dragon & the Blade of Light,Gaiden, andMystery of the Emblem

Random numbers are saved as an eight-bit integer (ranging 0–255) that increments by 55 each time it is used, including when it is burned.[1] InFire Emblem: Shadow Dragon & the Blade of Light, the eight-bit integer is multiplied by 10 and divided by 25, then truncated—this allows for numbers ranging from 0–102, but all numbers above 100 are reduced to it; inGaiden andMystery of the Emblem, the integer is multiplied by 100 and divided by 256, then truncated, allowing for a range of 0–99.[1]

Thracia 776

Random numbers are stored as eight-bit integers (ranging 0–99). In many occasions like at the start of a chapter or when closing a unit stats screen, the game will generate a new sequence of random numbers using theKnuth's substractive generator. The 55 first numbers are generated with an initial seed equal to a RAM value increasing by 1 every frame, looping from 1 to 64, and the following values are generated with the formula:

RN[N] = (RN[N-55] - RN[N-24]) modulo 100

One consequence of these rules is that there are only 64 different sets of stats for units generated at the start of a chapter. Also, the randomness is not perfect and some of the numbers can be predicted, for example the 35th random number will always be equal to 94 regardless of the seed.[clarification needed]

For the purpose of random events calculations, random numbers 0 are treated as 100.

The Binding Blade,The Blazing Blade,The Sacred Stones, andPath of Radiance

Random numbers are stored as sixteen-bit integers (ranging 0–65535). The three initial random numbers are generated at startup, and are always the same for the GBA games. ForPath of Radiance, based on the GameCube internal clock, the three initial random number are chosen between 7 different sets of 3 numbers, and up to around 30 extra numbers can be burned after that.[clarification needed]

The following random numbers are generated with the bitwise operation:

RN[N] = ((RN[N-1] >> 5) XOR (RN[N-2] << 11) XOR (RN[N-3] << 1) XOR (RN[N-2] >> 15)) modulo 65536

For the purpose of random events calculations like battles or leveling up, these numbers are divided and truncated. InThe Binding Blade, the integer is divided by 655, allowing for numbers 0–100; in the other games, the integer is multiplied by 100 and divided by 65536, allowing for numbers 0–99.[2]

This oversight inThe Binding Blade means that it is possible to miss 100% accurate attacks.[3]

New Mystery of the Emblem

Random numbers are stored as sixteen-bit integers (ranging 0–65535). The four initial random numbers are generated at startup with two Mersenne Twister algorithms in a row, with the first seed based on the DS internal clock.[4]

The following random numbers are generated with the bitwise operation:

RN[N] = ((RN[N-4]) XOR (RN[N-4] >> 8) XOR (RN[N-4] << 3) XOR (RN[N-4] << 11) XOR (RN[N-1]) XOR (RN[N-4] >> 19)) modulo 65536

Like the previous games, the integer is multiplied by 100 and divided by 65536, allowing for numbers 0–99.

Attacking or being attacked

Depending on whether the game uses true hit or not, either one or two random numbers are expended to determine whether an attack hits or misses. If the attack hits, another random number is spent to determine whether the attack is critical or not. Certain games expend additional random numbers for additional effects. InThe Blazing Blade andThe Sacred Stones, for example, there is a probability for anAssassin's critical hit to activateSilencer, and so an additional random number is spent if an attack is critical in those games, even if the attacker is not an Assassin.

Leveling up

Main article:Growth rate

When a unitlevels up, random numbers are used to determine whether each stat increases or not. The odds of a stat increase for a specific unit are determined by the unit's personal growth rates, and—when applicable—theirclass. Some games also provideitems andskills that boost a unit's growth rates, such as theStarsphere inFire Emblem: Mystery of the Emblem or theAptitude skill.

In the GBA games, each level-up uses seven RNs to determine whether or not HP, strength/magic, skill, speed, defense, resistance, and luck increase, in that order.

Additionally, inThracia 776, enemy stats are treated as though they had leveled up, and can therefore vary between playthroughs and resets. As a side effect of the way RNs are generated, every enemy present at the start of a chapter will only have 64 possible stat layouts. The GBA games also have enemy stats based on their growths with added randomness, though they are calculated in a manner that results in far less variance than inThracia.

Some games have mechanics to prevent a level-up from not increasing any stats and therefore limiting randomness:

  • InThe Binding Blade,The Blazing Blade, andThe Sacred Stones, if a level-up would not increase any stat, the level-up will be re-rolled up to two times. If a level-up would increase an already capped stat, it is considered a stat increase and will not be re-rolled. If both re-rolls fail to increase a stat, the level-up will not grant any stat increases.
  • InFire Emblem: Radiant Dawn, level-ups always increase at least one stat unless the unit in question already has all of their stats capped. If all of a unit's growth rates are modified to be 0% through hacking, the game will force a stat increase inHP. Additionally, level-ups throughbonus experience always increase exactly three stats unless the unit has less than three un-capped stats.
  • InFire Emblem: Shadow Dragon, a unit's odds of increasing a stat through level-ups increases after it fails to increase on a level-up.
  • InFire Emblem Echoes: Shadows of Valentia, blank level-ups are forced to increase HP. However, if the HP cap of 52 is reached, blank level-ups are possible.
  • InFire Emblem: Three Houses,Byleth,Flayn,Cyril, and all members of the four houses are guaranteed to increase at least two stats on level-up. If a level-up hits a capped stat, it is counted as a stat increase. If a level-up would increase only one stat, that stat will not be rerolled.

InFire Emblem Fates's Lunatic difficulty, a unit's level-ups are determined when they are first recruited, and therefore cannot be rerolled through resetting.

Fire Emblem: Path of Radiance andFire Emblem Engage have an optional, fixed mode where level-ups are not determined by randomness. In both games, Fixed Mode is unlocked after completing the game once; inEngage, Maddening difficulty defaults to Fixed Mode.

Creating a unit

Random numbers are used to determine the stats of most enemies as they spawn. This is most evident for enemies inArena battles. In the GBA games, for example, level 1 unpromoted enemies do not receive bonuses to their stat levels, but level 2 or higher enemies and promoted enemies do; thus the former do not use up as many random numbers as the latter.

Creating a path

When the game is forced to create one of several possible paths (usually by moving a unit to a point that is at a diagonal to its original position), it uses the RNG to determine which path to take. This can also be done by the player, if one controls a unit with odd-numbered movement.

In the GBA games, paths are drawn backwards from the unit's destination to its original position, and when either horizontal or vertical movement is possible, a low RN (between 0 and 49) will generate a horizontal path, while a high RN (between 50 and 100) will generate a vertical path. For example, if a the game is forced to generate a diagonal path one space up and to the right, a low RN will result in a path leading to the left from the unit's destination, then down to the unit; a high RN will result in a path leading down from the unit's destination, then left to the unit. The second of these two steps does not use an RN because there is only one possible way to create the path from that point.

Miscellaneous

InFire Emblem: Thracia 776, every time the Combat Info window is opened, the game will simulate a round of combat, burning RNs as if the units entered combat. This will also happen every time a button on the directional pad is pressed to change the target, even if there is only one possible target.

References

  1. 1.01.1 Oziphantom,Fire Emblem 1 : What is up with the RNG?, YouTube,Published: December 8, 2020,Retrieved: November 10, 2021
  2. StanH,response to Fire Emblem6 Rng Data, Fire Emblem Universe,Published: November 6, 2019,Retrieved: November 10, 2021
  3. Mekkah,FE6 Rutger miss with 100 hit, YouTube,Published: August 18, 2018,Retrieved: March 5, 2025
  4. lapogne36,FE12 TAS submission, TASVideos,Published: July 16, 2022,Retrieved: March 5, 2025
Game mechanics
Out-of-battle managementBase (BarracksBase CampBase conversationEveryone's ConditionsExpeditionGarreg Mach Monastery (Abyss) •My CastleSomniel) •Bonus experienceCalendarDungeonsGameplay modes (DifficultyCreature CampaignNew Game +) •GoldLessonsMila ShrinesPeddlerPeer trainingPreparationsRenownShopping (ArmoryBargainsForgeItem shopMerchantOnline shopSecret shop) •Supply convoyWorld map
Battles and chaptersArenaBattle saveBossCastleChapter (Alternate routeParalogueSide quest) •ChestCombat forecastEvent tilesHidden treasureObjectivesReinforcementSkirmishTerrain (Hazards) •Trial MapTurn (Turn rewind) •Weather (Fog of war) •Village
StatsUnitsActionAffinityAuthorityBiorhythmCharmClass (Class masteryClass relative powerUnit type) •Class bonusConstitution (Aid) •DefenseExperienceFollow-up critical multiplierGrowth rateHit pointHoly BloodInventoryLevelLuckMagicMoraleMovementProficiencyResistanceSkillSpeedStrengthWeapon levelWeight
WeaponsBrave weaponCritical rateDurabilityElementHitKill bonusMightPersonal weaponsRangeWeapon experienceWeapon levelWeightWorth
Unit mechanics and commandsAdjutantAttack (Counterattack) •Auto-BattleBattalion (Gambit) •CantoChain attackChain GuardClass change (Reclass) •Combat artCrestsDance (GaldrarPlaySing) •Death (Decoy) •DismountDragon VeinEmblem RingsFatigueInventoryLaguz transformationLove (JealousyInheritance) •Pair UpRallyRecruitmentRescue (Capture) •Skills (Offensive skill) •SmashStaggering BlowStatus effectsSupportTalkTradeUnit (AvatarBond unitBonus unitEinherjarLoan unitPrisonerReplacement unit) •Visit
CalculationsAttackAttack speedAvoidBonus damageCritical hit (Combination bonusDodgeTriangle Attack) •Hit rate (True hit) •Random number generatorWeapon triangle (Trinity of magic)
ConnectivityamiiboData transferDouble DuelDownloadable contentLink ArenaMultiplayer battleOnline shopSpotPassStreetPass
OtherBarrierBirthdayClass rollGlitchesMovieMultiple endingsRankingsSound RoomTactician bonus