Jump to content

Does anyone know the RN generating formula?


Tables
 Share

Recommended Posts

To put it bluntly, I'm writing an essay for my maths degree on random number generation, and I'd like to use Fire Emblem's RNG as an example - ideally, I want to break it apart and prove that with any three consecutive values, you know the precise sequence of values of the generator (although that may be either not very mathematical, or may be beyond me to prove). However, I currently can't find the formula for the generator - I know I've seen it somewhere online, but a quick forum and google search haven't found it.

If anyone could point me in the correct direction, that would be appreciated.

Link to comment
Share on other sites

http://www.gamefaqs....ones/faqs/37253

Should be what you're looking for. http://www.gamefaqs....red-stones/faqs this is in case it's something else.

Edit: Actually this is probably what you're looking for.

http://www.gamefaqs.com/gba/921183-fire-emblem-the-sacred-stones/faqs/37685

Edited by Klokinator
Link to comment
Share on other sites

As far as I can see, none of those even contain anything remotely close to an equation for the RNG. Which isn't surprising, since there'd be no point quoting an FAQ when the equation should be one line long.

All I know about the equation off the top of my head is that it's a linear feedback shift register.

Link to comment
Share on other sites

In the GBA era, there isn't a generator. There's a set order for the RNG, which is why certain prologue hits/misses/criticals happen the same way so often. The variation comes from how you move the units and certain menu selections, I think, as well as of course doing different things.

Link to comment
Share on other sites

Hm, I don't really know if it'd be considered a formula or not, but I dug up an old programming practice I did that writes a random number generator. The order of the rn string generated is always the same though.

Here's a screen from my code: http://gyazo.com/6f9723e5f04646f9d3fcc076cca85116

So I would imagine FE's would be something similar except more complicated.

Edited by Luminescent Blade
Link to comment
Share on other sites

In the GBA era, there isn't a generator.

Yes, there is. You yourself are calling it an RNG; what do you think the G stands for?

There's a set order for the RNG

That's how RNGs work. The reason you get consistent behaviour is that the RNG is seeded with the same value each time you reset. The rest of the sequence is still generated, though. It's not stored somewhere. It's determined, one number at a time, as they're needed, with math.

Based on a combination of what I can figure out from Hex's documentation, and playing around with the VBA disassembler, the routine in question starts at xBDC in the ROM and goes all the way to xCA6 (i.e. about a hundred opcodes long). Good luck sorting through it :) The actual RNG state is held in ROM at 0x3000000, i.e. the very beginning of IRAM. 6 bytes are used, with a seed of 71 36 EA 90 96 14. AFAIK the code is identical for all three GBA FEs.

Edited by zahlman
Link to comment
Share on other sites

Hm. There's certainly a generator, and as I said I believe it's a linear feedback shift register, but I don't know the details.

Ah well, to be honest it would have just been a cute example, so it's not that important to me. I can easily talk about things like... the Mersenne Twister (for suitable definitions of 'easily')

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...