List of integers - selecting 4 numbers from that list
darkdreamr
Member Posts: 1
i need help. i need to make 4 unique random numbers... (none can match another)
normally in another programing language i would have a list of integers 1,2,3,4,5,6,7,8,9,10
from that list i would randomize it.. and pull from 4 different positions.. numbers never repeat.
but im having troubles making non repeating numbers.. i dont wanna limit the randomization
of the numbers (ie - box 1 = 1-3 box2 = 4-5 ect)
basicly what im asking is
is there a way of taking 4 integers.. that randomize between 1 and 10
and make sure none of them repeat? and how do i do it
normally in another programing language i would have a list of integers 1,2,3,4,5,6,7,8,9,10
from that list i would randomize it.. and pull from 4 different positions.. numbers never repeat.
but im having troubles making non repeating numbers.. i dont wanna limit the randomization
of the numbers (ie - box 1 = 1-3 box2 = 4-5 ect)
basicly what im asking is
is there a way of taking 4 integers.. that randomize between 1 and 10
and make sure none of them repeat? and how do i do it
Comments
I'll give you a quick high-level answer until I can get all the details in.
Since we don't have tables yet, you will need game attributes that will keep track of which numbers have been chosen.
When you get a random number, set an attribute that says you are in the state of getting a random number. Have a rule that checks if you are in the choose a number state AND if the number selected equals 1. (Repeat this rule set for each number) Have a rule inside that rule that checks if the attribute tracking if that number has been chosen. If it has, change the attribute with a random number again. If it hasn't, change the choosing state to false, and set the number chosen to that number.
I think that should work.