SRL Archive - Help and Support

Common random numbers


Krazy_Meerkat

2006-03-21 21:52:06

I've been doing a lot of testing with random numbers lately and I keep noticing the same ones over and over. Sometimes the same supposedly "random" number will be repeated 3 times in a row.
Ones I have noticed with the script I'll show you are 46/47, 62/63, 78, 31/32, 15/16, 9 (the ones in bold show up more often).
It's not just the particular formula I use either, I've noticed them while using kane and lorax's scripts.
I think there could be one of several reasons for this occuring:
1. True random numbers are generated by noise, and it could just be the noise levels at my house.
2. SCAR's system for random numbers is too basic (causing limited variance for random numbers)
3. I'm using this piece of code to determine the time values:
a:= getsystemtime
writeln(inttostr(getsystemtime - a));
So the commands might only get used at those times or something like that.

Here is the script I was working on when I noticed these numbers:
program New;

procedure chancewait(Normalwait : Integer);
var
render,i,lerngth : Integer;
begin
render:= 0;
i:= 0;
if (random(100) < 5) then
begin
wait((Normalwait * 2) + (random(Normalwait div 2) + 1));
end else
begin
if(length(inttostr(Normalwait)) <= 2)then
begin
lerngth:= 0;
end else
lerngth:= 1;
repeat
render:= render + random(Normalwait div (random(Normalwait div 10) + 1))+1;
i:= i + 1;
if(i > 10)then
render:= random(Normalwait div (random(Normalwait div 10) + 1))+1;
until(render < (Normalwait div 2))and(length(inttostr(render))>lerngth)and(i>(3 + random(5)))
render:= Normalwait + render
wait(render);
end;
end;

var
a : Integer;
begin
a:= getsystemtime
chancewait(500);
writeln(inttostr(getsystemtime - a));
end.
The more you run it, the more you start to notice these numbers. Something is giving an error here or we have been left wide open to jagex.

Edit: I've been doing some testing and it seems that the amount of time waited for (using the wait command) will not always be the same as the random number worked out.
It seems as if whatever time you tell SCAR to wait, the actual time waited will be rounded to one of these numbers.
Try this script:
program New;
var
a : Integer;
begin
a:= getsystemtime
Wait(75);
WriteLn('ms = ' + IntToStr(getsystemtime - a));
end.

Do it a couple of times and you will notice our friend, 78 will come up most times but, sometimes it will be mr. 62 or 63.
From: results
Successfully compiled
ms = 78
Successfully executed
Successfully compiled
ms = 78
Successfully executed
Successfully compiled
ms = 78
Successfully executed
Successfully compiled
ms = 78
Successfully executed
Successfully compiled
ms = 63
Successfully executed

This is an example I got while waiting 75ms, if you know maths then you will know that 4 * 78 + 63 is the same as 75 * 5

This means that the numbers may be balanced out at a certain point.. Could this be to our advantage?
Kait made this program himself, do you think he put this mechanism in there to make our scripts more random than even we knew?
I've been doing some experimenting and I've found that the base for all waits is either a 15 or a 16 ms wait. Combined they make all of the numbers we've been seeing. (In other words, every wait possible is a combination of 15's and 16's).
I understand that CPU speed will affect how long the waits actually last (except when the speed is above a certain amount).

This could also be our downfall.. All SCAR users will wait at least 15/16ms if the wait is low. However the wait is corrected at a later stage in the waiting period.
This is not possible for some reason = [false hopes]The minimum waiting period before we can make completely random waits (like actually waiting 1001) is 225ms, or 15sqr. Then it is possible to have any wait time to within the ms (a combination or 15's and 16's will make this possible).[/false hopes]
From: wait of 225
Successfully compiled
ms = 234
Successfully executed
Successfully compiled
ms = 234
Successfully executed
Successfully compiled
ms = 219
Successfully executed



If a Fakawi or someone thinks this should be deleted in case jagex does not know our weakness, just say so.

If you are experiencing something similar and it's not just me then start typing a reply. If it is just me then :/

XxKanexX

2006-03-21 23:53:39

I just wrote this to test, it dosn't bring up the same numbers frequently. It's actually very rare to get the same numbers:


