User Tag List

Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 22

Thread: Random number without last number ? (It's possible ?) (random counter)

  1. #1
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)iOS Export Module (Steam)

    Join Date
    Jan 2015
    Posts
    262
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Random number without last number ? (It's possible ?) (random counter)

    Hi,

    I have a counter with my project. Every 1 second my counter change number between 1 - 10 (range 1 to 10). After that when counter select number i have Set counter to 0. So it's look like:

    Select number between 1 - 10 -> Number 5 -> Set Counter to 0 -> My counter is 0 -> 2 second -> Select number between 1-10 > Number 7 etc.

    Everything work great but from time to time my counter select the same number as last time. How can i resolve it ? I would like to create counter system without the same number after. ( 1 sec - select 5, 2 sec - select 5 - WRONG ; 1 sec. - select 5 , 2 sec - select 7 , 3 sec. select 5 - GOOD)

    Regards,

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module

    Join Date
    Nov 2011
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    store the last value of your counter in a glogal variable(a)...test if the newvalue is the same of the global variable(a) then restart your random counter...

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    You could use a list object that would serve as a pool of numbers

    1)
    store numbers from 1-9 in the list and set list index to 0,
    prepare an additional "record counter" with starting value 10

    then:

    2)
    pick a random list line from random(total lines number) and set the "main counter" to this line value,
    add the "record counter" value as a line to the list,
    set the "record counter" to the "main counter" value

    drawbacks: first throw will never return 10

  4. #4
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)iOS Export Module (Steam)

    Join Date
    Jan 2015
    Posts
    262
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Thank you guys.

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Sparckman's Avatar
    Join Date
    Feb 2011
    Location
    Planet of the Kangaroos
    Posts
    1,423
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

  6. #6
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Posts
    1,305
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    I like to solve these kinds of problem using string functions:

    Set counter to:
    Val(Mid$(Left$("01020304050607080910", (value( "Counter" )-1)*2)+Right$("01020304050607080910", 20-(value( "Counter" )*2)), Random(9)*2, 2))

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    beautiful solution

  8. #8
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleMac Export Module
    dsilvers's Avatar
    Join Date
    Jun 2008
    Location
    Boston, MA
    Posts
    573
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    That's the kind of thing I love ​doing in Fusion! Setting up a real calculation and performing all sorts of crazy tricks without the need for extra extensions and feeling like a badass for doing so.

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module

    Join Date
    Apr 2010
    Location
    Germany
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You guys already found a solution, but you could also use the following:
    Set Counter to (( value( "Counter" ) + 1 + Random(a)) mod (a+1))

    Want random numbers between 0 and 9? Just set a=9:
    Set Counter to (( value( "Counter" ) + 1 + Random(9)) mod 10)

    You'll never have the same number behind one another. Don't forget to +1 when displaying this value to get your 1 to 10 range.

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    Really elegant and clever.
    These are for sure the two better solutions!

    single lined, objectless, quick & solid

Page 1 of 3 1 2 3 LastLast

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. Spread random number?
    By ratty in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 4th August 2012, 05:36 PM
  3. Random number
    By Mayfly in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 27th August 2008, 12:36 PM
  4. Random Number Experiment
    By Pkeod in forum File Archive
    Replies: 2
    Last Post: 24th December 2007, 12:10 AM
  5. Random Number Gen
    By mee in forum The Games Factory 2 - Technical Support
    Replies: 3
    Last Post: 7th February 2007, 10:06 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
  •