Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure TPAUnique(var TPA: TPointArray);
- var
- h, h2, i, i2, i3, d: Integer;
- begin
- h := High(TPA);
- if (h < 1) then
- Exit;
- for i := (h - d) downto 1 do
- for i2 := (i - 1) downto 0 do
- if ((TPA[i].X = TPA[i2].X) and (TPA[i].Y = TPA[i2].Y)) then
- begin
- h2 := High(TPA);
- for i3 := i to (h2 - 1) do
- TPA[i3] := TPA[(i3 + 1)];
- SetLength(TPA, h2);
- Inc(d);
- Break;
- end;
- end;
- function FindColorsMulti(colors: TIntegerArray; xs, ys, xe, ye: Integer): TPointArray;
- var
- l, i: Integer;
- ATPA: T2DPointArray;
- begin
- ClearSameIntegers(colors);
- l := Length(colors);
- if (l < 1) then
- Exit;
- SetLength(ATPA, l);
- for i := 0 to (l - 1) do
- if ((colors[i] >= 0) and (colors[i] <= 16777215)) then
- FindColors(ATPA[i], colors[i], xs, ys, xe, ye);
- Result := MergeATPA(ATPA);
- SetLength(ATPA, 0);
- TPAUnique(Result);
- end;
- function RSCE_UpText: string;
- var
- TPA: TPointArray;
- ATPA: array of TPointArray;
- begin
- TPA := FindColorsMulti([65535, 4231423, 16776960, 65280, 16777215], 3, 2, 311, 18);
- ATPA := SplitTPAEx(TPA, 1, 12);
- SortATPAFromFirstPoint(ATPA, Point(0, 0));
- SetLength(TPA, 0);
- try
- Result := GetTextATPA(ATPA, 3, 'RSCMainFont');
- except
- end;
- SetLength(ATPA, 0);
- end;
- function MinEx(Arr: TIntegerArray): Integer;
- var
- H, I: LongInt;
- begin
- H := High(Arr);
- Result := Arr[0];
- for I := 1 to H do
- Result := Min(Result, Arr[I]);
- end;
- function LevenshteinDistance(s: string; t: string): Integer;
- var
- m, n, i, j: integer;
- d: T2DIntegerArray;
- begin
- m := Length(s);
- n := Length(t);
- SetLength(d, (m + 1));
- for i := 0 to m do
- begin
- SetLength(d[i], (n + 1));
- d[i][0] := i;
- end;
- for j := 0 to n do
- d[0][j] := j;
- for j := 1 to n do
- for i := 1 to m do
- if (s[i] = t[j]) then
- d[i][j] := d[(i - 1)][(j - 1)]
- else
- d[i][j] := MinEx([(d[(i - 1)][j] + 1), (d[i][(j - 1)] + 1), (d[(i - 1)][(j - 1)] + 1)]);
- Result := d[m][n];
- end;
- function Percent(position, source: Extended): Extended;
- begin
- if (position = 0) then
- Result := 0
- else
- Result := (100 * (position / source));
- end;
- function IsUpText(str: string; accuracy_percent: Extended): Boolean;
- var
- L: Integer;
- similarity: Extended;
- uptxt: string;
- begin
- uptxt := RSCE_UpText;
- L := Length(str);
- Result := (Percent((L - LevenshteinDistance(str, uptxt)), L) > accuracy_percent);
- end;
- begin
- LoadFont('RSCMainFont', False);
- ClearDebug;
- ActivateClient;
- Wait(2000);
- if IsUpText('Well: Walk here / 1 more option', 85.0) then
- WriteLn('SUCCESS!');
- FreeFont('RSCMainFont');
- end.
Advertisement
Add Comment
Please, Sign In to add comment