SRL Archive - News and General

How random are your failsafes? [for scripters]


footballjds

2013-11-13 12:32:45

With recent runescape bans human-like scripts are more important than ever.

This advice is very simple, I hope most people already practice proper randomness in failsafes

I cannot count how many times I've seen the following code:


function openBank: boolean;
var
timerX: integer;
begin
timerX := getSystemTime+10000;
while timerX > getSystemTime and (not result) do
begin
Mouse(bankPoint, Mouse_Right, Mouse_Human);
result := chooseOption.select(['Use Bank'], 3000);
wait(randomRange(100, 400));
end;
end;
That looks pretty good right? We're trying to open the bank. We're waiting a random amount of time each loop to add randomness. If we can't open it within 10 seconds we give up. We also wait to "Use Bank" for 3 seconds without giving up.
This does function. However, imagine worst case scenario, imagine we fail. Then we'll be waiting almost exactly 3 seconds for chooseOption each time and we'll quit trying after almost exactly 10 seconds.

For obvious reasons this isn't optimal. The below is far more human IMHO:

function openBank: boolean;
var
timerX: integer;
begin
timerX := getSystemTime+randomRange(9000,15000);
while timerX > getSystemTime and (not result) do
begin
Mouse(bankPoint, Mouse_Right, Mouse_Human);
result := chooseOption.select(['Use Bank'], randomRange(2500,4000));
wait(randomRange(100, 400));
end;
end;

Tickyy

2013-11-13 12:56:55


The Killer

2013-11-13 12:58:39

It is more human like yes. In the past I wouldn't of bothered but bans are pretty ripe atm so very small things like this are important.
Do I do it? honestly? yes and No. I have random adds with my waits but I don't bother with loops like the ones provided (I will usually exit the loop upon it being successful and not ones with "and"). I do normally add random waits on my timeouts though

Kyle Undefined

2013-11-13 14:57:32

Yeah, I've always done my waits like that. Just keeps things a little more safe.

footballjds

2013-11-13 17:09:20

From: Kyle Undefined
Yeah, I've always done my waits like that. Just keeps things a little more safe.


I should hope you're doing it right!

Kyle Undefined

2013-11-13 19:12:10

From: footballjds
I should hope you're doing it right!


Ha, I suck at scripting.

footballjds

2013-11-14 11:17:48

From: Kyle Undefined
Ha, I suck at scripting.


that one script, what was it. For runespan? that was pretty intense

Kyle Undefined

2013-11-14 12:08:30

From: footballjds
that one script, what was it. For runespan? that was pretty intense


Ha, thanks, but @Ashaman88; helped with most of it. I setup the core, he did the rest really. Was too busy at work to do them.

Wanted Returns

2013-11-14 12:50:45

Is SRL utilizing Gaussian Variance with randomness?


Sjoe

2013-11-14 12:59:53

From: Wanted Returns
Is SRL utilizing Gaussian Variance with randomness?

Is that gaussbox? :confused:

Wanted Returns

2013-11-14 13:00:58

From: Sjoe
Is that gaussbox? :confused:


No… otherwise it wouldn't be circular…. the image file has to be square (unless I pulled up photoshop and did transparency etc.)

Sjoe

2013-11-14 13:01:49

From: Wanted Returns
No… otherwise it wouldn't be circular….


Thought the same technique or smthing used in gaussbox lol :p

Wanted Returns

2013-11-14 13:02:53

From: Sjoe
Thought the same technique or smthing used in gaussbox lol :p


There's also more simple uses for waiting etc.

footballjds

2013-11-14 16:21:21

From: Wanted Returns
There's also more simple uses for waiting etc.


random waits with gaus? huh

Wanted Returns

2013-11-14 16:40:34

From: footballjds
random waits with gaus? huh


For example

Random generates a number between A and B

It is likely to be any number between A and B equally

However say you wanted to disperse it in a way where it was centralized towards the center or some other value ;)

"Like throwing darts at a target" … 'humanly'…

footballjds

2013-11-14 17:00:10

From: Wanted Returns
For example

Random generates a number between A and B

