User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14

Thread: Generating non-repeating Random numbers?

  1. #1
    Clicker Fusion 2.5Android Export Module

    Join Date
    Jun 2014
    Location
    London, UK
    Posts
    96
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Generating non-repeating Random numbers?

    Hi,

    So I've set up a frame with a counter in it. And have 2 lines of code, which are:

    Always - Set countSelector to RRandom (1, 4)
    Every Second - Set Counter to countSelector


    Now, as you may have figured out, every second the counter is set between a number of 1 and 4.

    My question is, how can I change up this code in order to make sure the counter doesn't display the same number twice in a row?

    Thanks a lot.

    Samer.

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleUnicode Add-on

    Join Date
    Nov 2010
    Location
    Switzerland
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you don' t mind using an Extension, then You could use the "Random Pool" or the "Random Multipool"-Extension.
    It allows You to create a Pool of Numbers and then "draw" these Numbers off from the Pool. Every Number can only be used
    once (until you refill the Pool ofcourse).

    With kind regards,
    jahkri

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleUnicode Add-on

    Join Date
    Nov 2010
    Location
    Switzerland
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could also use a simple List-Object and draw the Numbers at Random from the List

  4. #4
    Clicker

    Join Date
    Jul 2011
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Attachment 13557

    Here is a random pool thing. Maybe it will help?

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Tuna's Avatar
    Join Date
    Feb 2008
    Location
    Central Texas
    Posts
    1,853
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    even in random sequences, there is a chance for repeated numbers... so if you still want to ensure the same number isn't regenerated you can create a variable called PreviousPick and use it to remember the previous number.
    CountSelector= RRandom (1, 4).
    if CountSelector<> PreviousPick then PreviousPick = CountSelector

    or you could just check the counter... if counter <> countSelector then counter = CountSelector

  6. #6
    Clicker Fusion 2.5Android Export Module

    Join Date
    Jun 2014
    Location
    London, UK
    Posts
    96
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Unfortunately I'm creating this game for Android, so none of the extensions will work for me.

    And to Tuna's suggestion, I'm not quite sure where you're coming from. Surely if CountSelector <> PreviousPick then it would only run this line if it does not match the previousPick? But the previousPick will always match CountSelector since it sets previousPick to CountSelector everytime it generates a random number. Or have I understood it completely wrong?


    Thanks.

    Samer.

  7. #7
    Clicker Fusion 2.5Android Export Module

    Join Date
    Jun 2014
    Location
    London, UK
    Posts
    96
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I really appreciate your suggestions, Snail, but I'm still not getting a clear and logical picture in my head. What I've got at the moment is this:

    if countSelector <> previousPick
    -set previousPick to countSelector

    if countSelector = previousPick
    -Start loop "ran" 2 times

    On loop "ran"
    -Set countSelector to RRandom (1, 4)

    Every Second
    -Set Counter to countSelector



    But for some reason, this still isn't doing the trick. :/

    Any clarification would be much appreciated.

    Thanks.

    Samer.

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleUnicode Add-on

    Join Date
    Nov 2010
    Location
    Switzerland
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The List-Object should work in Andoid too. You can place it outside the Frame if you don' t want it to show in the Frame or you can even make the List invisible during Runtime
    I think it' s the Easiest Way to achieve what You want. You can even populate the List with Numbers at Runtime and then draw numbers off from a Random-Line in the List and then delete that Line in the List.

  9. #9
    Clickteam Clickteam
    Danny's Avatar
    Join Date
    Aug 2007
    Location
    United Kingdom
    Posts
    3,016
    Mentioned
    21 Post(s)
    Tagged
    2 Thread(s)
    Here is a cross platform example in just 3 events... should be of use! You can make the list object 'hidden' and take it out of the playarea for your games.

    min-max-random.zip

    Just change the Alterable Values (MinRandom and MaxRandom) to change the number scope from and to.

  10. #10
    Clicker Fusion 2.5Android Export Module

    Join Date
    Jun 2014
    Location
    London, UK
    Posts
    96
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Thanks Danny for the attached example. However I don't think this will work in my case, since the 4 Random numbers I need generated need to be reused rather than deleted from the list.

    Any other ideas? :S

    I really appreciated this, btw.

    Samer.

Page 1 of 2 1 2 LastLast

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. Non Repeating Number Generating in IOS .
    By hcem in forum iOS Export Module Version 2.0
    Replies: 1
    Last Post: 19th January 2013, 03:51 PM
  3. Non Repeating Number Generating in IOS - Possible ??
    By hcem in forum iOS Export Module Version 2.0
    Replies: 2
    Last Post: 19th January 2013, 03:30 PM
  4. Generating random floating point numbers
    By Greasy in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 7th January 2012, 06:12 AM
  5. 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

Posting Permissions

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