SRL Archive - Test corner

Bee Keeper random solver


Town

2007-10-20 17:54:24

This has actually been done for about a week now, I've just been hiding it from you :rolleyes:

program New;
{.include SRL\SRL.scar}

var
x, y: Integer;
Bee: Array[0..3] of Integer;
BoxArray: TBoxArray;
Done: Array[0..3] of Boolean;

procedure DeclareDTMs;
begin
Bee[3] := DTMFromString('78DA63DCC6C0C0709D0105AC5DB890811F483' +
'302F17F20603C0F64BC4555B36CF62CB81A10609C0324DEA1AA59' +
'3C633AAA9A2940E226AA9A6DAB57A1AAB90C246EA1AA99DCD989A' +
'20600DCDF158B');
Bee[2] := DTMFromString('78DA6364666460F8C08002440405192481345' +
'086E13F10303E07321EA2AAD9B369135C0D0830CA02590F50D5AC' +
'9C3B17558D2290F50555CDCCFE3E54354F1830D4EC58BB16450D0' +
'045CA132D');
Bee[1] := DTMFromString('78DA6364656460B8C48002766FDCC8C00FA48' +
'1320CFF8180F12590710C55CDA15D3BE16A4080F10990B883AAE6' +
'E89E3DA86A9480ACE3A86A56CD9B8BAA460DC8BA8BAA66D6847E5' +
'435FF31EDDAB96E2DAA1A5E4CBBB6AC5A89A2060093191BA1');
Bee[0] := DTMFromString('78DA639CCDC0C0708701055CBF7491811F483' +
'302F17F2060AC05329EA3AA7970FB365C0D0830760289CBA86A9E' +
'3F7982AA662690388DAAE6C2C993A86AD600896BA86AF66DD982A' +
'A662BA67B56CF9F8FAA660E90788DAA66D7860D286A0066D81EFE' +
'');
SetArrayLength(BoxArray, 11);
BoxArray[0].x1 := 0;
BoxArray[0].y1 := 0;
BoxArray[0].x2 := 26;
BoxArray[0].y2 := 338;
BoxArray[1].x1 := 0;
BoxArray[1].y1 := 0;
BoxArray[1].x2 := 515;
BoxArray[1].y2 := 50;
BoxArray[2].x1 := 495;
BoxArray[2].y1 := 31;
BoxArray[2].x2 := 516;
BoxArray[2].y2 := 338;
BoxArray[3].x1 := 19;
BoxArray[3].y1 := 304;
BoxArray[3].x2 := 515;
BoxArray[3].y2 := 337;
BoxArray[4].x1 := 86;
BoxArray[4].y1 := 226;
BoxArray[4].x2 := 516;
BoxArray[4].y2 := 304;
BoxArray[5].x1 := 179;
BoxArray[5].y1 := 28;
BoxArray[5].x2 := 193;
BoxArray[5].y2 := 226;
BoxArray[6].x1 := 325;
BoxArray[6].y1 := 27;
BoxArray[6].x2 := 340;
BoxArray[6].y2 := 226;
BoxArray[7].x1 := 191;
BoxArray[7].y1 := 71;
BoxArray[7].x2 := 326;
BoxArray[7].y2 := 77;
BoxArray[8].x1 := 191;
BoxArray[8].y1 := 123;
BoxArray[8].x2 := 325;
BoxArray[8].y2 := 131;
BoxArray[9].x1 := 191;
BoxArray[9].y1 := 174;
BoxArray[9].x2 := 325;
BoxArray[9].y2 := 185;
BoxArray[10].x1 := 426;
BoxArray[10].y1 := 192;
BoxArray[10].x2 := 516;
BoxArray[10].y2 := 338;
end;

function ConvertTPAToBox(TPA: TPointArray): TBoxArray;
var
i: Integer;
begin
SetArrayLength(Result, GetArrayLength(TPA));
for i := 0 to GetArrayLength(TPA) - 1 do
begin
Result[i].X1 := TPA[i].x - 1; Result[i].X2 := TPA[i].x + 1;
Result[i].Y1 := TPA[i].y - 1; Result[i].Y1 := TPA[i].y + 1;
end;
end;

