User Tag List

Results 1 to 5 of 5

Thread: Possible bug with random number generator

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    MJK's Avatar
    Join Date
    Jun 2006
    Location
    Espoo, Finland
    Posts
    1,162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Possible bug with random number generator

    I use the "generate a random number"-function in MMF2 Std Build R242 and I couldn't get it to work with high numbers.

    When I do this:

    Always
    - set counter to Random(1000000)

    The counter will get values only up to 17000 or so for some reason (the counter has a max value of 999999999). If I make it Random(100000), it will get closer to approximately 34000. Everything up to 65535 works perfectly, but higher numbers don't.

    [confused]

  2. #2
    No Products Registered

    Join Date
    Nov 2006
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Possible bug with random number generator

    I don't know if this helps, but 65535 is the maximum internal volume for your computer. Like, if you were adjusting your volume from within MMF with the Volume Object, the max volume you can set it to is 65535.

    Again, I don't know if this helps, but it would seem that this may have some significance, even if it simply means the people who made MMF made it so the Random command only goes to 65535 and max volume to 65535: Who knows? It might be as simple as that. [grin]

  3. #3
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jun 2006
    Location
    England
    Posts
    3,537
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)

    Re: Possible bug with random number generator

    Ah yes, I can confirm this bug.

    65535 is nothing special to do with volume. It is a power of 2 (if you think 0-based) and that is why it is important (as bits have 2 states, on and off).

    One possible workaround might be to set the counter to random(65535)+random(65535)+random(65535) or something similar.
    .:::.Joshtek.:::.

  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: Possible bug with random number generator

    Quote Originally Posted by Joshtek
    Ah yes, I can confirm this bug.

    65535 is nothing special to do with volume. It is a power of 2 (if you think 0-based) and that is why it is important (as bits have 2 states, on and off).

    One possible workaround might be to set the counter to random(65535)+random(65535)+random(65535) or something similar.
    random(65536)*65536 + random(65536) I'd think. Remembering that random(65536) will give numbers up to 65535, this would give you a random number in the full 32-bit range of 4,294,967,295 (65535 being the highest 16-bit number). A computer can't physically represent more than that without using a "floating point" number and losing accuracy. If a number is large enough in floating point then adding 1 to it won't change the value because it will make too small a change, which causes havoc.

    Unfortunately putting two random()s back-to-back like that dramatically reduces the randomness of the result, because the first random giving one value will normally make the second random give another specific value. That would mean that not all of the 4 thousand million values would actually be possible...
    You'd need to use two separately seeded 16-bit random number generators to make this properly random again. (Or just use a 32-bit random number generator)

    This post may have been over-detailed.

  5. #5
    Clickteam Clickteam

    Join Date
    Jun 2006
    Location
    France
    Posts
    13,858
    Mentioned
    262 Post(s)
    Tagged
    3 Thread(s)

    Re: Possible bug with random number generator

    I confirm (it's also explained in the documentation) that the maximum value for the parameter of the random function is 65535.

    I think the MT Random object created by FireMonkey (in the extension pack #1) allows you to generate higher random numbers.

    Yves.

Similar Threads

  1. Getting a random number between a negative and positive number
    By D_Light in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 9th January 2013, 11:51 PM
  2. A Random Number Generator from a Pool
    By robsterdobster in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 19th February 2012, 10:13 PM
  3. Random Number generator
    By RoachLIVEinLA in forum The Games Factory 2 - Technical Support
    Replies: 5
    Last Post: 22nd July 2009, 03:16 PM
  4. Random Map Generator?
    By dragonguy in forum Multimedia Fusion 2 - Technical Support
    Replies: 37
    Last Post: 6th July 2008, 03:58 PM
  5. Random Number Generator
    By bkfitww in forum Multimedia Fusion 2 - Technical Support
    Replies: 12
    Last Post: 10th December 2006, 12:30 AM

Posting Permissions

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