Iroki
02-03-2009, 08:04 AM
Hey Guys,
"What comes next?" solved!! its half of work at Mr.mordaut solver but. For me its the most complicated and hard work needed random. Ok here is:program New;
{.include SRL/SRL.scar}
const
ScanningTime = 4.5; //seconds
function SmallRandomSolver: integer;
var
i, slot: integer;
begin
Result := (3 + Random(3));
for i := 0 to 6 do
begin
slot := Mordaut_GetSlotNr(ScanningTime, GetClientCanvas.Handle);
if (slot <> 0) then
begin
WriteLn(IntToStr(slot));
Result := slot;
Exit;
end;
end;
end;
begin
SetUpSRL;
case SmallRandomSolver of
3: Mouse(RandomRange(91, 131), RandomRange(220, 252), 0, 0, True);
4: Mouse(RandomRange(187, 227), RandomRange(220, 252), 0, 0, True);
5: Mouse(RandomRange(283, 323), RandomRange(220, 252), 0, 0, True);
6: Mouse(RandomRange(379, 419), RandomRange(220, 252), 0, 0, True);
end;
end.
and source, ( i think that i must post it according to my past )
library MordautPlugin;
uses
FastShareMem,
SysUtils,
Classes,
Windows,
Math,
Graphics;
{$R *.res}
type
TSCARPlugFunc = record
Name: string;
Ptr: Pointer;
end;
// TOneStrProc = procedure(s: string);
TSCARWindowHandle = function(): Integer;
type
TRGB32 = packed record
B, G, R, A: Byte;
end;
TRGB32Array = packed array[0..MaxInt div SizeOf(TRGB32) - 1] of TRGB32;
PRGB32Array = ^TRGB32Array;
var
// Writeln: TOneStrProc;
GetClientWindowHandle: TSCARWindowHandle;
c: array of array of array of Integer;
b: array of array of array of Boolean;
w, h: Integer;
// Fillinfo: boolean;
{
Mr.Mordaut solver
By: ManFromCzech, small tweaks by NaumanAkhlaQ
}
function Mordaut_GetSlotNr(ScanningTime: Extended; ClientHDC: HDC): integer; stdcall;
var
BMP: TBitmap;
Line: PRGB32Array;
Sx1, Sy1, Sx2, Sy2, x, y, sx, sy, a1, a2, b1, b2, Slot, i: integer;
Start, Stop, Freq: int64;
Time: double;
ObjToFind: string;
Obj: array of string;
Lum: array of extended;
CoMax: array of Integer;
CoMin: array of Integer;
BMaxArea: array of Integer;
BMinArea: array of Integer;
BArea: array of Integer;
BlackArea: array of Integer;
ObjectArea: array of Integer;
begin
SetLength(Obj, 7);
SetLength(Lum, 7);
SetLength(CoMax, 7);
SetLength(CoMin, 7);
SetLength(BMaxArea, 7);
SetLength(BMinArea, 7);
SetLength(BArea, 7);
SetLength(BlackArea, 7);
SetLength(ObjectArea, 7);
for Slot := 0 to 6 do
begin
CoMax[Slot] := 0; CoMin[Slot] := 2000; BMaxArea[Slot] := 0; BMinArea[Slot] := 0;
BArea[Slot] := 0;
end;
QueryPerformanceFrequency(Freq);
QueryPerformanceCounter(Start);
Sx1 := 0; Sy1 := 0; Sx2 := 0; Sy2 := 0; a1 := 0; a2 := 0; b1 := 0; b2 := 0;
repeat
w := 456; h := 291;
Bmp := TBitmap.Create;
Bmp.Width := w;
Bmp.Height:= h;
Bmp.PixelFormat := pf32bit;
SetLength(c, w + 1, h + 1, 7);
SetLength(b, w + 1, h + 1, 7);
BitBlt(Bmp.Canvas.Handle, 0, 0, w, h, ClientHDC, 0, 0, SRCCOPY);
for Slot := 0 to 6 do
begin
BlackArea[Slot] := 0;
//////////////////////
{
Slots:
_________________________________
| ______ ______ ______ |
| | | | | |
| | 0 | 1 | 2 | |
| |______|______|______| |
| |
| What comes next? |
| ______ ______ ______ ______ |
| | | | | | |
| | 3 | 4 | 5 | 6 | |
| |______|______|______|______| |
|_________________________________|
}
case Slot of
0, 1, 2: begin
Sx1 := 55 + Slot*100;
Sy1 := 45;
Sx2 := Sx1 + 100;
Sy2 := 145;
end;
3, 4, 5, 6: begin
Sx1 := -245 + Slot*100;
Sy1 := 190;
Sx2 := Sx1 + 100;
Sy2 := 290;
end;
end;
for y := Sy1 to Sy2 do
begin
Line := bmp.ScanLine[y];
for x := Sx1 to Sx2 do
begin
c[x][y][Slot] := RGB(Line[x].R, Line[x].G, Line[x].B);
if (Line[x].R <> 0) then
begin
if InRange(Line[x].R, 65, 95) then
if InRange(Line[x].G, 80, 115) then
if InRange(Line[x].B, 65, 95)then
begin
c[x][y][Slot] := 0;
b[x][y][Slot] := True;
inc(BlackArea[Slot]);
end;
end else
begin
c[x][y][Slot] := 0;
b[x][y][Slot] := True;
inc(BlackArea[Slot]);
end;
end;
end;
ObjectArea[Slot] := (10201 - BlackArea[Slot]);
for sx := Sx2 - 1 downto Sx1 + 1 do
for sy := Sy1 + 1 to Sy2 - 1 do
begin
if (c[sx][sy][Slot] <> 0) then
begin
a2 := sx;
break;
end;
end;
for sx := Sx1 + 1 to Sx2 - 1 do
for sy := Sy1 + 1 to Sy2 - 1 do
begin
if (c[sx][sy][Slot] <> 0) then
begin
a1 := sx;
break;
end;
end;
for sy := Sy2 - 1 downto Sy1 + 1 do
for sx := Sx1 + 1 to Sx2 - 1 do
begin
if (c[sx][sy][Slot] <> 0) then
begin
b2 := sy;
break;
end;
end;
for sy := Sy1 + 1 to Sy2 - 1 do
for sx := Sx1 + 1 to Sx2 - 1 do
begin
if (c[sx][sy][Slot] <> 0) then
begin
b1 := sy;
break;
end;
end;
BArea[Slot] := (a2 - a1)*(b2 - b1);
if (ObjectArea[Slot] > CoMax[Slot]) then
begin
CoMax[Slot] := ObjectArea[Slot];
BMaxArea[Slot] := BArea[Slot];
end;
if (ObjectArea[Slot] < CoMin[Slot]) then
begin
CoMin[Slot] := ObjectArea[Slot];
BMinArea[Slot] := BArea[Slot];
end;
//////////////
end;
Bmp.Free;
QueryPerformanceCounter(Stop);
Time := (1E3 * (Stop - Start) / Freq);
Until (Time >= (ScanningTime * 1000));
for Slot := 0 to 6 do
begin
Lum[Slot] := (BMaxArea[Slot]/CoMax[Slot]);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~ Objects database ~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Obj[Slot] := 'unknow';
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (Slot = 0) then
begin
if InRange(Lum[Slot], 1.3, 1.9) and InRange(BMaxArea[Slot], 700, 1200) and InRange(BMinArea[Slot], 340, 650) and InRange(CoMax[Slot], 580, 730)
and InRange(CoMin[Slot], 300, 460) then Obj[Slot] := 'Q18'; // Boots
if InRange(Lum[Slot], 1.35, 1.9) and InRange(BMaxArea[Slot], 100, 1350) and InRange(BMinArea[Slot], 300, 900) and InRange(CoMax[Slot], 700, 775)
and InRange(CoMin[Slot], 115, 270) then Obj[Slot] := 'Q03'; // Thieve mask
if InRange(Lum[Slot], 2.7, 4.9) and InRange(BMaxArea[Slot], 800, 1400) and InRange(BMinArea[Slot], 0, 160) and InRange(CoMax[Slot], 280, 360)
and InRange(CoMin[Slot], 20, 80) then Obj[Slot] := 'Q02'; // Scimitar
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (Slot = 1) then
begin
if InRange(Lum[Slot], 1.5, 2.8) and InRange(BMaxArea[Slot], 1000, 1550) and InRange(BMinArea[Slot], 200, 450) and InRange(CoMax[Slot], 500, 670)
and InRange(CoMin[Slot], 180, 320) then Obj[Slot] := 'Q19'; // Ore
if InRange(Lum[Slot], 1.4, 2.2) and InRange(BMaxArea[Slot], 820, 1000) and InRange(BMinArea[Slot], 320, 700) and InRange(CoMax[Slot], 440, 540)
and InRange(CoMin[Slot], 250, 330) then Obj[Slot] := 'Q17'; // Full helmet
if InRange(Lum[Slot], 1.05, 1.35) and InRange(BMaxArea[Slot], 1050, 1300) and InRange(BMinArea[Slot], 500, 650) and InRange(CoMax[Slot], 950, 1050)
and InRange(CoMin[Slot], 480, 580) then Obj[Slot] := 'Q16'; // Cake
if InRange(Lum[Slot], 0.9, 1.4) and InRange(BMaxArea[Slot], 250, 380) and InRange(BMinArea[Slot], 220, 300) and InRange(CoMax[Slot], 240, 320)
and InRange(CoMin[Slot], 150, 200) then Obj[Slot] := 'Q15'; // Garlic
if InRange(Lum[Slot], 1.2, 4.0) and InRange(BMaxArea[Slot], 200, 560) and InRange(BMinArea[Slot], 20, 360) and InRange(CoMax[Slot], 130, 170)
and InRange(CoMin[Slot], 10, 120) then Obj[Slot] := 'Q13'; // Shrimp
if InRange(Lum[Slot], 1.4, 1.7) and InRange(BMaxArea[Slot], 510, 610) and InRange(BMinArea[Slot], 290, 410) and InRange(CoMax[Slot], 330, 410)
and InRange(CoMin[Slot], 210, 260) then Obj[Slot] := 'Q11'; // Strawberry
if InRange(Lum[Slot], 1.15, 1.4) and InRange(BMaxArea[Slot], 1150, 1300) and InRange(BMinArea[Slot], 380, 520) and InRange(CoMax[Slot], 900, 950)
and InRange(CoMin[Slot], 380, 460) then Obj[Slot] := 'Q09'; // Fire rune
if InRange(Lum[Slot], 1.45, 2.4) and InRange(BMaxArea[Slot], 700, 1200) and InRange(BMinArea[Slot], 0, 70) and InRange(CoMax[Slot], 465, 515)
and InRange(CoMin[Slot], 0, 50) then Obj[Slot] := 'Q01'; // White approw
if InRange(Lum[Slot], 1.40, 2.2) and InRange(BMaxArea[Slot], 940, 1310) and InRange(BMinArea[Slot], 680, 1000) and InRange(CoMax[Slot], 560, 640)
and InRange(CoMin[Slot], 300, 360) then Obj[Slot] := 'Q06'; // Watering can
if InRange(Lum[Slot], 1.5, 1.9) and InRange(BMaxArea[Slot], 1150, 1380) and InRange(BMinArea[Slot], 200, 500) and InRange(CoMax[Slot], 720, 790)
and InRange(CoMin[Slot], 200, 360) then Obj[Slot] := 'Q07'; // Bar
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (Slot = 2) then
begin
if InRange(Lum[Slot], 1.3, 2.9) and InRange(BMaxArea[Slot], 1100, 2300) and InRange(BMinArea[Slot], 390, 900) and InRange(CoMax[Slot], 770, 870)
and InRange(CoMin[Slot], 250, 460) then Obj[Slot] := 'Q14'; // Monkfish
if InRange(Lum[Slot], 1.0, 1.5) and InRange(BMaxArea[Slot], 800, 1200) and InRange(BMinArea[Slot], 120, 250) and InRange(CoMax[Slot], 750, 820)
and InRange(CoMin[Slot], 60, 200) then Obj[Slot] := 'Q12'; // Wooden shield
if InRange(Lum[Slot], 1.0, 1.3) and InRange(BMaxArea[Slot], 500, 580) and InRange(BMinArea[Slot], 120, 280) and InRange(CoMax[Slot], 420, 490)
and InRange(CoMin[Slot], 35, 90) then Obj[Slot] := 'Q10'; // Rum
if InRange(Lum[Slot], 2.7, 4.65) and InRange(BMaxArea[Slot], 770, 1250) and InRange(BMinArea[Slot], 200, 400) and InRange(CoMax[Slot], 250, 300)
and InRange(CoMin[Slot], 70, 140) then Obj[Slot] := 'Q04'; // Crossbow
if InRange(Lum[Slot], 1.75, 2.9) and InRange(BMaxArea[Slot], 200, 360) and InRange(BMinArea[Slot], 50, 150) and InRange(CoMax[Slot], 120, 140)
and InRange(CoMin[Slot], 50, 70) then Obj[Slot] := 'Q05'; // Candle
if InRange(Lum[Slot], 3.1, 4.0) and InRange(BMaxArea[Slot], 1300, 1700) and InRange(BMinArea[Slot], 80, 120) and InRange(CoMax[Slot], 380, 470)
and InRange(CoMin[Slot], 55, 95) then Obj[Slot] := 'Q08'; // Holy symbol
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if InRange(Slot, 3, 6) then
begin
if InRange(Lum[Slot], 1.5, 1.9) and InRange(BMaxArea[Slot], 1150, 1380) and InRange(BMinArea[Slot], 200, 500) and InRange(CoMax[Slot], 720, 790)
and InRange(CoMin[Slot], 200, 360) then Obj[Slot] := 'Q19'; // Bar
if InRange(Lum[Slot], 1.2, 2.0) and InRange(BMaxArea[Slot], 800, 1200) and InRange(BMinArea[Slot], 380, 700) and InRange(CoMax[Slot], 600, 700)
and InRange(CoMin[Slot], 220, 470) then Obj[Slot] := 'Q17'; // Q18 // Boots
if InRange(Lum[Slot], 1.3, 2.0) and InRange(BMaxArea[Slot], 1020, 1300) and InRange(BMinArea[Slot], 380, 670) and InRange(CoMax[Slot], 650, 750)
and InRange(CoMin[Slot], 300, 470) then Obj[Slot] := 'Q17'; // Platebody
if InRange(Lum[Slot], 1.1, 1.35) and InRange(BMaxArea[Slot], 1150, 1350) and InRange(BMinArea[Slot], 400, 600) and InRange(CoMax[Slot], 950, 1050)
and InRange(CoMin[Slot], 300, 370) then Obj[Slot] := 'Q16'; // Apple pie
if InRange(Lum[Slot], 1.0, 1.3) and InRange(BMaxArea[Slot], 500, 620) and InRange(BMinArea[Slot], 400, 500) and InRange(CoMax[Slot], 430, 520)
and InRange(CoMin[Slot], 100, 180) then Obj[Slot] := 'Q15'; // Pineapple
if InRange(Lum[Slot], 1.9, 3.1) and InRange(BMaxArea[Slot], 700, 1100) and InRange(BMinArea[Slot], 150, 310) and InRange(CoMax[Slot], 330, 420)
and InRange(CoMin[Slot], 50, 150) then Obj[Slot] := 'Q14'; // Trout
if InRange(Lum[Slot], 3.0, 4.9) and InRange(BMaxArea[Slot], 1050, 1600) and InRange(BMinArea[Slot], 40, 170) and InRange(CoMax[Slot], 310, 380)
and InRange(CoMin[Slot], 30, 100) then Obj[Slot] := 'Q13'; // Swordfish
if InRange(Lum[Slot], 1.4, 2.6) and InRange(BMaxArea[Slot], 1100, 2000) and InRange(BMinArea[Slot], 100, 300) and InRange(CoMax[Slot], 700, 810)
and InRange(CoMin[Slot], 40, 200) then Obj[Slot] := 'Q12'; // Antidragon shield
if InRange(Lum[Slot], 1.5, 2.65) and InRange(BMaxArea[Slot], 300, 620) and InRange(BMinArea[Slot], 10, 110) and InRange(CoMax[Slot], 140, 280)
and InRange(CoMin[Slot], 20, 100) then Obj[Slot] := 'Q11'; // Berry's
if InRange(Lum[Slot], 1.2, 1.45) and InRange(BMaxArea[Slot], 1100, 1300) and InRange(BMinArea[Slot], 380, 520) and InRange(CoMax[Slot], 880, 950)
and InRange(CoMin[Slot], 400, 460) then Obj[Slot] := 'Q09'; // Earth rune
if InRange(Lum[Slot], 1.05, 2.0) and InRange(BMaxArea[Slot], 320, 570) and InRange(BMinArea[Slot], 120, 270) and InRange(CoMax[Slot], 250, 300)
and InRange(CoMin[Slot], 100, 170) then Obj[Slot] := 'Q08'; // Ring
if InRange(Lum[Slot], 1.05, 1.35) and InRange(BMaxArea[Slot], 1050, 1300) and InRange(BMinArea[Slot], 500, 650) and InRange(CoMax[Slot], 950, 1050)
and InRange(CoMin[Slot], 480, 580) then Obj[Slot] := 'Q01'; // Cake
if InRange(Lum[Slot], 2.4, 4.0) and InRange(BMaxArea[Slot], 520, 1050) and InRange(BMinArea[Slot], 200, 800) and InRange(CoMax[Slot], 210, 280)
and InRange(CoMin[Slot], 110, 190) then Obj[Slot] := 'Q02'; // Mace
if InRange(Lum[Slot], 1.7, 2.6) and InRange(BMaxArea[Slot], 760, 1100) and InRange(BMinArea[Slot], 250, 450) and InRange(CoMax[Slot], 400, 480)
and InRange(CoMin[Slot], 110, 190) then Obj[Slot] := 'Q03'; // Jeaster hat
if InRange(Lum[Slot], 1.4, 8.0) and InRange(BMaxArea[Slot], 300, 1250) and InRange(BMinArea[Slot], 0, 200) and InRange(CoMax[Slot], 140, 195)
and InRange(CoMin[Slot], 0, 60) then Obj[Slot] := 'Q04'; // Longbow
if InRange(Lum[Slot], 1.2, 1.75) and InRange(BMaxArea[Slot], 600, 800) and InRange(BMinArea[Slot], 320, 610) and InRange(CoMax[Slot], 400, 600)
and InRange(CoMin[Slot], 200, 310) then Obj[Slot] := 'Q05'; // Bullseye lataren
if InRange(Lum[Slot], 2.3, 3.3) and InRange(BMaxArea[Slot], 720, 1000) and InRange(BMinArea[Slot], 60, 160) and InRange(CoMax[Slot], 280, 340)
and InRange(CoMin[Slot], 45, 100) then Obj[Slot] := 'Q06'; // Gardening trowel
if InRange(Lum[Slot], 3.5, 5.4) and InRange(BMaxArea[Slot], 1020, 1750) and InRange(BMinArea[Slot], 95, 260) and InRange(CoMax[Slot], 270, 340)
and InRange(CoMin[Slot], 70, 160) then Obj[Slot] := 'Q07'; // Pickaxe
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
end;
ObjToFind := 'unknow';
Result := (0);
for i := 0 to 2 do
if (Obj[i] <> 'unknow') then ObjToFind := Obj[i];
if (ObjToFind = 'Q10') then ObjToFind := 'Q08';
if (ObjToFind = 'Q18') then ObjToFind := 'Q17';
if (ObjToFind <> 'unknow') then
begin
for i := 3 to 6 do
begin
if (Obj[i] = ObjToFind) then Result := i;
end;
end else Result := (0);
// Result := strtoint('0 ' + Obj[0] + ' 1 ' + Obj[1] + ' 2 ' + Obj[2] + ' 3 ' + Obj[3] + ' 4 ' + Obj[4] + ' 5 ' + Obj[5] + ' 6 ' + Obj[6]);
// if ((Option = 1) and (Obj[1] = 'unknow')) then Result := ('Lum ' + FloatToStr(Lum[1]) + ' BMax: '+ IntToStr(BMaxArea[1]) + ' BMin: ' + IntToStr(BMinArea[1]) + ' ColoredMax: '+ IntToStr(CoMax[1]) + ' ColoredMin: '+ IntToStr(CoMin[1]));
// if ((Option = 2) or (Result = 'unknow')) then Result := ('AreaMax: ' + IntToStr(CoMax[Slot]) + ' AreaMin: ' + IntToStr(CoMin[Slot]) + ' BMax: '+ IntToStr(BMinArea[Slot]) + ' BMin: ' + IntToStr(BMinArea[Slot]));
end;
function GetFunctionCount(): Integer; stdcall; export;
begin
Result := 1;
end;
function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall;
begin
case x of
0:
begin
ProcAddr := @Mordaut_GetSlotNr;
StrPCopy(ProcDef, 'function Mordaut_GetSlotNr(ScanningTime: Extended; ClientHDC: HDC): integer;');
end;
else
x := -1;
end;
Result := x;
end;
procedure SetFunctions(Funcs: array of TSCARPlugFunc); stdcall;
var
i: Integer;
begin
for i := 0 to Length(Funcs) - 1 do
begin
{ if Funcs[i].Name = 'Writeln' then
Writeln := Funcs[i].Ptr; }
if Funcs[i].Name = 'GetClientWindowHandle' then
GetClientWindowHandle := Funcs[i].Ptr;
end;
// FillInfo := false;
end;
exports GetFunctionCount;
exports GetFunctionInfo;
exports SetFunctions;
end.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.