How does "Pick a random object" internally work?


im wondering how “Pick a random object” internally works, as i am getting strange results. Does “Pick a random object” create a queue with objects internally when it is called serveral times?
So lets say i call it 3 times successively, does it have 3 objects in queue?

My problem is:

I want to get 4 random objects from a group.
Each object has an object variable type
Each time i want to get 4 random objects, i want to get
1-2 objects of type “one” and
2-3 objects of type “two”

For that i am running “Pick a random object” in a loop.


before the loop:
    do = 0 to objectOneCounter
    do = 0 to objectTwoCounter
    do = 0 to total_object_counter

Runs in a loop:
    Pick a random object
  •    Variable type of object is one         position the object
      objectOneCounter < 2                    do + 1 to objectOneCounter
                                              do + 1 to total_object_counter
  •    Variable type of object is two         position the object
      objectTwoCounter < 3                    do + 1 to objectTwoCounter
                                              do + 1 to total_object_counter

and this repeats until the total_object_counter is 4

Seeing this you might notice that this loop can potentially have “dry runs”, runs without doing anything. For example when objectOneCounter is already 2 and another type one object has been picked. But thats ok (the game is round based).

But the problem is, sometimes it happens that i only get 3 objects. Not every round but sometimes.

Im wondering if it has something to do with how “Pick a random object” works. As my code looks pretty right to me.