function AddBoxArray(Box1, Box2: TBoxArray): TBoxArray;
var
i: Integer;
begin
SetArrayLength(Result, GetArrayLength(Box1));
for i := 0 to GetArrayLength(Box2) - 1 do
begin
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[GetArrayLength(Result) - 1].X1 := Box2[i].X1;
Result[GetArrayLength(Result) - 1].X2 := Box2[i].X2;
Result[GetArrayLength(Result) - 1].Y1 := Box2[i].Y1;
Result[GetArrayLength(Result) - 1].Y2 := Box2[i].Y2;
end;
end;

procedure TalkTo; // Talks to Bee Keeper
var
Points: TPointArray;
i: Integer;
PointBox: TBoxArray;
begin
if (not (LoggedIn)) then Exit;
FindColorsTolerance(Points, 10329514, MSX1, MSY1, MSX2, MSY2, 30);
PointBox := ConvertTPAToBox(Points);
BoxArray := AddBoxArray(PointBox, BoxArray);
FindColorsTolerance(Points, 5000274, MSCX + 20, MSCY - 35, MSCX + 65, MSCY + 35, 25);
if (GetArrayLength(Points) = 0) then Logout;
if (not (LoggedIn)) then Exit;
for i := 0 to GetArrayLength(Points) - 1 do
begin
MMouse(Points[i].x, Points[i].y, 2, 2);
Wait(250 + Random(450));
if (IsUpText('alk')) then Break;
if (i = GetArrayLength(Points) - 1) then
begin
Logout;
Exit;
end;
end;
GetMousePos(x, y);
Mouse(x, y, 2, 2, true);
MarkTime(i);
repeat
if (ClickToContinue) then MarkTime(i);
Wait(1000 + Random(1000));
until (TimeFromMark(i) > 8000);
end;

procedure MovePiece(Num: Integer);
begin
case Num of
1: MouseBox(138, 279, 159, 292, True);
2: MouseBox(191, 268, 209, 284, True);
3: MouseBox(303, 281, 328, 288, True);
4: MouseBox(357, 283, 380, 289, True);
end;
end;

procedure MoveToCorner(Num: Integer); // Moves each piece to the corner so they aren't overlapping
var
p, i: Integer;
begin
if (not (LoggedIn)) then Exit;
case Num of
1: begin
repeat
MovePiece(1);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, MSX2, 80)) then Break;
end;
until (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, MSX2, 80));
repeat
MovePiece(3);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, 100, 80)) then
begin
Done[0] := True;
Exit;
end;
end;
until (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, 100, 80));
end;
2: begin
repeat
MovePiece(3);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, 105, MSY2)) then Break;
end;
until (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, 105, MSY2));
repeat
MovePiece(2);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, MSX1, 190, 105, 230)) then
begin
Done[1] := True;
Exit;
end;
end;
until (FindDTM(Bee[Num - 1], x, y, MSX1, 190, 105, 230));
end;
3: begin
repeat
MovePiece(1);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, MSX2, 85)) then Break;
end;
until (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, MSX2, 85));
repeat
MovePiece(4);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 400, MSY1, MSX2, 85)) then
begin
Done[2] := True;
Exit;
end;
end;
until (FindDTM(Bee[Num - 1], x, y, 400, MSY1, MSX2, 85));
end;
4: begin
repeat
MovePiece(4);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 350, MSY1, MSX2, MSY2)) then Break;
end;
p := p + 1;
until (p > 16 + Random(3) + Random(4)); // I call it "quality over perfection" as opposed to "quality of quantity"
repeat
MovePiece(2);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 400, MSY1, MSX2, MSY2))
or (not (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, MSX2, MSY2))) then
begin
Done[3] := True;
Exit;
end;
end;
until (FindDTM(Bee[Num - 1], x, y, 400, 200, MSX2, 250));
end;
end;
end;


