random specific numbers?

POMPOM Member Posts: 2,599
edited November -1 in Working with GS (Mac)
hey is there a way to make a change attribute behavior to a random number from a specific list?
like-
change attribute ZZZ to random of 2,5,9,35,67
and not just min and max

could not figure it out hope you can help me..

Comments

  • AtlantenAtlanten Member, PRO Posts: 56
    How about

    change attribute Z to random(1,5)

    if Z=1 then change attribute ZZZ to 2
    ...
    if Z=5 then change attribute ZZZ to 67

    This would suck if your list of numbers is really long, but otherwise it would work!
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    Good idea atlanten, that should work perfect. Tedious maybe :) but it should work perfect
  • POMPOM Member Posts: 2,599
    Wish I could use it but I have a list of about 30 numbers ;(
    it's such a simple task yet we can't do it..
    Maybe the GS guys will add this option in a later version
  • synthesissynthesis Member Posts: 1,693
    You could use a random tree...

    ie...
    set an attribute to tempRandomValue (tRV)
    then changeAttribute tRV to random(1,3)...this splits the 30 numbers in thirds
    then have 3 rule branches (1 for each result)
    when tRV = 1
    then tRV= random(1,5)...this splits the 10 numbers (of the third set into fifths)
    when tRV = 1
    then trV= random(1,2)...this splits the fifths in half.
    when tRV= 1
    .......ZZZ = 2 otherwise ZZZ = 5 (this assigns the first 2 values of the 30)

    repeat each branch and sub-branch of the tree.

    It is tedious...but it works! Plus its efficient as it only take 4 processing steps to get the sequence number vs...30 rule checks for the random number assignment.

    In open coding...you can do this as a function or an array or whatever...but in GS...you have to use rules.
Sign In or Register to comment.