the value assigned to the IntegerOrder will remain the same, but the order of the IntegerOrder will be randomly re-ordered using 1-50 "slots" per say.
My goal is to create a virtual table and randomize its order. Then, I return values based on 1 through 50, which has been randomized for the map I am creating.
Could brute force it, you'll need another temp array[50] variable and sequentially pass through the first one pulling the values, set an int to a random value between 1 and max then brute force loop check the temp one to see if you've already added an entry at that random spot: if so re-randomize the int and do another check, if not input the value and move onto the next array value of your original. If its only 50 numbers the end few that'll have a lot of repeated loops to find the last remaining open slots won't be so bad, if you're talking in the thousands well you may want a better solution.
(this assumes that 0 is never a valid value in the array, you could just as easily use -1 or just any number that'd never appear in the array to indicate a free spot, just remember to first pass through the temp's array and set it all to that value you want to indicate as a free spot)
assume tmp and i are local variables of type integer.
Pick Each Integer From 0 to (size of array - 1)
Set i = Random integer from 0 to (size of array - 1)
Set tmp = Array[i]
Set Array[i] = Array[(picked integer)]
Set Array[(Picked integer)] = tmp
to be honest though if you're getting trigger errors and can't figure out what's wrong then I think you just don't understand some of the fundamentals of how triggers (or programming in general) work. maybe go through some tutorials or something to get a better understanding.
assume tmp and i are local variables of type integer.
Pick Each Integer From 0 to (size of array - 1)
Set i = Random integer from 0 to (size of array - 1)
Set tmp = Array[i]
Set Array[i] = Array[(picked integer)]
Set Array[(Picked integer)] = tmp
to be honest though if you're getting trigger errors and can't figure out what's wrong then I think you just don't understand some of the fundamentals of how triggers (or programming in general) work. maybe go through some tutorials or something to get a better understanding.
If mapping since day 1 of SC1 -> WC3 - > TFT -> SC2 doesn't count for some measure of fundamental understanding, I'm not sure what community I am in anymore.
I need mathmatical help. Is there a way to randomize an array in an integer (in theory, reorganizing it) without creating duplicate values?
For example:
Make variable "IntegerOrder[player#][loop50]" = "Integer_id_number[player#][loop50]"
go to:
variable "IntegerOrder[player#][randomized reordering]" = "Integer_id_number[player#][loop50]"
the value assigned to the IntegerOrder will remain the same, but the order of the IntegerOrder will be randomly re-ordered using 1-50 "slots" per say.
My goal is to create a virtual table and randomize its order. Then, I return values based on 1 through 50, which has been randomized for the map I am creating.
I hope I made a little sense....
Could brute force it, you'll need another temp array[50] variable and sequentially pass through the first one pulling the values, set an int to a random value between 1 and max then brute force loop check the temp one to see if you've already added an entry at that random spot: if so re-randomize the int and do another check, if not input the value and move onto the next array value of your original. If its only 50 numbers the end few that'll have a lot of repeated loops to find the last remaining open slots won't be so bad, if you're talking in the thousands well you may want a better solution.
Pseudo code
(this assumes that 0 is never a valid value in the array, you could just as easily use -1 or just any number that'd never appear in the array to indicate a free spot, just remember to first pass through the temp's array and set it all to that value you want to indicate as a free spot)
for each item in the array, swap its value with a randomly selected index in the same array.
I attempted what I thought it was you suggested, and got nothing but trigger errors for an hour.
And then I tried what the 1st suggestion was... and got trigger errors again. I deleted both triggers and am starting from scratch.
Again: I am reoganizing an array, but the arrays being reorganized (randomly) still hold the same values. Grr :P
assume tmp and i are local variables of type integer.
Pick Each Integer From 0 to (size of array - 1)
Set i = Random integer from 0 to (size of array - 1)
Set tmp = Array[i]
Set Array[i] = Array[(picked integer)]
Set Array[(Picked integer)] = tmp
to be honest though if you're getting trigger errors and can't figure out what's wrong then I think you just don't understand some of the fundamentals of how triggers (or programming in general) work. maybe go through some tutorials or something to get a better understanding.
If mapping since day 1 of SC1 -> WC3 - > TFT -> SC2 doesn't count for some measure of fundamental understanding, I'm not sure what community I am in anymore.
However, thank you for the input.
--
I think I understand what to do now.