procedure MoveToSpot(Num: Integer); // Moves pieces from the corners to their spots
var
i: Integer;
begin
if (not (LoggedIn)) then Exit;
case Num of
1: Mouse(56, 52, 8, 8, true);
2: Mouse(66, 216, 8, 8, true);
3: Mouse(436, 67, 8, 8, true);
4: Mouse(425, 216, 8, 8, true);
end;
case Num of
1: repeat
MovePiece(4);
for i := 0 to 5 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 210, 25, 310, 75)) then
begin
Done[0] := True;
Exit;
end;
end;
until (FindDTM(Bee[Num - 1], x, y, 210, 25, 310, 75));
2: begin
repeat
MovePiece(4);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 210, 195, 310, 240)) then Break;
end;
until (FindDTM(Bee[Num - 1], x, y, 210, 195, 310, 240));
repeat
MovePiece(1);
for i := 0 to 5 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 210, 80, 310, 125)) then
begin
Done[1] := True;
Exit;
end;
end;
until (FindDTM(Bee[Num - 1], x, y, 210, 80, 310, 125));
end;
3: begin
repeat
MovePiece(2);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 400, 140, MSX2, 175)) then Break;
end;
until (FindDTM(Bee[Num - 1], x, y, 400, 140, MSX2, 175));
repeat
MovePiece(3);
for i := 0 to 5 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 210, 140, 310, 175)) then
begin
Done[2] := True;
Exit;
end;
end;
until (FindDTM(Bee[Num - 1], x, y, 210, 140, 310, 175));
end;
4: begin
repeat
MovePiece(3);
for i := 0 to 5 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 210, 185, 310, 245)) then Break;
end;
until (FindDTM(Bee[Num - 1], x, y, 210, 185, 310, 245));
repeat
MovePiece(1);
for i := 0 to 5 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 210, 185, 310, 230)) then
begin
Done[3] := True;
Exit;
end;
end;
until (FindDTM(Bee[Num - 1], x, y, 210, 185, 310, 245));
end;
end;
end;

function FindFirstPiece: TPoint; // Finds a piece that has not been moved yet
var
Cur: Integer;
begin
repeat
if (not (LoggedIn)) then Exit;
if (FindColorSkipBoxArrayTolerance(x, y, 10329514, MSX1, MSY1, MSX2, MSY2, 30, BoxArray)) then
begin
// WriteLN('x: ' + IntToStr(x) + ' y: ' + IntToStr(y));
Cur := GetColor(x, y);
Wait(10);
if (GetColor(x, y) = Cur) then
begin
SetArrayLength(BoxArray, GetArrayLength(BoxArray) + 1);
BoxArray[GetArrayLength(BoxArray) - 1].x1 := x - 1;
BoxArray[GetArrayLength(BoxArray) - 1].x2 := x + 1;
BoxArray[GetArrayLength(BoxArray) - 1].y1 := y - 1;
BoxArray[GetArrayLength(BoxArray) - 1].y2 := y + 1;
end else Break;
end else
begin
Result.y := -1;
Exit;
end;
until (false);
Mouse(x, y, 2, 2, false);
Wait(250 + Random(450));
if (ChooseOption('Ok')) then
begin
Result.x := x;
Result.y := y;
Exit;
end else
begin
SetArrayLength(BoxArray, GetArrayLength(BoxArray) + 1);
BoxArray[GetArrayLength(BoxArray) - 1].x1 := x - 1;
BoxArray[GetArrayLength(BoxArray) - 1].x2 := x + 1;
BoxArray[GetArrayLength(BoxArray) - 1].y1 := y - 1;
BoxArray[GetArrayLength(BoxArray) - 1].y2 := y + 1;
Result.x := -1;
end;
end;

