Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. integer tests = 100;
  2. integer max = 2;
  3. integer min = 0;
  4.  
  5. list distribution;
  6.  
  7. integer random(integer min, integer max)
  8. {
  9.         key id = llGenerateKey();
  10.         string subid = "0x" + llGetSubString((string)id, -8, -1);
  11.         string subid2 = "0x" + llGetSubString((string)id, 0, 7);
  12.         string subid3 = "0x" + llGetSubString((string)id, -12, -9);
  13.         integer int = llAbs((integer)subid ^ (integer)subid2 ^ (integer)subid3);
  14.         string ints = "0." + llGetSubString((string)int, -7, -1);
  15.         integer rand = (integer)(max*((float)ints));                
  16.  
  17.         return min + rand;
  18. }
  19.  
  20. init()
  21. {
  22.     integer i;
  23.     for(i = 0; i < max; i++)
  24.     {
  25.         distribution += [0];
  26.     }    
  27. }
  28.  
  29. run()
  30. {
  31.     llOwnerSay("////////////");
  32.     integer i;
  33.     for(i = 0; i < tests; i++)
  34.     {
  35.         integer rand = random(min, max);
  36.         integer total = llList2Integer(distribution, rand) + 1;
  37.         distribution = llListReplaceList(distribution, [total], rand, rand);
  38.        
  39.         llOwnerSay((string)rand);    
  40.     }
  41.    
  42.    
  43.     for(i = 0; i < max; i++)
  44.     {
  45.         llOwnerSay((string)i + ": " + (string)llList2Integer(distribution, i));
  46.     }    
  47. }
  48.  
  49. default
  50. {
  51.     state_entry()
  52.     {
  53.         init();
  54.     }
  55.    
  56.     touch_start(integer num)
  57.     {
  58.         run();
  59.         llResetScript();
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement