SRL Archive - Discussions and Debates

Improve fail safes.


Wanted

2007-12-26 14:13:51

Look at this simple Examine Coal script.

program ExamineCoal;

{.Include SRL\SRL.SCAR}

procedure SetUpScript;
begin
SetUpSRL;
ClearDeBug;
FindRS;
ActivateClient;
Wait(2000);
end;

function ExamineCoal: Boolean;
var
EC: TPoint;
DTMCoal: LongInt;
FindTrys, UpTextTrys, ExamineTrys: Byte;
begin
DTMCoal := DTMFromString('78DA630C6662609066644006FA7AF20CFF813448F43F10300602D5F0A1AA81C8C248209D04542346404D2C508D3201350140359A04D4B800D5C81150E30554238A5F0D007EE308A0');
for FindTrys := 1 to (3 + Random(3)) do
begin
if (FindDTM(DTMCoal, EC.X, EC.Y, MIX1, MIY1, MIX2, MIY2)) then
begin
for UpTextTrys := 1 to (3 + Random(3)) do
begin
MMouse(EC.X, EC.Y, 5, 5);
Wait(200 + Random(100));
if (IsUpText('Coal')) then
begin
GetMousePos(EC.X, EC.Y);
for ExamineTrys := 1 to (2 + Random(2)) do
begin
Mouse(EC.X, EC.Y, 0, 0, False);
Wait(200 + Random(100));
if (ChooseOption('Examine')) then
begin
Wait(1000 + Random(500));
if (InChat('non-renewable')) then
begin
Result := True;
WriteLn(' Chat box text found, examination confirmed!');
FreeDTM(DTMCoal);
Exit;
end
else
WriteLn(' Did not find chat box text.');
end
else
WriteLn(' Try : ' + IntToStr(ExamineTrys) + '. Did not find choose option selection.');
end;
end
else
WriteLn(' Try : ' + IntToStr(UpTextTrys) + '. Did not find "IsUpText" in the upper left corner.');
end;
end
else
WriteLn(' Try : ' + IntToStr(FindTrys) + '. Did not find coal.');
end;
WriteLn('All attempts failed, logging...');
FreeDTM(DTMCoal);
LogOut;
end;

begin
SetUpScript;
if (not (ExamineCoal)) then
WriteLn('function ExamineCoal: Boolean; returned: False.');
end.

I was making a tutorial and when I got the fail safes portion of the tutorial I got bored and spent a few hours figuring out how to make the best possible fail safe with out going overboard or anything.

I think what I'm trying to show everyone is just the general concept of having multi-steps here, then repeating them a random number of times if they fail just like a human would.

Any ideas?

Wanted

2009-07-16 07:36:12

Massive grave dig, but does anyone like this concept?

Infantry001

2009-07-16 08:34:01

Well, technically, those aren't failsafes. Just the same steps repeated three times.

For real failsafes, you'd probably have to solve the same problem with a different method.

For example, take banking. If you can't find the bankbooth, maybe you could then try to find the banker on the MS. If you can't find them, maybe move close to them by finding the banker dots on the MM. Then repeat, and see if you have any luck. Something like that ;)

senrath

2009-07-16 09:05:40

From: Infintry001
Well, technically, those aren't failsafes. Just the same steps repeated three times.



Repetition can be a failsafe. A failsafe is just something that is triggered when an initial attempt fails. Repeating the initial attempt certainly counts as a failsafe, as the repetition is only triggered in the event of failure in the initial attempt.

Infantry001

2009-07-16 18:26:08

From: senrath
Repetition can be a failsafe. A failsafe is just something that is triggered when an initial attempt fails. Repeating the initial attempt certainly counts as a failsafe, as the repetition is only triggered in the event of failure in the initial attempt.


I supposed that can be true, but when something fails (multiple times), then you should move on to other methods.

Wanted

2009-07-16 19:51:29

From: Infintry001
I supposed that can be true, but when something fails (multiple times), then you should move on to other methods.


This is a good point… I need to explain this in my tutorial.

Thanks senrath/infintry

Infantry001

2009-07-16 20:01:59

No problem, always glad to help =)