function MoveFirstPiece: Integer; // Moves piece to the bottem so it can be identified
var
Coord: TPoint;
i: Integer;
begin
repeat
Coord := FindFirstPiece;
if (Coord.x > 0) and (Coord.y > 0) then Break;
if (Coord.y = 0) then MMouse(641, 298, 40, 40);
Wait(100 + Random(1900));
if (not (LoggedIn)) then Exit;
until (false);
if (Coord.x < 200) then
begin
MovePiece(4);
Wait(100 + Random(400));
if (Coord.x < 175) then
begin
MovePiece(4);
Wait(100 + Random(400));
if (Coord.x < 150) then
begin
MovePiece(4);
Wait(100 + Random(400));
if (Coord.x < 125) then
begin
MovePiece(4);
Wait(100 + Random(400));
if (Coord.x < 100) then
begin
MovePiece(4);
Wait(100 + Random(400));
if (Coord.x < 80) then
begin
MovePiece(4);
Wait(100 + Random(400));
end;
end;
end;
end;
end;
end;
repeat
MovePiece(2);
for i := 0 to 3 do
if (FindDTM(Bee[i], x, y, 60, MSCY + 27, MSX2 - 150, MSY2)) then
begin
case i of
0: begin
SetArrayLength(BoxArray, GetArrayLength(BoxArray) + 1);
BoxArray[GetArrayLength(BoxArray) - 1].x1 := 25;
BoxArray[GetArrayLength(BoxArray) - 1].x2 := 110;
BoxArray[GetArrayLength(BoxArray) - 1].y1 := 30;
BoxArray[GetArrayLength(BoxArray) - 1].y2 := 100;
end;
1: begin
SetArrayLength(BoxArray, GetArrayLength(BoxArray) + 1);
BoxArray[GetArrayLength(BoxArray) - 1].x1 := 25;
BoxArray[GetArrayLength(BoxArray) - 1].x2 := 105;
BoxArray[GetArrayLength(BoxArray) - 1].y1 := 170;
BoxArray[GetArrayLength(BoxArray) - 1].y2 := 225;
end;
2: begin
SetArrayLength(BoxArray, GetArrayLength(BoxArray) + 1);
BoxArray[GetArrayLength(BoxArray) - 1].x1 := 385;
BoxArray[GetArrayLength(BoxArray) - 1].x2 := MMX2;
BoxArray[GetArrayLength(BoxArray) - 1].y1 := 30;
BoxArray[GetArrayLength(BoxArray) - 1].y2 := 115;
end;
3: begin
SetArrayLength(BoxArray, GetArrayLength(BoxArray) + 1);
BoxArray[GetArrayLength(BoxArray) - 1].x1 := 395;
BoxArray[GetArrayLength(BoxArray) - 1].x2 := MMX2;
BoxArray[GetArrayLength(BoxArray) - 1].y1 := 200;
BoxArray[GetArrayLength(BoxArray) - 1].y2 := MMY2;
end;
end;
Result := i + 1;
WriteLN(IntToStr(i));
Exit;
end;
Wait(100 + Random(400));
until (not (LoggedIn));
end;

function SolveBeeKeeper: Boolean; // Main loop
var
i: Integer;
begin
DeclareDTMs;
TalkTo;
repeat
i := MoveFirstPiece;
MoveToCorner(i);
if (Done[0] = True) and (Done[1] = True) and (Done[2] = True) and (Done[3] = True) then Break;
until (not (LoggedIn));
for i := 0 to 3 do
Done[i] := False;
i := 1;
repeat
MoveToSpot(i);
i := i + 1;
if (Done[0] = True) and (Done[1] = True) and (Done[2] = True) and (Done[3] = True) then Break;
until (not (LoggedIn));
Mouse(257, 279, 4, 4, true); // Clicks build
for i := 0 to 50 do
begin
if (not (InBlack)) then
begin
Result := True;
Break;
end;
Wait(100);
if (i = 50) then
begin
Mouse(498, 20, 4, 4, true);
Wait(1000 + Random(1000));
if (Sec) then
begin
Result := False;
Logout;
Exit;
end;
Sec := True;
SolveBeeKeeper;
end;
end;
end;

begin
SetupSRL;
ActivateClient;
Wait(1000 + Random(1000));
SolveBeeKeeper;
end.

What do you think?

King of Knives

2007-10-20 19:24:04

What is this? Are we just solving every random right now? 3 random-solvers in 1 day!

I didn't read it through very good, all I saw was "DTM" and then I love it :D

GJ though, as someone told me: "Every random solved is good job" (Or something like that)

-Knives

Santa_Clause

2007-10-20 19:43:24

Wow…this should definitely be put into SRL.

the scar noob

2007-10-21 15:19:54

nice job town :)

-Tsn.

n3ss3s

2007-10-22 10:49:55

Wow…this should definitely be put into SRL.


Santy's favourite phrase xD

Nice, I thought it'd be cool to solve this one, but I dont have members acc to auto flax on so I cant get this random, gj.

MasterKill

2007-10-22 12:07:40

lol i never ever head that random, when does it pops up?

but, it looks nice :)

good job

Town

2007-10-22 14:23:17

From: MasterKill
lol i never ever head that random, when does it pops up?

but, it looks nice :)

good job


While picking flax, which can only be done in members worlds.

