Suppose I want to be fair and I have N unique units I want to give out to N players, where each player receives exactly one of those unique units, and no player has an identical unit.
For simplicity here is an example for N=4
4 players, 4 unique options:
0 = Terran Marine
1 = Terran Ghost
2= Terran Firebat
3= Terran Medic
I know how to randomly generate a number in the editor (a single switch with a death counter). But how do I prevent the other players from generating a number that has already been picked?
Suppose player one rolls number 0. He is assigned the Terran Marine.
Now player two rolls. In order to make sure he does not roll 0 or rather I resize the mapping to now roll a number 0-2 (0 = ghost, 1 = firebat, 2 = medic). I would need to iterate over all four cases (one of 0, 1, 2, or 3 is taken by player 1). This is a little silly I think.
When player three rolls, I need to iterate over two choose four possible cases to make sure he can only random an option not picked.
In the general case I would need this many "cases" for N players:
(1 choose N) + (2 choose N) + ... + (N - 1 choose N) = some very large number
I know if I bruteforced it for N unique options there would have to be N! cases (that is I simply generate a random number where each one represents a possible combination of the N options).
Now there are easier alternatives:
junk yard dog
or basing it on a player's action (e.g. when they move to a location).
I do not want to use either of those. So what is the solution using switch randomization with a DC?
Edit: Another stupid solution would be to have each player keep re-rolling until they get a number that hasn't been used. In the general case I don't think that's feasable but I know for a fact my N <= 6. So perhaps I should just use that.
Edit: Bruteforce solution isn't working because for some reason I am not generating a number 0-719... Please tell me what is wrong with my triggers (attached in text file...).
Edit: I found a working method. But I realized something...the RNG must fix itself in singleplayer, because I kept looping between only two of six choices when using "Restart Mission." But on Battle.net each game resulted in one of the six choices like it should >_>
Attachments:
Post has been edited 3 time(s), last time on May 7 2014, 11:43 am by sethmachine.
None.