User Tag List

Results 1 to 6 of 6

Thread: Deterministically seeding random numbers

  1. #1
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Deterministically seeding random numbers

    I'm curious how plausible it would be to rewind the RNG through seeding or extensions to directly alter the (entropy pool?) to create a string of deterministic and intentionally repeatable random numbers.

    In my current project I have whats effectively a state-tracing machine, recording the necessary memory states and a deque of more tricky state changes and rewinding through this array as needed to return to a previous state. I would like to make it so that I can use the "Random()" function in the expression editor in a way that is deterministic as time rewinds, ie when returning to a previous state, so would the RNG seed and pool.

    From what I've seen of the in-editor MMF2 functions, theres only a means to seed the RNG, and no means to retrieve a previous seed or the current state. So that makes me wonder on two things. Is it possible to retrieve either or both of the seed & pool through the SDK? I'm not familiar with it. I could imagine an extension that could retrieve these, but I'd also need one that could directly set them, which I'm imagining is not possible.

    The other idea is, would it be possible to seed the MMF2 RNG constantly using another RNG and still get results with high entropy, or would resetting it nonstop make the results poor? For example, if I took some external RNG and seeded the MMF2 RNG with it at the beginning of each frame, recording the seed, would the actions through each frame be sufficiently entropic, or would there be patterns that arose (for example if only a single Random() function was called each frame, seeded with a random number)?

    I guess thats really a question of the reliability of the method used in the RNG in MMF2. I've noticed it isn't exactly the most secure, creating patterns in macroscopic processes before, but I'm more interested in micro processes with repeated reseeding.

    Thanks!

  2. #2
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Deterministically seeding random numbers

    Could you perhaps just record the random numbers as you generate them, and then when you rewind you can re-use the same numbers without actually rewinding the RNG?

    I don't know what MMF's RNG is, but generally the internal state of an RNG is larger than the output number size, to allow output to be repeated. If MMF still uses an RNG from "back in the day" it's probably 32-bit internal state (generating only 16-bit random numbers), which is easily storable. On the other hand, the popular "Mersenne Twister" has a 20kB internal state, which is somewhat impractical to store.

  3. #3
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Deterministically seeding random numbers

    Yeah I have so many uses of "Random()" in my code I'd prefer to not rewrite it all with a new function to be able to plug in stored values :S It could take ages. Im guessing the best approach is to just keep reseeding the MMF2 RNG, using something like the Mersenne Twister to seed it and record those, I'm just concerned about low entropy in the results if I keep reseeding it based on whatever algorithm the default RNG uses. Yeah if I could record the 32 bit state directly that would be excellent, but maybe that would even be a bit excessive if I could just seed it constantly and still get good quality results.

    Btw, any clue on what sort of input the seed works on in the default? Should I ensure its less then 2^16 (ie modding it), or is that implicit? I know that if I simply seeded the MMF2 RNG by consecutive values of "1,2,3,4..." the result will be alternating high/low values (random(300) = 143,54,145,51,etc). So what sort of random number should I be plugging into it? :S

    thanks!

  4. #4
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Deterministically seeding random numbers

    Time is a good one.

  5. #5
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Deterministically seeding random numbers

    Oh yeah I just mean on what range for the seed :S

  6. #6
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Deterministically seeding random numbers

    well uh, testing with using the mersenne twister to seed it, and seeding the mersenne twister with just date/time (maybe I'll throw in some sort of player feedback to seed it better but this isn't exactly needing to be cryptographically secure) definitely showed that seeding the randomizer with a [0,65535] value made it quite appropriately random applied once per callback or just once per frame. It also demonstrated how woefully bad the built in RNG is- my trials designed to produce static interference like on a TV created non-moving images because it used a power of 2 -.-

    So I guess I'll just seed it with a 2^16 from the mersenne, and that should be even more entropic than what it was before.

Similar Threads

  1. Random Numbers and expiring the result numbers.
    By Corlen in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 26th April 2013, 04:11 PM
  2. Random numbers?
    By infinitum3d in forum The Games Factory 2 - Technical Support
    Replies: 3
    Last Post: 21st March 2012, 04:07 PM
  3. random numbers
    By nick_Peoples in forum The Games Factory 2 - Technical Support
    Replies: 12
    Last Post: 10th February 2010, 12:51 AM
  4. Random Numbers Greater then Random Numbers...
    By Hordolur in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 15th April 2009, 06:24 AM
  5. random numbers
    By delusan in forum The Games Factory 2 - Technical Support
    Replies: 4
    Last Post: 24th March 2007, 05:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •