Random numbers

ChillBoxChillBox Member, PRO Posts: 115
edited November 2013 in Working with GS (Mac)
Hello,
I want to change attribute to a random numbers between 1 to 1000
I want that the Random numbers that have been selected not repeat themselves again.
how can I do that?

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited November 2013

    Hello @Talo One way that works quite well for non-repeating random numbers is to use Tables.

    So you'd make your attribute (let's call it MyRand) – give it a value of 1 more than your max. random number (so in this case, it'll be 1001).

    And then a boolean for a loop if that's the way you're going to trigger it over and again, so I'll include that as a continuous loop, triggered every 3 seconds as an example.

    Make your table with 1 column, each row cell the number from 1 to 1000 (or even a randomised order). Then make another blank Table called TRandUse.

    Copy Table MyTable to TRandUse (so you can reset to the beginning again later if you wanted)

    Display Text MyRand

    Rule: When Loop is false
    Change Attribute MyRand to random(1,MyRand-1)
    Change Attribute MyNum to TableCellValue(TRandUse,MyRand,1)
    Add/Remove Row Table: TRandUse Remove Row At Index MyRand
    Timer: After 3 seconds
    Change Attribute Loop to true

    Rule: When Attribute Loop is true and MyRand > 0
    Change Attribute Loop to false

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • SocksSocks London, UK.Member Posts: 12,822
    edited November 2013
    ...
Sign In or Register to comment.