Harry

2007-10-22 15:08:32

Good job Town! :)

neG

2007-10-22 18:07:11

I used to auto pick heaps of flax and I never got that random :(
Looks awesome Town! Nice work :)

Home

2007-10-24 07:25:17

From: Town
This has actually been done for about a week now, I've just been hiding it from you :rolleyes:

program New;
{.include SRL\SRL.scar}

var
x, y: Integer;
Bee: Array[0..3] of Integer;
BoxArray: TBoxArray;
Done: Array[0..3] of Boolean;

procedure DeclareDTMs;
begin
Bee[3] := DTMFromString('78DA63DCC6C0C0709D0105AC5DB890811F483' +
'302F17F20603C0F64BC4555B36CF62CB81A10609C0324DEA1AA59' +
'3C633AAA9A2940E226AA9A6DAB57A1AAB90C246EA1AA99DCD989A' +
'20600DCDF158B');
Bee[2] := DTMFromString('78DA6364666460F8C08002440405192481345' +
'086E13F10303E07321EA2AAD9B369135C0D0830CA02590F50D5AC' +
'9C3B17558D2290F50555CDCCFE3E54354F1830D4EC58BB16450D0' +
'045CA132D');
Bee[1] := DTMFromString('78DA6364656460B8C48002766FDCC8C00FA48' +
'1320CFF8180F12590710C55CDA15D3BE16A4080F10990B883AAE6' +
'E89E3DA86A9480ACE3A86A56CD9B8BAA460DC8BA8BAA66D6847E5' +
'435FF31EDDAB96E2DAA1A5E4CBBB6AC5A89A2060093191BA1');
Bee[0] := DTMFromString('78DA639CCDC0C0708701055CBF7491811F483' +
'302F17F2060AC05329EA3AA7970FB365C0D0830760289CBA86A9E' +
'3F7982AA662690388DAAE6C2C993A86AD600896BA86AF66DD982A' +
'A662BA67B56CF9F8FAA660E90788DAA66D7860D286A0066D81EFE' +
'');
SetArrayLength(BoxArray, 11);
BoxArray[0].x1 := 0;
BoxArray[0].y1 := 0;
BoxArray[0].x2 := 26;
BoxArray[0].y2 := 338;
BoxArray[1].x1 := 0;
BoxArray[1].y1 := 0;
BoxArray[1].x2 := 515;
BoxArray[1].y2 := 50;
BoxArray[2].x1 := 495;
BoxArray[2].y1 := 31;
BoxArray[2].x2 := 516;
BoxArray[2].y2 := 338;
BoxArray[3].x1 := 19;
BoxArray[3].y1 := 304;
BoxArray[3].x2 := 515;
BoxArray[3].y2 := 337;
BoxArray[4].x1 := 86;
BoxArray[4].y1 := 226;
BoxArray[4].x2 := 516;
BoxArray[4].y2 := 304;
BoxArray[5].x1 := 179;
BoxArray[5].y1 := 28;
BoxArray[5].x2 := 193;
BoxArray[5].y2 := 226;
BoxArray[6].x1 := 325;
BoxArray[6].y1 := 27;
BoxArray[6].x2 := 340;
BoxArray[6].y2 := 226;
BoxArray[7].x1 := 191;
BoxArray[7].y1 := 71;
BoxArray[7].x2 := 326;
BoxArray[7].y2 := 77;
BoxArray[8].x1 := 191;
BoxArray[8].y1 := 123;
BoxArray[8].x2 := 325;
BoxArray[8].y2 := 131;
BoxArray[9].x1 := 191;
BoxArray[9].y1 := 174;
BoxArray[9].x2 := 325;
BoxArray[9].y2 := 185;
BoxArray[10].x1 := 426;
BoxArray[10].y1 := 192;
BoxArray[10].x2 := 516;
BoxArray[10].y2 := 338;
end;

function ConvertTPAToBox(TPA: TPointArray): TBoxArray;
var
i: Integer;
begin
SetArrayLength(Result, GetArrayLength(TPA));
for i := 0 to GetArrayLength(TPA) - 1 do
begin
Result[i].X1 := TPA[i].x - 1; Result[i].X2 := TPA[i].x + 1;
Result[i].Y1 := TPA[i].y - 1; Result[i].Y1 := TPA[i].y + 1;
end;
end;