procedure TestTimes(time: integer);
var
i, e, tot, a: integer;
begin
i:= random(time+(random(time/2)));
repeat
for a:= 1 to 5 do
e:= e + (random(time*2+(random(time/4)))/2);
until(i <> e);
tot:= (i+random((i+e)/2))+(e+random(e+i/2)) + random(i*e/4);
while(tot > time * 4)do
tot:= tot/2+random(5)-random(5);
if(tot mod 2 = 0)then
tot:= tot + random(tot/2+random(tot/4))+random(5)+1;
//wait(tot);

writeln(inttostr(tot));
end;

var
i: integer;
begin
Cleardebug;
for i:= 1 to 50 do
TestTimes(2000);
end.

The Un-Named

2006-03-22 00:20:54

I've never tested it before, but do a movemousesmooth(random(x), random(y)) on a paint document and hold the mouse down. Same pattern alot of the time.

XxKanexX

2006-03-22 00:26:21

Try this. If it's not random, I don't know what is. :S


function RandomRandom(time: integer): integer;
var
a: integer;
begin
for a:= 1 to 4+(((random(3)+1)+1)/2) do
begin
result:= result + random(time/(4+random(2)+1));
if(result > (time*4))then
break;
end;
end;

function RTimeR(time: integer): integer;
var
i, e, tot, a: integer;
begin
i:= RandomRandom(time+(RandomRandom(time/2)));
repeat
for a:= 1 to 5 do
e:= e + (RandomRandom(time*2+(RandomRandom(time/4)))/2);
until(i <> e);
tot:= (i+RandomRandom((i+e)/2))+(e+RandomRandom(e+i/2)) + RandomRandom(i*e/4);
while(tot > time * 4)do
tot:= tot/2+RandomRandom(5)-RandomRandom(5);
if(tot mod 2 = 0)then
tot:= tot + RandomRandom(tot/2+RandomRandom(tot/4))+RandomRandom(5)+1;
result:= tot/2+RandomRandom(tot/8+1)-RandomRandom(20)+1;
result:= result+(tot/2)+(RandomRandom(20)+1-RandomRandom(20)+1/2)
result:= result/(4+random(8));
end;

procedure RWait2(time: integer);
var
i, e, tot: integer;
begin
for i:= 1 to time/2+(RandomRandom(5)+1)*2+RandomRandom(3)+1 do
tot:= tot + RandomRandom(RandomRandom(RandomRandom(time/(2+RandomRandom(2)+1))/2+(RandomRandom(2)+1))/4+(RandomRandom(4)+1));
tot:= tot - RandomRandom(tot/(tot-RandomRandom(30)+5));
if(tot mod 2 = 0)then
tot:= tot/(RandomRandom(2)+1+RandomRandom(5));
tot:= tot/(RandomRandom(4)+1)
writeln(inttostr(tot));
end;

procedure rWait(ms: integer);
var
i, diva, a: integer;
begin
a:= getsystemtime;
if(ms <= 0)then
ms:= 5;
diva:= ms div(ms div(random(ms div(ms div(ms-(ms-random(ms+1 div 2))+1)+1)+1)+1)+1);
if(diva <= 0)then
diva:= ms/((ms/4)+1);
for i:= 1 to diva do
begin
wait(ms/diva + random(diva));
if(random(100)+1 = random(100)+1)then
wait(diva + random(diva div 2));
if(trunc(getsystemtime-a) > ms * ((random(7)+2 + random(3)+1)/(random(2)+1)))then
break;
end;
if(trunc(getsystemtime-a) = ms)or
(trunc(getsystemtime-a) < ms + (ms/4+(random(3)+1)))then
wait(random(ms));
end;

procedure MRWait(time: integer);
var
tot: integer;
begin
tot:= time/(2+RandomRandom(3)+1);
if(tot < time*2+RandomRandom(4)+1)then
tot:= tot*2-RandomRandom(tot*2-(tot*2));
if(tot mod 2 = 0)then
tot:= tot + ((RandomRandom(tot*2)*(RandomRandom(2)+1)*2+RandomRandom(2)+1)/2)
else
tot:= tot+(RandomRandom(time/4+1)/2)-RandomRandom(RandomRandom(time+4+RandomRandom(2)+1/4));
if(random(100)+1 = random(100)+1)then
tot:= tot + (RandomRandom(100)+RandomRandom(100)-RandomRandom(50)-RandomRandom(60)+(1+RandomRandom(2)+1))/2;
tot:= tot * random(5)+1;
if(tot < time)then
tot:= tot * RandomRandom(5+(RandomRandom(5))+3+RandomRandom(3)+1);
if(tot <= 0)then
tot:= time*(time/(RandomRandom(6)+2))+1;
while(tot > time*(5+random(3)+1))do
tot:= tot/2-randomrandom(randomrandom(10+random(100+random(20+random(50)))));
RWait(tot+RandomRandom(tot/2+(random(2)+1)));
end;

