SRL Archive - SRL Archives

Function Modulation(range:Integer):Boolean;


1337_macro

2006-09-30 03:27:00

I know i dont contribute much to srl or its members but this is too big to pass up.


Ok i was reading a news article about how computer launguages do not have true random funtions rather Psudo-Random funtions. I became interested in it and i made a simple script to test a random number and print the findings. Well i did and i ran it through a program that finds patterns in things and low and behold it found a pattern. That peaked my curiosity because i believe that jagex could use this to catch us because the longer a script runs (1 hour+) the better apparent the pattern becomes (no im not crazy!). Well i got to reading and Pascal uses a complex algorithm called the "Wichmann-Hill psudo-random number algorithm" this a pattern that is made to look random but is actually not random at all (especially on small numbers)…Well i did nothing about it for 2 weeks. Then i mentioned it to MadCow about it not being random and he became interested and asked me what solution did i have. I didnt have anything at the time but i do now. Here it is




Function Modulation(range:Integer):integer;
Var
A, B, E, F, Modulated:Integer;
C, D:Extended;
Modded:Boolean;
Begin
Result := 0;
repeat
A:=RanDom(Range)
B:=RanDom(Range)
C:=Sqrt(A)+(Random(Range))
D:=Sqrt(b)+(Random(Range))
E:=Random(Trunc(C))
F:=Random(Trunc(D))
If(not SameValue(E,F))then
Begin
If (E+F<=Range) then
Modulated:=(E+F)
Modded:=true
End;
until(Modded=True)
Result := modulated;
End;


Flyboy

2006-09-30 08:35:54

I think I missed the point…. Shouldn't this function return a random number???

program New;
Function Modulation(range:Integer):Boolean;
Var
A, B, E, F:Integer;
C, D:Extended;
Begin
Result := False;
repeat
A:=RanDom(Range);
B:=RanDom(Range);
C:=Sqrt(A)+(RanDom(Range));
D:=Sqrt(b)+(RanDom(Range));
E:=Random(Trunc(C));
F:=Random(Trunc(D));
if(not SameValue(E,F)) then
begin
If (E + F <= Range) then
begin
result := true;
end;
End;
until result;
end;

var
Range, yes, no: Integer;
begin
Range := Round(strtoint(Readln('Input range')));
repeat
if Modulation(Range) then
yes := yes + 1
else
no := no + 1;
writeln('yes: ' + inttostr(yes) + ' No: ' + inttostr(no));

until (IsKeyDown('q') or IsKeyDown('Q'));
end.

1337_macro

2006-09-30 11:02:02

Ya mine does return a random number…Maybe im not getting what u mean

Yakman

2006-09-30 13:50:20

ok i get what you mean,

pascal random isnt accutaly random,

and you've writen a function which proves they are not random

so, maybe we should use this instead of random(range:integer):integer

Flyboy

2006-09-30 16:52:43

From: 1337_macro
Ya mine does return a random number…Maybe im not getting what u mean

Please dont play games with me… Don't edit your post and then reply as if I was dumb and mistook your function to return a boolean when it always was an integer… (at least you should have edited the subject as well)

The point you are making could be very valid and deserves more investigation.

EDIT:
Here is a tester I developed to test your function… just run it and it will compare your function agains Random()

Yakman

2006-09-30 17:06:22

Haha, i was about to write something else before i saw he changed it to a integer

i was going to write "yeah you've proved pascal random isnt random, but why should the function that proves it go into SRL?"

Sumilion

2006-09-30 17:10:35

Lol, thats a good joke :p, sorry Flyboy :)

1337_macro

2006-09-30 17:27:56

This funtion does not prove its not random but it actually makes as close as to a random number as possible… the program i wrote proved that after 2 hours of running it didnt find a patteren whiich is ALOT better than the half hour it took the "random" funtion in scar to find a pattern.


AGAIN NoTE: THIS PRODUCES MORE OF A RANDOM NUMBER THAN SCARS "RANDOM" FUNTION

Yakman

2006-09-30 17:36:05

well ok i'll start again, the current function returns a random number thats more random than the pascal random

the functon that was up an hour ago, returned a boolean, i didnt get a good look at it but im assuming that it returned true when a pattern was found in the normal random function

however assumtions are the mother of all fuck-ups so please tell me what it was accturally for note:im talking about the boolean returner here

WhiteShadow

2006-09-30 17:50:23

From: Yakman
well ok i'll start again, the current function returns a random number thats more random than the pascal random

the functon that was up an hour ago, returned a boolean, i didnt get a good look at it but im assuming that it returned true when a pattern was found in the normal random function

however assumtions are the mother of all fuck-ups so please tell me what it was accturally for note:im talking about the boolean returner here


He made a mistake when he made it return a boolean.

Yakman

2006-09-30 17:55:18

From: WhiteShadow
He made a mistake when he made it return a boolean.


im sorry i dont belive that, any scripter would run their function at least once and find the debug log said "faliure when compiling - type mismatch in script"

because like it or not
  
Modulated:=(E+F)

Result := modulated;

returns a integer, Not a boolean

also when he edited it, why didnt he say something like "sorry i made a mistake, its integer not boolean" now that doesnt prove it, but its a little suspitious to me…

WhiteShadow

2006-09-30 17:59:11

From: Yakman
im sorry i dont belive that, any scripter would run their function at least once and find the debug log said "faliure when compiling - type mismatch in script"

because like it or not
  
Modulated:=(E+F)

Result := modulated;

returns a integer, Not a boolean

also when he edited it, why didnt he say something like "sorry i made a mistake, its integer not boolean" now that doesnt prove it, but its a little suspitious to me…


Yea now it retuns an Integer. It use to not be Result:= Modulated. Why would you get a type mismatch….

function idongetit : Boolean; 
begin
Result:= True;
end;

He did it like that. Type boolean return boolean. Then he changed it to type return integer.

I guess he edited and didn't say anything, because he was hoping nobody noticed his awkward mistake. Maybe he didn't even know what he was doing then he realized it.

Yakman

2006-09-30 18:04:34

im sure he would have done something like


writeln(inttostr(modulation(10)))
when he finished it, to make sure it returned something different

WhiteShadow

2006-09-30 18:17:02

random(1); in Scar always returns 0 I think. Has anyone else noticed that before?

Flyboy

2006-09-30 18:19:37

did anyone try out the tester script I wrote?

Just download it and let it run for a while… if you enter 5 in the Range window that pops up it will then test his function and compare it to the normal Random() function. it displays each number from 0 to the number you entered in the range and give the percentage of times it was picked. If its a perfect random number it will be equally appearing as each of the optional numbers. So if you put 5 in the range you should get
0 - 20%
1 - 20%
2 - 20%
3 - 20%
4 - 20%
5 - 0%

The longer you let it run the more accurate it will be.

WhiteShadow

2006-09-30 18:20:57

I'll give it a try. One sec.

Clear differences. This is cool.

Number and percentage of occurancs in a sample of 43998
Number Modulation(Range) Random(Range)
0 4 20
1 33 20
2 20 20
3 23 20
4 12 20
5 8 0

1337_macro

2006-09-30 19:14:44

Dude omg JUST BECAUSE I MESS UP A TITLE I GET SHIT ON FOR TRYING TO HELP OUT…i didnt change my post at all….just because i accadently messed up on my title doesnt mean i changed anything….guys just accept this funtion for what it is…a more random funtion than srl's random….

Flyboy

2006-10-01 01:28:26

Macro, don't take it too personal… there is two issues being discussed here
1. why isn't your first post the same as it originally was?
2. Is the issue you brought up regaurding randoms being non-random valid, and if so what can be done about it.

so…
1. My style in life is to give everyone I meet an initial chunk of trust and respect and leave it up to them to prove themselves worthy of my trust. Having said that, since you say you did not edit your post I will accept that at face value. There is the posibility that someone else has messed pulled a little joke here at your expence. Since your post does not say it was edited that would be evidence toward that theory.

2. I don't want to be the one to come to the conclution of weather or not your function gives better results or not… that's why I made the tester script so everyone can draw thier own conclutions. I can state the characteristics of a perfectly random number…
a. there is an equal chance at any one given instance of any of the options happening (if you flip a coin ther is always a 50% chance of it being heads and a 50% chance of it being tails.
b. If you record the flips of a coin a LARGE number of times you will find that 50% of all the flips were heads and 50%was tails.

Run the tester script and decide which method meets these criteria.

1337_macro

2006-10-01 01:48:21

Omg i never edited my post but 5 minutes after i posted last night to return a integer instead of a boolean…big deal i messed up…so what?

What ur seeming not to understand is with a large enough sample its not how much its spread out but what is the pattern…ill give a example


122211221112 easy to see pattern right? but thats 50% 1 and 50% 2


2212112111212 not much of a patteren there but its still 50% 1 and 50% 2….

i dont care how well they are spread out….what i care about is how much of a patteren emerges after a average script run…

there is a vary noticable patteren in the random after 1 hour….but with my thing there is a significant decline in pattern distribution….

WhiteShadow

2006-10-01 03:29:11

I think 1337_Macro's function is more "random" than "random(range : Integer);" . :D

Well it doesn't show that he edited his post on the bottom that is good proof. But even if he did edit, we can just keep that to ourselves.Happy Happy. Nich is a happyboy. lalalala . xP

:cartman: :bart: :f:

Pmg, that sounds so gay. ^^ Haha. xP

1337_macro

2006-12-03 13:11:28

Thanks whiteshadow…sorry i havent been on to read this…been in the hospital… anyone who wants to contact me can contact [email]1337_macro@fagex.net[/email]

Dub

2006-12-03 13:20:49

I think this should be put in the next version of SRL, defo.
Why?
This function creates a less detectable random function. Therefore Jagex will find out we are autoing less quick, and we get advantage out of it.
Now lets get the common sense part to work. If something new is better than the original thing, whatever it is, shouldn't the original be replaced with something better? For example, if we find a new medicine which is proven to be better than the current Aspirine, shouldn't we use the new medicine?
Just use your common sense, and put this into SRL!
Thanks for reading :p
~Dub.