Yes, I cannot seem to accomplish basic set theory, as I have no ability to create/add/remove integers/reals from an Integer/Real Group, as I can create/destroy/add/remove units/players from Unit and Player Groups.

The result is that I've been making hidden dummy units at certain X coordinates and getting the X position of the units in the unit group and converting it to a real/integer. I've been removing and adding these units to the unit group in order to simulate the effect of adding/removing integers/reals from Integer/Real groups.

So my question: Is there a way to create sets of integers?

This doesn't work because I want to select a random value from these arrays. Not to mention that the size of an array is fixed. If I want to remove a value from the array such that it cannot be picked, but retain the ability to add it back later, how would I go about that?

EDIT: Here is why I cannot use arrays.

Pick a Random Number from set {1, 6, 18, -23, 5, 2, -14}

vs

Set Integer A = Random Number between 1 and 7, set Integer B = IntegerArray[A]

Already this takes two steps instead of one. Now take a more complicated scenario.

Subtract the set B {0, 4, 18, -14, 9) from set A {1, 6, 18, -23, 5, 2, -14} and set Set A to the result.
Result Set A = { 1, 6, -23, 5, 2}

vs

?

The problem is that there are no set theory controls. It would nice to bring sets into union, disjunction and intersection, as well as create and destroy sets.

This doesn't work because I want to select a random value from these arrays. Not to mention that the size of an array is fixed. If I want to remove a value from the array such that it cannot be picked, but retain the ability to add it back later, how would I go about that?

EDIT: Here is why I cannot use arrays.

Pick a Random Number from set {1, 6, 18, -23, 5, 2, -14}

vs

Set Integer A = Random Number between 1 and 7, set Integer B = IntegerArray[A]

Already this takes two steps instead of one. Now take a more complicated scenario.

Subtract the set B {0, 4, 18, -14, 9) from set A {1, 6, 18, -23, 5, 2, -14} and set Set A to the result. Result Set A = { 1, 6, -23, 5, 2}

vs

?

The problem is that there are no set theory controls. It would nice to bring sets into union, disjunction and intersection, as well as create and destroy sets.

It's pretty simple to implement them. There are many different ways to implement sets, which is best depends on your usage.

You can code your own sets with Galaxy. There is no built-in functionality for what you want.

I've been looking for these functionality. Can you give me a small tutorial of how to create the following integer set, and how to use it in this following example?

Create set A = {1 , 4, 9, 17, 29}, Create set B = {-5, 17, 4}, Create set C as the disjunction between sets A and B, C = {1, 9, 29, -5}

Reset set A to set C, set A = {1, 9, 29, -5}, Set integerX to a random element of set A

It's pretty simple to implement them. There are many different ways to implement sets, which is best depends on your usage.

Here is my usage:

I need to limit the amount of Unit Groups that can exist on my map for a trigger that creates formations. The Unit Group Array is set to 300, thus I cannot have more than 300 formations on the map at any time. However, I want it to be possible to disband formations and destroy formations if the leader unit dies. Thus I need to be able to reuse a Formation Group index without overwriting it.

So let's say I want to create a formation of units. The Trigger fires, the first thing it does is look for the first Empty Unit Group within my 300 unit group array. This means the loop needs to be executed up to a maximum of 300 times. After it finds the first index that is empty, it creates the group. This is how the function currently works. It is however, very inefficient, not to mention that the loop Array is not 300, but only 24 in size, as 300 to is too large a number for such a frequent trigger.

What I would like to do instead: Start with some set A with the integers {1 , 2, 3, 4, 5 . . . 300} and a second set of integers B that is initially empty, so B = { } or null

Now when we create the first formation is picks a random number n from A and the variable UNITGROUP[n] becomes the formation group. We then remove n from A and add n to B. Now A = {1, 2, 3 . . . 300} - {n} and B = {n}

Now when I go to make my second formation group it picks a random number from A, but now n cannot be picked. Call this m, now A = {1, 2, 3...300} - {n} and B = {n, m}

Now if the group is disbanded or the leader dies, I want to place that index back into A and remove it to B. Say the first group dies, then we put n back inside A and remove n from B.

If A becomes empty and some player tries to form a new group, a message will be displayed that says "Too many formation groups, please disband some formations."

You can look up the concept of a linked list and try to integrate one. That'd pretty much serve your purpose well.

Or you can reduce the number of iterations by grouping your unit groups. Meaning we create several smaller arrays of unit group and keep track of how many of them are empty. Then we check each array if it has empty unit groups. If it does then we loop through the array fields to find an empty slot.
About like this:

StructGroupChunk:groups[20]=EmptyUnitGroup<UnitGroup>emptyGroups=20<Integer>//And a global array of GroupChunk:GroupList[15]<GroupChunk>