var
i,a: integer;
begin
Cleardebug;
a:= getsystemtime;
MRWait(200);
writeln(floattostr(getsystemtime-a));
end.

XxKanexX

2006-03-22 01:00:37

Sorry for the double post, But i was able to also Combine Lorax's into it. It's 1 huge mega random thing. :o It has like a 1 second delay because of all the procedures and functions that go through everything, but that could also be good for random-ness?

Pretty efficent and waits are very random.

EDIT: NEW WAIT, AGAIN.


Function RandomRandom(time: integer): integer;
var
a: Integer;
begin

for a:= 1 to 4+(((random(3)+1)+1)/2) do
begin
Result:= result + random(time/(4+random(2)+1));
if(Result > (time*4))then
Break;
end;

end;

Function RTimeR(time: integer): integer;
var
i, e, tot, a: Integer;
begin
i:= RandomRandom(time+(RandomRandom(time/2)));

repeat
for a:= 1 to 5 do
e:= e + (RandomRandom(time*2+(RandomRandom(time/4)))/2);
until(i <> e);

tot:= (i+RandomRandom((i+e)/2))+(e+RandomRandom(e+i/2)) + RandomRandom(i*e/4);

while(tot > time * 4)do
tot:= tot/2+RandomRandom(5)-RandomRandom(5);

if(tot mod 2 = 0)then
tot:= tot + RandomRandom(tot/2+RandomRandom(tot/4))+RandomRandom(5)+1;

Result:= tot/2+RandomRandom(tot/8+1)-RandomRandom(20)+1;
Result:= Result+(tot/2)+(RandomRandom(20)+1-RandomRandom(20)+1/2)
{}Result:= Result/(4+random(8));

end;

Procedure RWait2(time: integer);
var
i, e, tot: Integer;
begin

for i:= 1 to time/2+(RandomRandom(5)+1)*2+RandomRandom(3)+1 do
tot:= tot + RandomRandom(RandomRandom(RandomRandom(time/(2+RandomRandom(2)+1))/2+(RandomRandom(2)+1))/4+(RandomRandom(4)+1));

tot:= tot - RandomRandom(tot/(tot-RandomRandom(30)+5));

if(tot mod 2 = 0)then
tot:= tot/(RandomRandom(2)+1+RandomRandom(5));

tot:= tot/(RandomRandom(4)+1)

end;

procedure rWait(ms: integer);
var
i, diva, a: integer;
begin
a:= getsystemtime;

if(ms <= 0)then
ms:= 5;

diva:= ms div(ms div(random(ms div(ms div(ms-(ms-random(ms+1 div 2))+1)+1)+1)+1)+1);

if(diva <= 0)then
diva:= ms/((ms/4)+1);

for i:= 1 to diva do
begin
wait(ms/diva + random(diva));
if(random(100)+1 = random(100)+1)then
wait(diva + random(diva div 2));
if(trunc(getsystemtime-a) > ms * ((random(7)+2 + random(3)+1)/(random(2)+1)))then
break;
end;

if(trunc(getsystemtime-a) = ms)or
(trunc(getsystemtime-a) < ms + (ms/4+(random(3)+1)))then
wait(random(ms));

end;

procedure rWaitLor(ms, min: Integer); //Made By LORAX
var
i, tRan, tVal: Integer;
begin
if Length(IntToStr(ms)) > 1 then
tVal:= Round(Length(IntToStr(ms)) div 2.0)
else
tVal:= 1;
repeat
for i := 1 to tVal do
tRan := tRan + Random(ms div tVal) div 2;
tVal := Random(4);
if(tVal = 3)or(tVal = 2)then
tRan := tRan * -1;
until(ms + tRan >= min);
Wait(ms + tRan);
end;

