NCDS
2009-12-22 23:37:06
I don't see how it takes so long..
var
FindTree_ArrCnt, TreeColors: array of Integer;
function N_PointToBox(Point: TPoint; W, H: Integer): TBox;
var
a, b: Integer;
begin
a := W / 2;
b := H / 2;
with Result do
begin
x1 := Point.x - a;
y1 := Point.y - b;
x2 := Point.x + a;
y2 := Point.y + b;
end;
end;
function FindTree(Clrs: TIntegerArray): TBox;
var
Arr: array of TPoint; i, t: Integer;
begin
if not LoggedIn then
Exit;
MarkTime(t);
for i := 0 to High(Clrs) do
begin
FindColorsSpiralTolerance(MSCx, MSCy, Arr, Clrs[i], MSx1, MSy1,
MSx2, MSy2, 2);
if Length(Arr) > 0 then
Break;
if i = High(Clrs) then
begin
Writeln('Failed to find tree''s.');
Exit;
end;
end;
SortTPAFrom(Arr, Point(MSCx, MSCy));
i := RandomRange(FindTree_ArrCnt[0], FindTree_ArrCnt[1]);
Result := N_PointToBox(Point(Arr[i].x, Arr[i].y), 20, 20);
//Debug
Writeln('Found tree in '+IntToStr(t)+' ms.');
Writeln('Chose point '+IntToStr(i)+' in array.');
Writeln('Found tree at: '+IntToStr(Arr[i].x)+', '+IntToStr(Arr[i].y)+';');
end;
begin
SetUpSRL;
ActivateClient;
FindTree_ArrCnt := [3, 7];
TreeColors := [10220279, 9956593, 14021108];
FindTree(TreeColors);
end;
SRL Compiled in 16 msec
Found tree in 21528499 ms.