randumb!

ApplaudAppsApplaudApps Member Posts: 308
edited November -1 in Working with GS (Mac)
Hey,

I know the random thing has been discussed to death but anyone got any new clever ideas?

I need to assign 4 attributes each with a unique integer 1,2, 3 or 4 in a random order with no repeats.

I know about seeding the random function to make it more random but is there a simple way to populate the attributes.

As it stands I'm thinking I have to do this :

game.att1 = random

game.att2 = random
check att2 does not equal game.att1
if it does try again

game.att3 = random
check att3 does not equal game.att1 or game.att2 etc....

Comments

  • old_kipperold_kipper Member Posts: 1,420
    Pretty much as you suggest. I would throw a random number between 1 and 100 perhaps for each attribute and then if there was a repeat make a repeat of the loop. Then select the highest with a > check. To avoid repeats drop out the winner on the next run.
  • ApplaudAppsApplaudApps Member Posts: 308
    Thx for reply old kipper

    I'm running a random on att1, att2 and att3 on a timer every 0 seconds loop until the player hits play (tsb's suggestion in an old post)

    then when they hit play I have 1.5 seconds to deal with any repeats so every 0.1 seconds it checks

    if att1 = att2 if they do att2=new random
    otherwise check if att3 = att1 or att3 = att2 if they do att3= new random

    that shouldn't be too taxing to work everytime within 15 passes of the loop (i hope and will keep testing)

    the final att4 is simply 10 minus the sum of the other 3.

    I'm running with this but if anyone can help improve please post it up

    Cheers :)
  • old_kipperold_kipper Member Posts: 1,420
    I don't think you need to run the timers. Just rules that say if = then run the random. I have just done something like this that ran exactly when I wanted the random and it worked fine and with no perceivable wait (also you can fire it by putting a zero in all attribute to generate the new randoms).
  • ApplaudAppsApplaudApps Member Posts: 308
    The "if then" rule will only test it once and generate a new random once, which could be a duplicate again. The timer is a loop so that it keeps generating a random until its different to the 1st attribute, more like a "while" statement.
  • old_kipperold_kipper Member Posts: 1,420
    I'll check how i did it...
Sign In or Register to comment.