It is likely to be any number between A and B equally

However say you wanted to disperse it in a way where it was centralized towards the center or some other value ;)

"Like throwing darts at a target" … 'humanly'…


right on!

My life dream(srl-forum/villavu life dream) has always been to play runescape with a video and mouse recorder for an hour, then try to replicate my style of playing.
I'd be interested in the gaus wait thingy tho

Ashaman88

2013-11-14 17:25:55

From: Kyle Undefined
Ha, thanks, but @Ashaman88; helped with most of it. I setup the core, he did the rest really. Was too busy at work to do them.


It's all about that teamwork ;)


And nice pointers football and wanted

Olly

2013-11-14 17:39:52

wait(gaussRangeInt(5000, 10000)); done.


program new;

{$i srl-6/srl.simba}

const
HIGH = 1000;
TRIES = 120000;

var
bmp: integer;
t, i, del: integer;

begin
bmp := createBitmap(1001, 500);

getMufasaBitmap(bmp).lineTo(point(0, 250), point(1000, 250), clRed);
getMufasaBitmap(bmp).drawText('0', point(0, 100), bigChars, true, clRed);
getMufasaBitmap(bmp).drawText(toStr(HIGH), point(930, 100), bigChars, true, clRed);

for i := 0 to tries do
begin
t := gaussRangeInt(0, HIGH);

if (fastGetPixel(bmp, t, 250) = clLime) then
begin
del := 0;
repeat
inc(del);

if (fastGetPixel(bmp, t, 250 - del) <> clLime) then
begin
fastSetPixel(bmp, t, 250 - del, clLime);
break;
end;

if (fastGetPixel(bmp, t, 250 + del) <> clLime) then
begin
fastSetPixel(bmp, t, 250 + del, clLime);
break;
end;
until false;
end else
fastSetPixel(bmp, t, 250, clLime);
end;

debugBitmap(bmp);
end.

Wanted Returns

2013-11-14 18:07:01

Why not just put that into the base SRL with optional Defines etc. so that it applies to the entire include etc.

https://github.com/OSI1/OfficialSCARInclude/blob/master/Divi/TFunctions/Integer.scar#L93

Olly

2013-11-14 18:45:20

We could do, since we can override it would be great.


function randomRange(const aFrom, aTo: integer): integer; override;
begin
{$IFDEF GAUSS}
result := gaussRangeInt(aFrom, aTo);
{$ELSE}
inherited(aFrom, aTo);
{$ENDIF}
end;

Wanted Returns

2013-11-14 18:48:21

From: Olly
We could do, since we can override it would be great.


function randomRange(const aFrom, aTo: integer): integer; override;
begin
{$IFDEF GAUSS}
result := gaussRangeInt(aFrom, aTo);
{$ELSE}
inherited(aFrom, aTo);
{$ENDIF}
end;


Yes but then you wouldn't be able to switch back and forth at will?

Olly

2013-11-14 19:19:52

From: Wanted Returns
Yes but then you wouldn't be able to switch back and forth at will?


Could do the same with a global var i guess.

Wanted Returns

2013-11-14 19:21:03

From: Olly
Could do the same with a global var i guess.


I wouldn't recommend using global variables for anything unless you have to.

Olly

2013-11-14 19:59:34

From: Wanted Returns
I wouldn't recommend using global variables for anything unless you have to.


Okay then we'd have you go down an extra parameter line, randomRange(s, e: integer; gaussian: boolean = false) or something.

Wanted Returns

2013-11-14 20:12:13

From: Olly
Okay then we'd have you go down an extra parameter line, randomRange(s, e: integer; gaussian: boolean = false) or something.


No.. I'd do it the way I have it in OSI.

{$DEFINE NoVariance} etc… to override and disable it

or override it case by case simply by using RandomRange instead of RR…

footballjds

2013-11-15 01:27:23

If you don't want the middle to be more probable?

bonsai

2013-11-15 08:30:40

From: Olly
Okay then we'd have you go down an extra parameter line, randomRange(s, e: integer; gaussian: boolean = false) or something.


This seems like a nice option to me. Better than having two different function names.