SCAR Code:
program New;
{.Include SRL\SRL\Extended\xColor.Scar}
{.Include SRL\SRL.Scar}
Function ArrayDifference(one, two:Array of Integer):Integer;
Var mylength, c, different:integer;
Begin
different:= 0;
mylength:= Min(GetArrayLength(one), GetArrayLength(two));
For c:=0 to (mylength - 1) Do
Begin
If(One[c] <> Two[c])Then
different:= different + 1;
End;
Result:= different;
End;
Function CameraMoving:Boolean;
Var
c, v:Integer;
SColor, FColor: Array [0..30] of Integer;
Begin
v:= 0;
For c:= 13 to 43 Do
Begin
SColor[v]:= GetColor(593, c);
v:= v + 1;
End;
Wait(100);
v:= 0;
For c:= 13 to 43 Do
Begin
FColor[v]:= GetColor(593, c);
v:= v + 1;
End;
If(ArrayDifference(SColor, FColor) > 5)Then
Begin
Result:= true;
End Else
Begin
v:= 0;
For c:= 13 to 43 Do
Begin
SColor[v]:= GetColor(686, c);
v:= v + 1;
End;
Wait(100);
v:= 0;
For c:= 13 to 43 Do
Begin
FColor[v]:= GetColor(686, c);
v:= v + 1;
End;
If(ArrayDifference(SColor, FColor) > 5)Then
Result:= true;
End;
End;
Function ShortWay(Direction:String):Boolean;
Var
QuadOne, QuadTwo, QuadThree, QuadFour:TPointArray;
GetMax: Integer;
Begin
FindColorsTolerance(QuadTwo, 920735, 552, 7, 566, 19, 80);
FindColorsTolerance(QuadOne, 920735, 566, 7, 579, 19, 80);
FindColorsTolerance(QuadThree, 920735, 552, 19, 566, 31, 80);
FindColorsTolerance(QuadFour, 920735, 566, 19, 579, 31, 80);//4341941}
{FindColorsTolerance(QuadTwo, 4341941, 552, 7, 566, 19, 80);
FindColorsTolerance(QuadOne, 4341941, 566, 7, 579, 19, 80);
FindColorsTolerance(QuadThree, 4341941, 552, 19, 566, 31, 80);
FindColorsTolerance(QuadFour, 4341941, 566, 19, 579, 31, 80);//4341941 }
GetMax := Max(Max(GetArrayLength(QuadOne), GetArrayLength(QuadTwo)),Max(GetArrayLength(QuadThree), GetArrayLength(QuadFour)));
Writeln('');
Writeln('Max: '+IntToStr(GetMax));
Writeln('One: '+IntToStr(GetArrayLength(QuadOne)));
Writeln('Two: '+IntToStr(GetArrayLength(QuadTwo)));
Writeln('Three :'+IntToStr(GetArrayLength(QuadThree)));
Writeln('Four: '+IntToStr(GetArrayLength(QuadFour)));
If(StrGet(Direction, 1) = 'n')Then
Begin
//Result:= ((GetArrayLength(QuadTwo) + GetArrayLength(QuadThree)) > (GetArrayLength(QuadOne) + GetArrayLength(QuadFour)));
If((GetMax = GetArrayLength(QuadTwo)) or (GetMax = GetArrayLength(QuadThree)))Then
Result:= true;
End Else
If(StrGet(Direction, 1) = 'e')Then
Begin
//Result:= ((GetArrayLength(QuadThree) + GetArrayLength(QuadFour)) < (GetArrayLength(QuadOne) + GetArrayLength(QuadTwo)));
If((GetMax = GetArrayLength(QuadThree)) or (GetMax = GetArrayLength(QuadFour)))Then
Result:= true;
End Else
If(StrGet(Direction, 1) = 'w')Then
Begin
//Result:= ((GetArrayLength(QuadOne) + GetArrayLength(QuadTwo)) < (GetArrayLength(QuadThree) + GetArrayLength(QuadFour)));
If((GetMax = GetArrayLength(QuadOne)) or (GetMax = GetArrayLength(QuadTwo)))Then
Result:= true;
End Else
If(StrGet(Direction, 1) = 's')Then
Begin
//Result:= ((GetArrayLength(QuadFour) + GetArrayLength(QuadOne)) > (GetArrayLength(QuadTwo) + GetArrayLength(QuadThree)));
If((GetMax = GetArrayLength(QuadOne)) or (GetMax = GetArrayLength(QuadFour)))Then
Result:= true;
End Else
Begin
Writeln('Compass direction must start with first letter "n", "e", "s", "w"');
Exit;
Result:= false;
End;
End;
Function FindCompassDirectionColors(Direction: String):Boolean;
Var c:integer;
Begin
If(StrGet(Direction, 1) = 'n')Then
Begin //bottom //west //east
If(FindColor(x, y, 920735, 564, 30, 569, 36) and FindColor(x, y, 920735, 546, 16, 556, 22) and FindColor(x, y, 920735, 576, 16, 584, 23))Then
Result:= True;
End Else
If(StrGet(Direction, 1) = 'w')Then
Begin
If(FindColor(x, y, 920735, 564, 30, 569, 36) and FindColor(x, y, 920735, 546, 16, 556, 22) and (Not (FindColor(x, y, 920735, 576, 16, 584, 23))))Then
Result:= True;
End Else
If(StrGet(Direction, 1) = 'e')Then
Begin
If(FindColor(x, y, 920735, 564, 30, 569, 36) and (Not (FindColor(x, y, 920735, 546, 16, 556, 25))) and FindColor(x, y, 920735, 576, 16, 584, 23))Then
Result:= True;
End Else
If(StrGet(Direction, 1) = 's')Then
Begin
If((Not (FindColor(x, y, 920735, 564, 30, 569, 36))) and FindColor(x, y, 920735, 546, 16, 556, 22) and FindColor(x, y, 920735, 576, 16, 584, 23))Then
Result:= True;
End;
End;
Function Compass(Direction: String):Boolean;
var
TheKey:Boolean;
Begin
Direction:= Lowercase(Direction);
TheKey:= ShortWay(Direction);
If(Not (FindCompassDirectionColors(Direction)))Then
Begin
If(TheKey)Then
Begin
KeyDown(VK_Right);
End
Else
Begin
KeyDown(VK_Left);
End;
Repeat
If( (Not (CameraMoving)) {and (Random(10) < 2)} and (Not (FindCompassDirectionColors(Direction))) )Then
Begin
ActivateClient;
TheKey:= ShortWay(Direction);
If(TheKey)Then
Begin
KeyDown(VK_Right);
End
Else
Begin
KeyDown(VK_Left);
End;
End;
Wait(1);
Until(FindCompassDirectionColors(Direction));
If(TheKey)Then
Begin
KeyUp(VK_Right);
End
Else
Begin
KeyUp(VK_Left);
End;
End;
End;
begin
SetupSRL;
ActivateClient;
Compass('n');
end.