PsyOps

WeighedRandom

Jan 21st, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.41 KB | None | 0 0
  1. // Random system class
  2. Random ran = new Random();
  3.  
  4. // Array of ranges to enter for random max index
  5. int[] ListOfMaxRanges = new int[] {5,5,5,5,5,5,5,5,5,5,10,10,10,10,20,20,20,50,50,100};
  6. // get a random MaxIndex number from the array ListOfMaxRanges
  7. int MaxRange = ListOfMaxRanges[ran.Next(ListOfMaxRanges.Length)];
  8. // Insert my max range to get final number
  9. int MyWeighedRandomNumber = ran.Next(MaxRange);
Advertisement
Add Comment
Please, Sign In to add comment