function AddBoxArray(Box1, Box2: TBoxArray): TBoxArray;
var
i: Integer;
begin
SetArrayLength(Result, GetArrayLength(Box1));
for i := 0 to GetArrayLength(Box2) - 1 do
begin
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[GetArrayLength(Result) - 1].X1 := Box2[i].X1;
Result[GetArrayLength(Result) - 1].X2 := Box2[i].X2;
Result[GetArrayLength(Result) - 1].Y1 := Box2[i].Y1;
Result[GetArrayLength(Result) - 1].Y2 := Box2[i].Y2;
end;
end;

procedure TalkTo; // Talks to Bee Keeper
var
Points: TPointArray;
i: Integer;
PointBox: TBoxArray;
begin
if (not (LoggedIn)) then Exit;
FindColorsTolerance(Points, 10329514, MSX1, MSY1, MSX2, MSY2, 30);
PointBox := ConvertTPAToBox(Points);
BoxArray := AddBoxArray(PointBox, BoxArray);
FindColorsTolerance(Points, 5000274, MSCX + 20, MSCY - 35, MSCX + 65, MSCY + 35, 25);
if (GetArrayLength(Points) = 0) then Logout;
if (not (LoggedIn)) then Exit;
for i := 0 to GetArrayLength(Points) - 1 do
begin
MMouse(Points[i].x, Points[i].y, 2, 2);
Wait(250 + Random(450));
if (IsUpText('alk')) then Break;
if (i = GetArrayLength(Points) - 1) then
begin
Logout;
Exit;
end;
end;
GetMousePos(x, y);
Mouse(x, y, 2, 2, true);
MarkTime(i);
repeat
if (ClickToContinue) then MarkTime(i);
Wait(1000 + Random(1000));
until (TimeFromMark(i) > 8000);
end;

procedure MovePiece(Num: Integer);
begin
case Num of
1: MouseBox(138, 279, 159, 292, True);
2: MouseBox(191, 268, 209, 284, True);
3: MouseBox(303, 281, 328, 288, True);
4: MouseBox(357, 283, 380, 289, True);
end;
end;

procedure MoveToCorner(Num: Integer); // Moves each piece to the corner so they aren't overlapping
var
p, i: Integer;
begin
if (not (LoggedIn)) then Exit;
case Num of
1: begin
repeat
MovePiece(1);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, MSX2, 80)) then Break;
end;
until (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, MSX2, 80));
repeat
MovePiece(3);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, 100, 80)) then
begin
Done[0] := True;
Exit;
end;
end;
until (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, 100, 80));
end;
2: begin
repeat
MovePiece(3);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, 105, MSY2)) then Break;
end;
until (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, 105, MSY2));
repeat
MovePiece(2);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, MSX1, 190, 105, 230)) then
begin
Done[1] := True;
Exit;
end;
end;
until (FindDTM(Bee[Num - 1], x, y, MSX1, 190, 105, 230));
end;
3: begin
repeat
MovePiece(1);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, MSX2, 85)) then Break;
end;
until (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, MSX2, 85));
repeat
MovePiece(4);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 400, MSY1, MSX2, 85)) then
begin
Done[2] := True;
Exit;
end;
end;
until (FindDTM(Bee[Num - 1], x, y, 400, MSY1, MSX2, 85));
end;
4: begin
repeat
MovePiece(4);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 350, MSY1, MSX2, MSY2)) then Break;
end;
p := p + 1;
until (p > 16 + Random(3) + Random(4)); // I call it "quality over perfection" as opposed to "quality of quantity"
repeat
MovePiece(2);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 400, MSY1, MSX2, MSY2))
or (not (FindDTM(Bee[Num - 1], x, y, MSX1, MSY1, MSX2, MSY2))) then
begin
Done[3] := True;
Exit;
end;
end;
until (FindDTM(Bee[Num - 1], x, y, 400, 200, MSX2, 250));
end;
end;
end;


