Random generator not so random?

Hello,

I am trying to creat a process where it randomly picks teams of 2 players out of a list of 12 players. I have run this process for more than 30.000 times, and the results are not so random after the first pick. These are the times every player was picked for each position:

The process step by step is as follows:

  1. Build data table “dtData” with 12 players
  2. Assign Int32 variable “Index”=new Random().Next(0,dtData.RowCount)
  3. Assign String variable “Player1”=dtData.Rows(Index)(0).ToString
  4. Filter data table “dtData” to remove Player 1 from column 0
  5. Assign Int32 variable “Index2”=new Random().Next(0,dtData.RowCount)
  6. Assign String variable “Player2”=dtData.Rows(Index2)(0).ToString
  7. Filter data table “dtData” to remove Player 2 from column 0
  8. Add data row to a new table called “dtDoubles” with the array {Player1, Player2}
  9. Flow decision with the condition “dtData.RowCount=0” if true, the process ends, if false it repeats all steps after the second step.

Can you tell me what I am doing wrong?

Thanks in advance.

@Andre_Santos
Welcome to the forum

give try at following:
Define a variable: name: myRandom | DataType: System.Random | DefaultValue: new Random()

Whenever you want to generate a random number use the following statement:

myRandom.Next() Mod dtData.RowCount

we just let us generate a more wide range of numbers and with the modulo operation we bring it to the restricted slot. When doing this we encountered a better distributed random result

1 Like

It worked. Thank you.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.