function RandomizeRandom(time: integer): integer;
var
i: array[1..100] of integer;
a, e, c, tot: integer;
begin

for c:= 1 to 5 do
for e:= 1 to 10 do
for a:= 1 to 100 do
i[a]:= i[a]+(random(time/(a+1))+random(a*2)/2);

for a:= 1 to 100 do
begin
if(not a = 100)then
i[a]:= i[a]+random(i[a+1])
end;

for a:= 1 to 100 do
tot:= tot+i[a]+random(i[a]/(2+random(1)+1));

while(tot > time*10)do
tot:= tot/(random((2+random(2)*random(2)+1))+1);

result:= tot;
end;

procedure MRWait(time: integer);
var
tot, i: integer;
begin

tot:= time/(2+RandomRandom(3)+1);
if(tot < time*2+RandomRandom(4)+1)then
tot:= tot*2-RandomRandom(tot*2-(tot*2));

if(tot mod 2 = 0)then
tot:= tot + ((RandomRandom(tot*2)*(RandomRandom(2)+1)*2+RandomRandom(2)+1)/2)
else
tot:= tot+(RandomRandom(time/4+1)/2)-RandomRandom(RandomRandom(time+4+RandomRandom(2)+1/4));

if(random(100)+1 = random(100)+1)then
tot:= tot + (RandomRandom(100)+RandomRandom(100)-RandomRandom(50)-RandomRandom(60)+(1+RandomRandom(2)+1))/2;
tot:= tot * random(5)+1;

if(tot < time)then
tot:= tot * RandomRandom(5+(RandomRandom(5))+3+RandomRandom(3)+1);
if(tot <= 0)then
tot:= time*(time/(RandomRandom(6)+2))+1;

while(tot > time*(5+random(3)+1))do
tot:= tot/2-randomrandom(randomrandom(10+random(100+random(20+random(50)))));
if(random(2)+1 = 2)then
begin
tot:= tot - random(time)*(random(5)+1)/2+random(2)+1;
tot:= tot + random(time/4)*random(3)+1+random(2)+1;
end
else
begin
tot:= tot - random(time/2)*(random(5)+1)/2+random(2)+1;
tot:= tot + random(time/2)*random(2)+1+random(2)+1;
end;
for i:= 1 to random(5)+1 do
begin
if(random(20)+1 = random(20)+1)then
tot:= tot + (RandomizeRandom(time*2)/2)
else
if(tot > time + (random(time)*2))then
tot:= tot - (RandomizeRandom(time/2)/2);
end;


while(tot >= time*(40+random(10)+1))do
tot:= tot-(random(tot)*random(2)+1);

if(tot <= 0)then
begin
case random(2)+1 of
1:
Begin
RWait(Time);
Exit;
End;
2:
Begin
rWaitLor(Time, (time/2)+random(time*2));
Exit;
end;
end;
end;


RWait((tot+RandomRandom(tot/2+(random(2)+1)))/2-random(time/2));
if(random(2)+1 = 2)then
RWaitLor((tot+RandomRandom(tot/2+(RandomRandom(2)+1)))/2-random(time/2), ((time/2+(RandomRandom(2)+1)+(RandomRandom(time)*2+RandomRandom(2)+1)*2+RandomRandom(2)+1)/1+RandomRandom(3)+1))


if(random(50)+1 = random(50)+1)then
RWait2(random(time/(7+random(5)+1)));

end;

var
i,a: integer;
begin
Cleardebug;
a:= getsystemtime;
MRWait(200);
writeln(floattostr(getsystemtime-a));
end.

It will wait half of my divrand and the other half with lorax's. :)

Krazy_Meerkat

2006-03-22 02:02:50

I don't think you are getting the picture kane.. It's not how random the number is, it's how long SCAR actually waits for.
For a simple test (Which I assume you did not do) try this script:
program New;
var
a : Integer;
begin
a:= getsystemtime
Wait(75);
WriteLn('ms = ' + IntToStr(getsystemtime - a));
end.
For proof about the 15/16 ms wait, change the wait time to 15. I'm not sure how the wait is calculated in scar, but it's always rounded to the closest 15 or 16ms (sometimes rounded higher, sometimes lower, sometimes 15, sometimes 16).
I hope you're not taking any of this as rude (I don't mean to be), but I think this is a real problem. Eg. Jagex looks for all the waiting times of runescape users, here's one which always waits at a factor of 15 or 16, must be a scar user.. = banned
Or a script to raise the sus level the more they wait for factors of 15 or 16
if(suslevel>50)then
scar.user:= banned;

