SRL Archive - Test corner

FindNormalRoadColor; and FindFaladorRoadColor;


_ChArMz

2007-06-12 21:30:13

program New;

function NumberDoesntExist(Ar2 : array of Integer; Number : Integer) : Boolean; //By Wizzup?
var
i : Integer;
begin
Result := False;
for i := 0 to GetArrayLength(Ar2) - 1 do
if Ar2[i] = Number then
Exit;
Result := True;
end;

function ShrinkArray(YourArray : array of Integer) : array of Integer; //By Wizzup?
var
i : Integer;
begin
SetArrayLength(Result, 0);
for i := 0 to GetArrayLength(YourArray) - 1 do
begin
if NumberDoesntExist(Result, YourArray[i]) Then
begin
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[GetArrayLength(Result) - 1] := YourArray[i];
end
end
end;

function FindNormalRoadColor : Integer;
var
tRoadPoints, RoadPoints : TPointArray;
RoadColors : TIntegerArray;
i, c : Integer;
Hue, Sat, Lum : Extended;
begin
FindColorsTolerance(tRoadPoints, 5987170, MMX1, MMY1, MMX2, MMY2, 60);
for i := 0 to GetArrayLength(tRoadPoints) - 1 do
if rs_OnMiniMap(tRoadPoints[i].x, tRoadPoints[i].y) then
begin
c := c + 1;
SetArrayLength(RoadPoints, c + 1);
RoadPoints[c] := tRoadPoints[i];
end
RoadColors := ShrinkArray(GetColors(RoadPoints));
for i := 0 to GetArrayLength(RoadColors) -1 do
begin
ColorToHSL(RoadColors[i], Hue, Sat, Lum);
if (Hue = 0) or (Hue > 85.0) or (Hue < 7.0) and
(Sat > 1.0) and (Sat < 6.0) then
begin
if CountColor(RoadColors[i], MMX1, MMY1, MMX2, MMY2) > 100 then
begin
Result := RoadColors[i];
Break;
end
end
end
if Result > 0 then
WriteLn('RoadColor = '+IntToStr(Result))
else
WriteLn('Unable to find road color.');
end;

function FindFaladorRoadColor : Integer;
var
tRoadPoints, RoadPoints : TPointArray;
RoadColors : TIntegerArray;
i, c : Integer;
Hue, Sat, Lum : Extended;
begin
FindColorsTolerance(tRoadPoints, 6187637, MMX1, MMY1, MMX2, MMY2, 50);
for i := 0 to GetArrayLength(tRoadPoints) - 1 do
if rs_OnMiniMap(tRoadPoints[i].x, tRoadPoints[i].y) then
begin
c := c + 1;
SetArrayLength(RoadPoints, c + 1);
RoadPoints[c] := tRoadPoints[i];
end
RoadColors := ShrinkArray(GetColors(RoadPoints));
for i := 0 to GetArrayLength(RoadColors) -1 do
begin
ColorToHSL(RoadColors[i], Hue, Sat, Lum);
if (Hue > 9.0) and (Hue < 19.0) and
(Sat > 9.0) and (Sat < 17.0) and
(Lum > 29.0) and (Lum < 55.0) then
begin
if CountColor(RoadColors[i], MMX1, MMY1, MMX2, MMY2) > 100 then
begin
Result := RoadColors[i];
Break;
end
end
end
if Result > 0 then
WriteLn('FaladorRoadColor = '+IntToStr(Result))
else
WriteLn('Unable to find falador road color.');
end;

begin
ClearDebug;
FindNormalRoadColor;
FindFaladorRoadColor;
end.

For Divi

Test Please, Might Need Some Editing For Get 100% Stable

WhiteShadow

2007-06-12 22:43:29

FindFaladorRoadColor as in, the light brown road or the grey one?

I was in South Falador and FindNormalRoadColor worked perfect. ;D

Swift too! Good job. Yay you don't do End; anymore. :PP