It's been awhile since I've taken a stats class, so I may be using my terminology incorrectly.
Sampling without duplication is when you want to choose something at random, but once it's picked, you don't want to pick it again. This is easy with things like player groups and unit groups because you can simply pick someone at random from them, then remove that item from the group. I wanted to do this with points, but there is no point group. My initial thought was to do something with booleans, but that seemed messy so I decided to sleep on it before I did anything. I came up with this solution:
First I set up all the points into an array using set variable. Then I would use a random number to choose one of those said points. It does what I want for the point. Then I use the following solution to remove the point from the, point group, or in my case the array. I took the variable for the chosen point and made it copy the point in the array one above itself. I then went to the one above itself and made it copy its above stairs neighbor and so on and so forth. The top variable then got chopped off. This essentially overwrites the one point that got picked, and moves all the points in a higher number in the array one spot down. There is no need to do anything with the points below the random number because we still want them as possibilities to get chosen.
Here is what my action looks like. I have not changed names so if you need context, it's for a boss that shoots beams which will start off spawning at a certain point (then head off to some other point unrelated to this example).
+Zone3:BossChooseRandomAttackBeamOptions:Action,CreateThreadReturnType:(None)ParametersNumberofbeams=2<Integer>GrammarText:+Zone3:BossChooseRandomAttackBeam(Numberofbeams)HintText:(None)CustomScriptCodeLocalVariablesPotentialattackpoints=NoPoint<Point[7]>
Max Integer = 7 <Integer>
Random integer = 1 <Integer>
i = 1 <Integer>
Actions
General - Action Group: "Setting up potential beams"
General - Action Group: "Picking Beams"
Actions
General - Repeat (Actions) Number of beams times
Actions
Variable - Set Random integer = (Random integer between 1 and Max Integer)
General - Action Group: "Random beams do their thing"
Variable - Modify Max Integer: - 1
General - Action Group: "Crushing variables"
Actions
General - For each integer i from Random integer to Max Integer with increment 1, do (Actions)
Actions
Variable - Set Potential attack points[i] = Potential attack points[(i+1)]
Number of beams parameter is where I chose how many beams the boss would send. It changes depending on boss hp and difficulty.
Action Group: "Setting up potential beams" is where I set the array variables to their actual points on the map.
General - Action Group: "Random beams do their thing" is where I made the beams spawn and do what I wanted them to do
Just wanted to share this as I imagine others have probably had questions about it. Should I throw this in tutorials?
It's been awhile since I've taken a stats class, so I may be using my terminology incorrectly.
Sampling without duplication is when you want to choose something at random, but once it's picked, you don't want to pick it again. This is easy with things like player groups and unit groups because you can simply pick someone at random from them, then remove that item from the group. I wanted to do this with points, but there is no point group. My initial thought was to do something with booleans, but that seemed messy so I decided to sleep on it before I did anything. I came up with this solution:
First I set up all the points into an array using set variable. Then I would use a random number to choose one of those said points. It does what I want for the point. Then I use the following solution to remove the point from the, point group, or in my case the array. I took the variable for the chosen point and made it copy the point in the array one above itself. I then went to the one above itself and made it copy its above stairs neighbor and so on and so forth. The top variable then got chopped off. This essentially overwrites the one point that got picked, and moves all the points in a higher number in the array one spot down. There is no need to do anything with the points below the random number because we still want them as possibilities to get chosen.
Here is what my action looks like. I have not changed names so if you need context, it's for a boss that shoots beams which will start off spawning at a certain point (then head off to some other point unrelated to this example).
Number of beams parameter is where I chose how many beams the boss would send. It changes depending on boss hp and difficulty.
Action Group: "Setting up potential beams" is where I set the array variables to their actual points on the map.
General - Action Group: "Random beams do their thing" is where I made the beams spawn and do what I wanted them to do
Just wanted to share this as I imagine others have probably had questions about it. Should I throw this in tutorials?
my solution to this was this http://www.sc2mapster.com/forums/development/triggers/81784-integer-group/
your solution might be faster if the array is "used" completely.