procedure MoveToSpot(Num: Integer); // Moves pieces from the corners to their spots
var
i: Integer;
begin
if (not (LoggedIn)) then Exit;
case Num of
1: Mouse(56, 52, 8, 8, true);
2: Mouse(66, 216, 8, 8, true);
3: Mouse(436, 67, 8, 8, true);
4: Mouse(425, 216, 8, 8, true);
end;
case Num of
1: repeat
MovePiece(4);
for i := 0 to 5 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 210, 25, 310, 75)) then
begin
Done[0] := True;
Exit;
end;
end;
until (FindDTM(Bee[Num - 1], x, y, 210, 25, 310, 75));
2: begin
repeat
MovePiece(4);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 210, 195, 310, 240)) then Break;
end;
until (FindDTM(Bee[Num - 1], x, y, 210, 195, 310, 240));
repeat
MovePiece(1);
for i := 0 to 5 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 210, 80, 310, 125)) then
begin
Done[1] := True;
Exit;
end;
end;
until (FindDTM(Bee[Num - 1], x, y, 210, 80, 310, 125));
end;
3: begin
repeat
MovePiece(2);
for i := 0 to 4 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 400, 140, MSX2, 175)) then Break;
end;
until (FindDTM(Bee[Num - 1], x, y, 400, 140, MSX2, 175));
repeat
MovePiece(3);
for i := 0 to 5 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 210, 140, 310, 175)) then
begin
Done[2] := True;
Exit;
end;
end;
until (FindDTM(Bee[Num - 1], x, y, 210, 140, 310, 175));
end;
4: begin
repeat
MovePiece(3);
for i := 0 to 5 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 210, 185, 310, 245)) then Break;
end;
until (FindDTM(Bee[Num - 1], x, y, 210, 185, 310, 245));
repeat
MovePiece(1);
for i := 0 to 5 do
begin
Wait(100 + Random(400));
if (FindDTM(Bee[Num - 1], x, y, 210, 185, 310, 230)) then
begin
Done[3] := True;
Exit;
end;
end;
until (FindDTM(Bee[Num - 1], x, y, 210, 185, 310, 245));
end;
end;
end;

function FindFirstPiece: TPoint; // Finds a piece that has not been moved yet
var
Cur: Integer;
begin
repeat
if (not (LoggedIn)) then Exit;
if (FindColorSkipBoxArrayTolerance(x, y, 10329514, MSX1, MSY1, MSX2, MSY2, 30, BoxArray)) then
begin
// WriteLN('x: ' + IntToStr(x) + ' y: ' + IntToStr(y));
Cur := GetColor(x, y);
Wait(10);
if (GetColor(x, y) = Cur) then
begin
SetArrayLength(BoxArray, GetArrayLength(BoxArray) + 1);
BoxArray[GetArrayLength(BoxArray) - 1].x1 := x - 1;
BoxArray[GetArrayLength(BoxArray) - 1].x2 := x + 1;
BoxArray[GetArrayLength(BoxArray) - 1].y1 := y - 1;
BoxArray[GetArrayLength(BoxArray) - 1].y2 := y + 1;
end else Break;
end else
begin
Result.y := -1;
Exit;
end;
until (false);
Mouse(x, y, 2, 2, false);
Wait(250 + Random(450));
if (ChooseOption('Ok')) then
begin
Result.x := x;
Result.y := y;
Exit;
end else
begin
SetArrayLength(BoxArray, GetArrayLength(BoxArray) + 1);
BoxArray[GetArrayLength(BoxArray) - 1].x1 := x - 1;
BoxArray[GetArrayLength(BoxArray) - 1].x2 := x + 1;
BoxArray[GetArrayLength(BoxArray) - 1].y1 := y - 1;
BoxArray[GetArrayLength(BoxArray) - 1].y2 := y + 1;
Result.x := -1;
end;
end;