XxKanexX

2006-03-22 02:23:11

From: Krazy_Meerkat
I don't think you are getting the picture kane.. It's not how random the number is, it's how long SCAR actually waits for.
For a simple test (Which I assume you did not do) try this script:
program New;
var
a : Integer;
begin
a:= getsystemtime
Wait(75);
WriteLn('ms = ' + IntToStr(getsystemtime - a));
end.
For proof about the 15/16 ms wait, change the wait time to 15. I'm not sure how the wait is calculated in scar, but it's always rounded to the closest 15 or 16ms (sometimes rounded higher, sometimes lower, sometimes 15, sometimes 16).
I hope you're not taking any of this as rude (I don't mean to be), but I think this is a real problem. Eg. Jagex looks for all the waiting times of runescape users, here's one which always waits at a factor of 15 or 16, must be a scar user.. = banned
Or a script to raise the sus level the more they wait for factors of 15 or 16
if(suslevel>50)then
scar.user:= banned;


Oh, i see.. That's a very good concept Krazy :)

Krazy_Meerkat

2006-03-22 06:03:11

Thanks Kaney, you should probably delete this thread so that it's never seen again.
It wouldn't take long for jagex to do something about it if they found out. I wonder if someone (Probably Fawk) could ask Kait if he could fix the wait times for the next release (If he decides to make another release)

