I need someone to help me write a function to return the number of random numbers specified, but they all need to be unique, the numbers it returns.
Like what I was thinking was something like:
;Something like above, with 2,3,4,5,6 different
;random numbers being returned depending on the need.
The reason is, I am randomly placing a few puzzle pieces, and I don't want them to overwrite each others grid positions, so if a certain gridx is already selected, I don't want to pick it again, in the random routine. Same for gridy locations.
Any help would be greatly appreciated. What I have written is kind of obfiscuated and not sure if it will work as designed or not.
Thanks
Like what I was thinking was something like:
type rnumber field rand1,rand2,rand3,rand4,rand5,rand6 end type global numbers.rnumber = new rnumber function MyRand(num_numbers%, min%, max%) ;maximum of 6 random numbers returned, prolly have to ;make a type shown above to return all of them at ;same time. .not_unique2 if num_numbers = 2 numbers\rand1 = rand(min,max) numbers\rand2 = rand(min,max) goto check_unique endif .check_unique if num_numbers = 2 then if numbers\rand1 = numbers\rand2 then goto not_unique2 else goto unique2 endif endif .unique if num_numbers = 2 then return numbers endif end function
;Something like above, with 2,3,4,5,6 different
;random numbers being returned depending on the need.
The reason is, I am randomly placing a few puzzle pieces, and I don't want them to overwrite each others grid positions, so if a certain gridx is already selected, I don't want to pick it again, in the random routine. Same for gridy locations.
Any help would be greatly appreciated. What I have written is kind of obfiscuated and not sure if it will work as designed or not.
Thanks