To find a new empty group:

LocalVariables:i=0<Integer>//We increment our counter i as long as the current Group chunk doesn't have a free slot.//We also stop the loop when i is larger than 15, since that'd be larger than our array size of//GroupList.While-ConditionsORGroupList[i].emptyGroups==0i>15-ActionsSeti=i+1Ifi<=15Then//Now loop through GroupList[i].groups and find an empty unit group//Then we reduce emptyGroups by 1 since we will occupy one group slot.SetGroupList[i].emptyGroups=GroupList[i].emptyGroups-1Else//No more empty groups left.Endif

Yes, I cannot seem to accomplish basic set theory, as I have no ability to create/add/remove integers/reals from an Integer/Real Group, as I can create/destroy/add/remove units/players from Unit and Player Groups.

The result is that I've been making hidden dummy units at certain X coordinates and getting the X position of the units in the unit group and converting it to a real/integer. I've been removing and adding these units to the unit group in order to simulate the effect of adding/removing integers/reals from Integer/Real groups.

So my question: Is there a way to create sets of integers?

For instance Set A = {1, 6, 18, -23, 5, 2, -14}

@EdwardSolomon: Go

Use arrays.

@tFighterPilot: Go

This doesn't work because I want to select a random value from these arrays. Not to mention that the size of an array is fixed. If I want to remove a value from the array such that it cannot be picked, but retain the ability to add it back later, how would I go about that?

EDIT: Here is why I cannot use arrays.

Pick a Random Number from set {1, 6, 18, -23, 5, 2, -14}

vs

Set Integer A = Random Number between 1 and 7, set Integer B = IntegerArray[A]

Already this takes two steps instead of one. Now take a more complicated scenario.

Subtract the set B {0, 4, 18, -14, 9) from set A {1, 6, 18, -23, 5, 2, -14} and set Set A to the result. Result Set A = { 1, 6, -23, 5, 2}

vs

?

The problem is that there are no set theory controls. It would nice to bring sets into union, disjunction and intersection, as well as create and destroy sets.

I don't think you will find an easy way to do it, but you can use the data table to make dynamic arrays, so it is possible to implement it.

It's pretty simple to implement them. There are many different ways to implement sets, which is best depends on your usage.

@EdwardSolomon: Go

You can code your own sets with Galaxy. There is no built-in functionality for what you want.

I've been looking for these functionality. Can you give me a small tutorial of how to create the following integer set, and how to use it in this following example?

Create set A = {1 , 4, 9, 17, 29}, Create set B = {-5, 17, 4}, Create set C as the disjunction between sets A and B, C = {1, 9, 29, -5}

Reset set A to set C, set A = {1, 9, 29, -5}, Set integerX to a random element of set A

Here is my usage:

I need to limit the amount of Unit Groups that can exist on my map for a trigger that creates formations. The Unit Group Array is set to 300, thus I cannot have more than 300 formations on the map at any time. However, I want it to be possible to disband formations and destroy formations if the leader unit dies. Thus I need to be able to reuse a Formation Group index without overwriting it.

So let's say I want to create a formation of units. The Trigger fires, the first thing it does is look for the first Empty Unit Group within my 300 unit group array. This means the loop needs to be executed up to a maximum of 300 times. After it finds the first index that is empty, it creates the group. This is how the function currently works. It is however, very inefficient, not to mention that the loop Array is not 300, but only 24 in size, as 300 to is too large a number for such a frequent trigger.

What I would like to do instead: Start with some set A with the integers {1 , 2, 3, 4, 5 . . . 300} and a second set of integers B that is initially empty, so B = { } or null

Now when we create the first formation is picks a random number

nfrom A and the variable UNITGROUP[n] becomes the formation group. We then removenfrom A and addnto B. Now A = {1, 2, 3 . . . 300} - {n} and B = {n}Now when I go to make my second formation group it picks a random number from A, but now

ncannot be picked. Call this m, now A = {1, 2, 3...300} - {n} and B = {n, m}Now if the group is disbanded or the leader dies, I want to place that index back into A and remove it to B. Say the first group dies, then we put n back inside A and remove n from B.

If A becomes empty and some player tries to form a new group, a message will be displayed that says "Too many formation groups, please disband some formations."

You can look up the concept of a linked list and try to integrate one. That'd pretty much serve your purpose well.

Or you can reduce the number of iterations by grouping your unit groups. Meaning we create several smaller arrays of unit group and keep track of how many of them are empty. Then we check each array if it has empty unit groups. If it does then we loop through the array fields to find an empty slot.

About like this:

To find a new empty group:

I hope that makes sense to you :P

@s3rius: Go

Yes thank you for the advice, this concept carries well into many other ideas as well. Thank you