Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- integer tests = 100;
- integer max = 2;
- integer min = 0;
- list distribution;
- integer random(integer min, integer max)
- {
- key id = llGenerateKey();
- string subid = "0x" + llGetSubString((string)id, -8, -1);
- string subid2 = "0x" + llGetSubString((string)id, 0, 7);
- string subid3 = "0x" + llGetSubString((string)id, -12, -9);
- integer int = llAbs((integer)subid ^ (integer)subid2 ^ (integer)subid3);
- string ints = "0." + llGetSubString((string)int, -7, -1);
- integer rand = (integer)(max*((float)ints));
- return min + rand;
- }
- init()
- {
- integer i;
- for(i = 0; i < max; i++)
- {
- distribution += [0];
- }
- }
- run()
- {
- llOwnerSay("////////////");
- integer i;
- for(i = 0; i < tests; i++)
- {
- integer rand = random(min, max);
- integer total = llList2Integer(distribution, rand) + 1;
- distribution = llListReplaceList(distribution, [total], rand, rand);
- llOwnerSay((string)rand);
- }
- for(i = 0; i < max; i++)
- {
- llOwnerSay((string)i + ": " + (string)llList2Integer(distribution, i));
- }
- }
- default
- {
- state_entry()
- {
- init();
- }
- touch_start(integer num)
- {
- run();
- llResetScript();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement