I have three variables, X, Y and Z. I want to assign each one of those variables to a number between 1 and 8 with No repeats, without messing with the odds for each variable other than picking order (meaning X has 1-8 chance, Y will have 1-7 chance and Z will have 1-6 chance etc.)
So what I did was I have an array set up with 8 slots. each slot has it's own specified value, 1 through 8 respectively ie. OptionsArray[1] = 1; OptionsArray[2] = 2; ... ...
Set X = RandomInt(1,8)
create unit at point PointArray(X)
Set OptionsArray[X] = OptionsArray[8]
Set OptionsArray[8] = OptionsArray[X]
Set Y = RandomInt(1,7)
create unit at point PointArray(Y)
Set OptionsArray[Y] = OptionsArray[7]
Set OptionsArray[7] = OptionsArray[Y]
...
Essentially, the idea is I'm picking X, a random number between 1-8 and then swapping the values of cells 1 and 8 of the randomly picked numbers (OptionsArray). So lets say random number 4 was chosen for X this is what the array would look like:
cell -> 1 2 3 4 5 6 7 8
value->1 2 3 8 5 6 7 4
and then for Y, it's only grabbing a random number from this array between cells 1 and 7... and then it swaps it for the seventh value in the array.
lets say the number chosen randomly for Y was 2.
cell -> 1 2 3 4 5 6 7 8
value->1 7 3 8 5 6 2 4
And now when I set Z, it'll be choosing a cell 1-6 from this array. Thus, I'm only picking from numbers that havn't been chosen yet.
HOWEVER, I'm still getting repeats somehow. any ideas on why? or an easier way to get the same result?
I have three variables, X, Y and Z. I want to assign each one of those variables to a number between 1 and 8 with No repeats, without messing with the odds for each variable other than picking order (meaning X has 1-8 chance, Y will have 1-7 chance and Z will have 1-6 chance etc.)
So what I did was I have an array set up with 8 slots. each slot has it's own specified value, 1 through 8 respectively ie. OptionsArray[1] = 1; OptionsArray[2] = 2; ... ...
Set X = RandomInt(1,8) create unit at point PointArray(X) Set OptionsArray[X] = OptionsArray[8] Set OptionsArray[8] = OptionsArray[X]
Set Y = RandomInt(1,7) create unit at point PointArray(Y) Set OptionsArray[Y] = OptionsArray[7] Set OptionsArray[7] = OptionsArray[Y]
...
Essentially, the idea is I'm picking X, a random number between 1-8 and then swapping the values of cells 1 and 8 of the randomly picked numbers (OptionsArray). So lets say random number 4 was chosen for X this is what the array would look like:
cell -> 1 2 3 4 5 6 7 8 value->1 2 3 8 5 6 7 4
and then for Y, it's only grabbing a random number from this array between cells 1 and 7... and then it swaps it for the seventh value in the array.
lets say the number chosen randomly for Y was 2.
cell -> 1 2 3 4 5 6 7 8 value->1 7 3 8 5 6 2 4
And now when I set Z, it'll be choosing a cell 1-6 from this array. Thus, I'm only picking from numbers that havn't been chosen yet.
HOWEVER, I'm still getting repeats somehow. any ideas on why? or an easier way to get the same result?
Nevermind, here was the problem...
Create 1 Desstructable Debris - 4x4 for player 0 at (Center of RegionsArray(PickingArray[X]))
:)