DannyRS
2013-02-10 20:53:52
Ok, so how can I get any of these below 100ms ^^ any idea's? how did SRL handle randoms back in the day?


program test;
{$I SRL/SRL/Misc/Debug.Simba}
Var
IntCounter: Integer;
Function P06_FindGenieMiddleBox: Boolean;
Var
TBP,TBB: Tbox;
IP,IB,IY,LY,LP,LB,XP,YP,XB,YB,XY,YY: Integer;
PurpleTPA,BlueTPA,YellowTPA: TPointArray;
PurpleATPA,BlueATPA,YellowATPA: T2DPointArray;
Begin
FindColorsTolerance(PurpleTPA, 8392314, 0, 0, 605, 357, 31);
//DebugTPA(PurpleTPA,'testgenie');
FindColorsTolerance(BlueTPA, 14717768, 0, 0, 605, 357, 64);
//DebugTPA(BlueTPA,'testgenie');
FindColorsTolerance(YellowTPA, 1353623, 0, 0, 605, 357, 47);
//DebugTPA(YellowTPA,'testgenie');
SplitTPAWrap(PurpleTPA, 22, PurpleATPA);
SortATPASize(PurpleATPA,True);
SplitTPAWrap(BlueTPA, 10, BlueATPA);
SortATPASize(BlueATPA,True);
SplitTPAWrap(YellowTPA, 10, YellowATPA);
SortATPASize(YellowATPA,True);
LP := High(PurpleATPA);
LB := High(BlueATPA);
LY := High(YellowATPA);
For IP := 0 to LP do
Begin
MiddleTPAEx(PurpleATPA[IP], XP, YP);
TBP:=IntToBox(XP-15, YP-15, XP+15, YP+15);
For IB := 0 to LB do
Begin
MiddleTPAEx(BlueATPA[IB], XB, YB);
If (PointInBox(Point(XB,YB), TBP)) Then
Begin
TBB:=IntToBox(XB-15, YB-15, XB+15, YB+15);
For IY := 0 to LY do
Begin
MiddleTPAEx(YellowATPA[IY], XY, YY);
If (PointInBox(Point(XY,YY), TBB)) Then
Begin
Result:=True;
//DebugTPA(BlueATPA[IB],'testgenie');
Exit;
End;
End;
End;
End;
End;
Result:=False;
End;
Function P06_FindGenieWidthHeight: Boolean;
Var
TBP,TBB: Tbox;
IP,IB,LP,LB,XB,YB: Integer;
PurpleTPA,BlueTPA: TPointArray;
PurpleATPA,BlueATPA: T2DPointArray;
Begin
FindColorsTolerance(PurpleTPA, 8392314, 0, 0, 605, 357, 31);
//DebugTPA(PurpleTPA,'testgenie');
FindColorsTolerance(BlueTPA, 14717768, 0, 0, 605, 357, 64);
//DebugTPA(BlueTPA,'testgenie');
SplitTPAWrap(PurpleTPA, 22, PurpleATPA);
SortATPASize(PurpleATPA,True);
SplitTPAWrap(BlueTPA, 10, BlueATPA);
SortATPASize(BlueATPA,True);
LP := High(PurpleATPA);
LB := High(BlueATPA);
For IP := 0 to LP do
Begin
TBP:=GetTPABounds(PurpleATPA[IP]);
If ((TBP.X2-TBP.X1)<12) Or ((TBP.Y2-TBP.Y1)<15) Then
Continue;
For IB := 0 to LB do
Begin
TBB:=GetTPABounds(BlueATPA[IB]);
If ((TBB.X2-TBB.X1)<7) Or ((TBB.Y2-TBB.Y1)<13) Then
Continue;
XB:=(TBB.X1+((TBB.X2-TBB.X1)/2));
YB:=(TBB.Y1+((TBB.Y2-TBB.Y1)/2));
If (PointInBox(Point(XB,YB), TBP)) Then
Begin
Result:=True;
//DebugTPA(BlueATPA[IB],'testgenie');
Exit;
End;
End;
End;
Result:=False;
End;
Function P06_FindGeniePixelDensity: Boolean;
Var
PAD,BAD,IP,IB,LP,LB,XB,YB: Integer;
PurpleTPA,BlueTPA: TPointArray;
PurpleATPA,BlueATPA: T2DPointArray;
Begin
FindColorsTolerance(PurpleTPA, 8392314, 0, 0, 605, 357, 31);
//DebugTPA(PurpleTPA,'testgenie');
FindColorsTolerance(BlueTPA, 14717768, 0, 0, 605, 357, 64);
//DebugTPA(BlueTPA,'testgenie');
SplitTPAWrap(PurpleTPA, 22, PurpleATPA);
SortATPASize(PurpleATPA,True);
SplitTPAWrap(BlueTPA, 10, BlueATPA);
SortATPASize(BlueATPA,True);
LP := High(PurpleATPA);
LB := High(BlueATPA);
For IP := 0 to LP do
Begin
PAD:=High(PurpleATPA[IP]);
If (PAD<50) Or (PAD>450) Then
Continue;
//Writeln('PAD: '+IntToStr(PAD));
For IB := 0 to LB do
Begin
BAD:=High(BlueATPA[IB]);
If (BAD<30) Or (BAD>450) Then
Continue;
//Writeln('BAD: '+IntToStr(BAD));
MiddleTPAEx(BlueATPA[IB], XB, YB);
If (PointInBox(Point(XB,YB), GetTPABounds(PurpleATPA[IP]))) Then
Begin
Result:=True;
//DebugTPA(BlueATPA[IB],'testgenie');
Exit;
End;
End;
End;
Result:=False;
End;
begin
MarkTime(IntCounter);
If P06_FindGenieMiddleBox Then
Writeln('Saw Genie');
Writeln('Took: '+inttostr(TimeFromMark(IntCounter)));
MarkTime(IntCounter);
If P06_FindGenieWidthHeight Then
Writeln('Saw Genie');
Writeln('Took: '+inttostr(TimeFromMark(IntCounter)));
MarkTime(IntCounter);
If P06_FindGeniePixelDensity Then
Writeln('Saw Genie');
Writeln('Took: '+inttostr(TimeFromMark(IntCounter)));
end.
Saw Genie
Took: 156
Saw Genie
Took: 140
Saw Genie
Took: 125