function MoveFirstPiece: Integer; // Moves piece to the bottem so it can be identified
var
Coord: TPoint;
i: Integer;
begin
repeat
Coord := FindFirstPiece;
if (Coord.x > 0) and (Coord.y > 0) then Break;
if (Coord.y = 0) then MMouse(641, 298, 40, 40);
Wait(100 + Random(1900));
if (not (LoggedIn)) then Exit;
until (false);
if (Coord.x < 200) then
begin
MovePiece(4);
Wait(100 + Random(400));
if (Coord.x < 175) then
begin
MovePiece(4);
Wait(100 + Random(400));
if (Coord.x < 150) then
begin
MovePiece(4);
Wait(100 + Random(400));
if (Coord.x < 125) then
begin
MovePiece(4);
Wait(100 + Random(400));
if (Coord.x < 100) then
begin
MovePiece(4);
Wait(100 + Random(400));
if (Coord.x < 80) then
begin
MovePiece(4);
Wait(100 + Random(400));
end;
end;
end;
end;
end;
end;
repeat
MovePiece(2);
for i := 0 to 3 do
if (FindDTM(Bee[i], x, y, 60, MSCY + 27, MSX2 - 150, MSY2)) then
begin
case i of
0: begin
SetArrayLength(BoxArray, GetArrayLength(BoxArray) + 1);
BoxArray[GetArrayLength(BoxArray) - 1].x1 := 25;
BoxArray[GetArrayLength(BoxArray) - 1].x2 := 110;
BoxArray[GetArrayLength(BoxArray) - 1].y1 := 30;
BoxArray[GetArrayLength(BoxArray) - 1].y2 := 100;
end;
1: begin
SetArrayLength(BoxArray, GetArrayLength(BoxArray) + 1);
BoxArray[GetArrayLength(BoxArray) - 1].x1 := 25;
BoxArray[GetArrayLength(BoxArray) - 1].x2 := 105;
BoxArray[GetArrayLength(BoxArray) - 1].y1 := 170;
BoxArray[GetArrayLength(BoxArray) - 1].y2 := 225;
end;
2: begin
SetArrayLength(BoxArray, GetArrayLength(BoxArray) + 1);
BoxArray[GetArrayLength(BoxArray) - 1].x1 := 385;
BoxArray[GetArrayLength(BoxArray) - 1].x2 := MMX2;
BoxArray[GetArrayLength(BoxArray) - 1].y1 := 30;
BoxArray[GetArrayLength(BoxArray) - 1].y2 := 115;
end;
3: begin
SetArrayLength(BoxArray, GetArrayLength(BoxArray) + 1);
BoxArray[GetArrayLength(BoxArray) - 1].x1 := 395;
BoxArray[GetArrayLength(BoxArray) - 1].x2 := MMX2;
BoxArray[GetArrayLength(BoxArray) - 1].y1 := 200;
BoxArray[GetArrayLength(BoxArray) - 1].y2 := MMY2;
end;
end;
Result := i + 1;
WriteLN(IntToStr(i));
Exit;
end;
Wait(100 + Random(400));
until (not (LoggedIn));
end;

function SolveBeeKeeper: Boolean; // Main loop
var
i: Integer;
begin
DeclareDTMs;
TalkTo;
repeat
i := MoveFirstPiece;
MoveToCorner(i);
if (Done[0] = True) and (Done[1] = True) and (Done[2] = True) and (Done[3] = True) then Break;
until (not (LoggedIn));
for i := 0 to 3 do
Done[i] := False;
i := 1;
repeat
MoveToSpot(i);
i := i + 1;
if (Done[0] = True) and (Done[1] = True) and (Done[2] = True) and (Done[3] = True) then Break;
until (not (LoggedIn));
Mouse(257, 279, 4, 4, true); // Clicks build
for i := 0 to 50 do
begin
if (not (InBlack)) then
begin
Result := True;
Break;
end;
Wait(100);
if (i = 50) then
begin
Mouse(498, 20, 4, 4, true);
Wait(1000 + Random(1000));
if (Sec) then
begin
Result := False;
Logout;
Exit;
end;
Sec := True;
SolveBeeKeeper;
end;
end;
end;

begin
SetupSRL;
ActivateClient;
Wait(1000 + Random(1000));
SolveBeeKeeper;
end.

What do you think?


If this does work :D I will add it in my Flax picker if it is Okay ?

~Home

Town

2007-10-24 17:05:33

Yeah, go for it.

t3hl33tn00b

2007-10-24 17:23:03

amazing, i always mess up when i got this at first LOL, kinda sad to think a script can do it better than i can :( . but nice job!

Santa_Clause

2007-10-25 05:13:32

From: n3ss3s
Santy's favourite phrase xD

Nice, I thought it'd be cool to solve this one, but I dont have members acc to auto flax on so I cant get this random, gj.


You know, I was looking through the posts and I saw that I'd already posted. I was also thinking the same thing before I saw what you wrote (h)