• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Serena, Kris, Dawn, Red - which Pokémon protagonist is your favorite? Let us know by voting in our grand final favorite protagonist poll!
  • PokéCommunity supports the Stop Killing Games movement. If you're a resident of the UK or EU, consider signing one of the petitions to stop publishers from destroying games. Click here for more information!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Pokeemerald] Better RNG (for Emerald this time)

  • 4
    Posts
    2
    Years
    • Seen Jun 20, 2025
    This is a patch that replaces the random number generator used in Emerald with a newer random number generator with higher quality output. The random number generator used is called SFC32.
    Care has been taken to ensure that link compatibility, with some minor exceptions, has been maintained with the original game.

    Getting started
    If you just want to replace the original random number generator, all you need to do is this:
    Code:
    git remote add tertu-m https://github.com/tertu-m/pokeemerald
    git pull tertu-m random
    make clean
    make

    I have tested this with vanilla and the RHH expansion.

    Why do this?
    • Seeding fixes are included.
    • The RNG is more fair. For example, every personality value/IV combination is theoretically possible for wild Pokemon now.
    • RNG prediction is harder, and existing tools (such as frame lists) don't work because they assume the vanilla game's random number generator is being used.

    Why not just use the Mersenne Twister like the DS games do?
    • The Mersenne Twister's state is about 2KB. On a machine with as little RAM as the GBA, that's a lot of RAM to burn on one thing. SFC32's state is 16 bytes.
    • Every 628th output from the Mersenne Twister takes way longer because the internal shift register has to be updated. Each SFC32 update takes the same amount of time, which is pretty similar to how long the fast Mersenne Twister updates take.
    • The output of the Mersenne Twister tests worse statistically than SFC32.

    What doesn't work?
    • Link battle recording has been disabled. This patch just tells other copies of Emerald that battle recording isn't allowed, which seems to work fine.

    What's next?
    There are many other functions added in this patch that are not used for better compatibility with other feature branches. If used, these can increase the clarity and performance of your code. They are listed at https://github.com/tertu-m/pokeemerald/blob/random/random.md.
     
    Last edited:
    Back
    Top