I actually typed this a few minutes after your reply but lost internet connection :(

XxKanexX

2006-03-22 06:15:31

From: Krazy_Meerkat
Thanks Kaney, you should probably delete this thread so that it's never seen again.
It wouldn't take long for jagex to do something about it if they found out. I wonder if someone (Probably Fawk) could ask Kait if he could fix the wait times for the next release (If he decides to make another release)

I actually typed this a few minutes after your reply but lost internet connection :(

I'll ask Kait for you.

Just tell me what you want asked? (In direct words) ;)

Krazy_Meerkat

2006-03-23 00:04:03

Whether he could do anything to make the wait times more accurate? It doesn't have to be my specific words, but you're aware this could cause problems for scar users so I think you'll know what to say.

maxzzz

2006-03-23 03:48:21

Could this be why I'm banned?

Krazy_Meerkat

2006-03-23 04:00:56

No. But Jagex may be able to take advantage of this information and ban all future scar users.

maxzzz

2006-03-23 04:35:47

Well i'm banned just 1 hour ago, my main was godlike: 1503 total and 45m total xp

Flyboy

2006-03-23 06:19:15

the answer is simple… scar's random wait is accurate, but not to the millisecond like you have been lead to believe, it is rounded up to the nearest 10Millisecond. I think this is a limitation in Pascal, not in SCAR. Java on the other hand had wait capabilities going down to the nano second. If anyone knows a pascal nano wait command, please tell as that would be the cure.

this is best illistrated by running this.


program WaitDemo;
var
a, b, i : Integer;
begin
Cleardebug;
for i := 0 to 50 do
begin
a:= getsystemtime;
wait(i);
b := getsystemtime;
WriteLn('wait(' + IntToStr(i) + ') takes: ' + IntToStr(b - a) + ' ms');
wait(1); //this is to eliminate writeln lag.
end;
end.
***EDIT***
Note removing getsystemtime from the writeln removes the 1 ms discrepency, the above script will always be right on the 10 ms mark.

XxKanexX

2006-03-23 06:42:29

From: Flyboy
the answer is simple… scar's random wait is accurate, but not to the millisecond like you have been lead to believe, it is rounded up to the nearest 10Millisecond. I think this is a limitation in Pascal, not in SCAR. Java on the other hand had wait capabilities going down to the nano second. If anyone knows a pascal nano wait command, please tell as that would be the cure.

this is best illistrated by running this.


program WaitDemo;
var
a, b, i : Integer;
begin
Cleardebug;
for i := 0 to 50 do
begin
a:= getsystemtime;
wait(i);
b := getsystemtime;
WriteLn('wait(' + IntToStr(i) + ') takes: ' + IntToStr(b - a) + ' ms');
wait(1); //this is to eliminate writeln lag.
end;
end.
***EDIT***
Note removing getsystemtime from the writeln removes the 1 ms discrepency, the above script will always be right on the 10 ms mark.

That's weird.
I got 30ms near 23. Interesting.

Krazy_Meerkat

2006-03-23 16:43:02

It may be different for all of our computer speeds, but here is my results:
wait(0) takes:  0 ms
wait(1) takes: 0 ms
wait(2) takes: 16 ms
wait(3) takes: 0 ms
wait(4) takes: 0 ms
wait(5) takes: 0 ms
wait(6) takes: 16 ms
wait(7) takes: 0 ms
wait(8) takes: 0 ms
wait(9) takes: 16 ms
wait(10) takes: 16 ms
wait(11) takes: 15 ms
wait(12) takes: 16 ms
wait(13) takes: 16 ms
wait(14) takes: 15 ms
wait(15) takes: 16 ms
wait(16) takes: 15 ms
wait(17) takes: 16 ms
wait(18) takes: 15 ms
wait(19) takes: 32 ms
wait(20) takes: 15 ms
wait(21) takes: 15 ms
wait(22) takes: 32 ms
wait(23) takes: 15 ms
wait(24) takes: 32 ms
wait(25) takes: 31 ms
wait(26) takes: 31 ms
wait(27) takes: 31 ms
wait(28) takes: 32 ms
wait(29) takes: 31 ms
wait(30) takes: 31 ms
wait(31) takes: 31 ms
wait(32) takes: 32 ms
wait(33) takes: 31 ms
wait(34) takes: 32 ms
wait(35) takes: 47 ms
wait(36) takes: 31 ms
wait(37) takes: 47 ms
wait(38) takes: 31 ms
wait(39) takes: 31 ms
wait(40) takes: 47 ms
wait(41) takes: 47 ms
wait(42) takes: 46 ms
wait(43) takes: 47 ms
wait(44) takes: 47 ms
wait(45) takes: 47 ms
wait(46) takes: 47 ms
wait(47) takes: 46 ms
wait(48) takes: 47 ms
wait(49) takes: 63 ms
wait(50) takes: 47 ms
Notice the common random numbers I was talking about? 15, 16, our old friend Mr. 47 :/
You can add 15 and 16 in different combinations to get any of the higher numbers. Please post your results everyone!

huh26010

2006-03-26 15:16:07

wait(0) takes:  0 ms
wait(1) takes: 0 ms
wait(2) takes: 0 ms
wait(3) takes: 0 ms
wait(4) takes: 0 ms
wait(5) takes: 0 ms
wait(6) takes: 16 ms
wait(7) takes: 15 ms
wait(8) takes: 0 ms
wait(9) takes: 16 ms
wait(10) takes: 15 ms
wait(11) takes: 16 ms
wait(12) takes: 16 ms
wait(13) takes: 15 ms
wait(14) takes: 16 ms
wait(15) takes: 16 ms
wait(16) takes: 15 ms
wait(17) takes: 16 ms
wait(18) takes: 31 ms
wait(19) takes: 16 ms
wait(20) takes: 15 ms
wait(21) takes: 32 ms
wait(22) takes: 15 ms
wait(23) takes: 15 ms
wait(24) takes: 32 ms
wait(25) takes: 15 ms
wait(26) takes: 16 ms
wait(27) takes: 31 ms
wait(28) takes: 31 ms
wait(29) takes: 31 ms
wait(30) takes: 32 ms
wait(31) takes: 31 ms
wait(32) takes: 31 ms
wait(33) takes: 31 ms
wait(34) takes: 32 ms
wait(35) takes: 47 ms
wait(36) takes: 31 ms
wait(37) takes: 47 ms
wait(38) takes: 31 ms
wait(39) takes: 47 ms
wait(40) takes: 47 ms
wait(41) takes: 31 ms
wait(42) takes: 47 ms
wait(43) takes: 47 ms
wait(44) takes: 47 ms
wait(45) takes: 46 ms
wait(46) takes: 47 ms
wait(47) takes: 47 ms
wait(48) takes: 47 ms
wait(49) takes: 47 ms
wait(50) takes: 46 ms