- Joined
- Oct 9, 2019
- Messages
- 295
Here is my code for getting maxNumbers unique random numbers from 0 to maxIndex. It usually works however I wonder if there is a way to do this without brute force?
JASS:
local integer count=0
local integer rand
loop
set rand=GetRandomInt(0,maxIndex)
if not chosenIndexes.exists(rand) then
set chosenIndexes.boolean[rand] = true
//dostuff
set count = count + 1
endif
exitwhen count >= maxNumbers
endloop
call chosenIndexes.flush()