SRL Archive - SRL Archives

Bee_Puzzle


Wanted

2009-12-04 19:33:22

Edit: Improved beekeeper massively, thanks to Coh3n for the account. Updated script and attachment:

New beekeeper.scar

//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- »» Bee Keeper Solver Routines --//
//-----------------------------------------------------------------//
// * function BeeScreen: Boolean; // * by ZephyrsFury
// * function Bee_Convo: Boolean; // * by ZephyrsFury
// * function Bee_Puzzle: Boolean; // * by Lord Saturn Remade by IceFire908
// * function SolveBeeKeeper: Boolean; // * by Lord Saturn & ZephyrsFury
//-----------------------------------------------------------------//

{*******************************************************************************
function BeeScreen: Boolean;
By: ZephyrsFury
Description: Returns True if the Bee Hive Construction screen is open.
*******************************************************************************}

function BeeScreen: Boolean;
begin
Result := (GetColor(500, 20) = 39423);
end;

{*******************************************************************************
function Bee_Convo: Boolean;
By: ZephyrsFury
Description: Handles the conversation with the Bee Keeper.
*******************************************************************************}

function Bee_Convo: Boolean;
var
T: integer;
begin
T := GetSystemTime;
while (GetSystemTime - T < 20000) do
begin
if (BeeScreen) then Break;
ClickContinue(True, True);
FindTextTpa(0, 0, MCX1, MCY1, MCX2, MCY2, 'Yeah', NPCChars, ClickLeft);
Wait(100 + Random(500));
end;
Result := BeeScreen;
end;

{*******************************************************************************
function Bee_Puzzle: Boolean;
By: Lord Saturn remade by IceFire908
Description: Tries to build the bee hive.
*******************************************************************************}
function Bee_Puzzle: Boolean;
var
StartPs, DestPs: array [0..3] of Boolean;
DestP, StartP, TPA: TPointArray;
PartColors: TVariantArray;
T, C: LongInt;
I, II: Byte;
P: TPoint;
begin //lwr mid lid legs
PartColors := [GetColor(454, 267), 0.00, 3.71, GetColor(429, 212), 0.00, 2.81, 5592409, 4.17, 0.06];
StartP := [Point(79, 55), Point(80, 104), Point(81, 156), Point(76, 205)];
DestP := [Point(260, 151), Point(260, 48), Point(258, 204), Point(259, 98)];
for I := 0 to 2 do
begin
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(PartColors[1 + (3 * I)], PartColors[2 + (3 * I)]);
T := GetSystemTime;
while ((not (FindColorsTolerance(TPA, PartColors[3 * I], 30, 31, 124, 219, 1))) and ((GetSystemTime - T) < 7000)) do
Wait(RandomRange(500, 750));
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(1);
if (Length(TPA) < 1) then
Continue;
P := MiddleTPA(TPA);
if (not (PointInBox(P, IntToBox(30, 31, 124, 219)))) then
Continue;
for II := 0 to 3 do
if ((Distance(80, P.Y, StartP[II].X, StartP[II].Y) < 20) and (not (StartPs[II]))) then
begin
StartPs[II] := True;
P := StartP[II];
Break;
end;
if (I > 3) then
Continue;
if (not (DestPs[I])) then
begin
DestPs[I] := True;
DragMouse(P.X, P.Y, 2, 2, DestP[I].X, DestP[I].Y, 2, 2);
Wait(RandomRange(200, 500));
end;
end;
for I := 0 to 3 do
if (not (StartPs[I])) then
for II := 0 to 3 do
if (not (DestPs[II])) then
begin
StartPs[I] := True;
DestPs[II] := True;
DragMouse(StartP[I].X, StartP[I].Y, 2, 2, DestP[II].X, DestP[II].Y, 2, 2);
Wait(RandomRange(200, 500));
end;
c := CountColor(0, MCX1, MCY1, MCX2, MCY2);
Mouse(270, 275, 10, 5, True);
T := GetSystemTime;
while (CountColor(0, MCX1, MCY1, MCX2, MCY2) = c) do
begin
if (GetSystemTime - T > 5000) then Break;
Wait(100);
end;
Result := FindTextTpa(0, 0, MCX1, MCY1, MCX2, MCY2, 'move', NPCChars, Nothing);
if Result then
begin
T := GetSystemTime;
while (PercentBlackMM = 100) do
begin
if (ClickContinue(True, True)) then
begin
Wait(500 + Random(100));
T := GetSystemTime;
end;
if GetSystemTime - T > 15000 then Exit;
Wait(100);
end;
end;
Result := (PercentBlackMM < 100);
end;

{*******************************************************************************
function SolveBeeKeeper: Boolean;
By: Lord Saturn & ZephyrsFury
Description: Solves the Bee Keeper Random.
*******************************************************************************}

function SolveBeeKeeper: Boolean;
var
Tries: Integer;
begin
for Tries := 0 to 3 do
begin

if (PercentBlackMM < 100) then
begin
Result := True;
Exit;
end;

if Bee_Convo then
Result := Bee_Puzzle;

if (Result) then
Exit;

if (Tries < 3) then
WriteLn('Failed to solve, retrying...');
end;
end;

WT-Fakawi

2009-12-04 19:40:06

Well, as long as it meets all neccesary requirements, (no loops, logout on fail, no funny mouse stuff etc) and don't see any reason why we shouldn't give it a try.

Wanted

2009-12-04 23:28:52

It might seem simple from just the look at it, but it was the best way I could find after testing 2 other methods that were more complicated and less stable.

Basically it finds unique colors on each piece and finds the height of that color, drags the mouse from that height with a fixed X to a static location on the right where the pieces belong. It meets all those requirements you have.

Really though, if anyone wants I'll pm you the account info so you can work on beekeeper or whatever, I just thought I'd give a crack at solving it myself.

Edit: I think the colors change every 4 hours, so I've compiled this using some small tolerances and it seems to be working again now.

YoHoJo

2009-12-04 23:29:52

Tested for him

Successfully compiled (10121 ms)
SRL Compiled in 31 msec
Solved puzzle in 8609 ms!
Successfully executed


Good Sht

Wanted

2009-12-05 14:51:52

Attached a full version of beekeeper.scar if anyone wants

here's the code if you're too lazy to scroll up.

Edit: removed old

marpis

2009-12-05 14:56:30

I'll commit this right away..

E: Ok, done! :)

Wanted

2009-12-05 15:03:53

Cool, if anyone gets this random it would be good if you could test it, me and lordsaturn were just talking about how fast it should search for the colors of each piece (seeing as they are rotating) right now it checks around 2 times per second for 5 seconds, lordsaturn was suggesting 20 a second and I told him if we can test it by all means change it (I cant test anymore because my account accidentally exited the random), but it should work really fast though as consecutive tests have shown.

Town

2009-12-05 19:11:23

I had one fail earlier today with the old version so I'll assume the problem was fixed here. It did continue attempting to solve the random while logged out for upwards of 3 hours, though, so if it hasn't been accounted for it may be beneficial to add "if not LoggedIn then Exit;" at points.

Wanted

2009-12-07 01:02:35

From: Town
I had one fail earlier today with the old version so I'll assume the problem was fixed here. It did continue attempting to solve the random while logged out for upwards of 3 hours, though, so if it hasn't been accounted for it may be beneficial to add "if not LoggedIn then Exit;" at points.


Do you still have the account in the random? That couldn't happen with the new one, but it wouldn't hurt to have one of those in the main loop.

Edit:

Had to fix solver:

Tested, works good, ask YoHoJo for account info, someone confirm this works please:

Test Script:

Edit Removed old

YoHoJo

2009-12-07 02:44:51

Tested, dragmouse is being odd, scripts dragging pieces to right spot, but often letting go too early?/Not letting go before going to grab a new piece from the left? I think a small wait or something needs to be added to dragmouse in SRL, sorry Ice, but account is out of the random now, I needed it :/. Tested 4 times, each time dragmouse was being odd so just add waits to SRLs dragmouse, and fix'd!

Wanted

2009-12-07 11:51:18

From: YoHoJo
Tested, dragmouse is being odd, scripts dragging pieces to right spot, but often letting go too early?/Not letting go before going to grab a new piece from the left? I think a small wait or something needs to be added to dragmouse in SRL, sorry Ice, but account is out of the random now, I needed it :/. Tested 4 times, each time dragmouse was being odd so just add waits to SRLs dragmouse, and fix'd!


I'm on mobile but it be a good idea if someone could switch out beekeeper and tweak drag mouse in mouse.scar

marpis

2009-12-07 15:47:51

I know it's not Beekeeper.SCAR problem but the random is not detected if not in chat with the Bee keeper, not even if the Beescreen is open.

Also, it didn't recognize any of the parts. :-\

Wanted

2009-12-11 18:46:28

Sorry to double post, but if someone could update it on their next commit that would be great, I'm very confident this will work from detecting random to exiting as I just tested it.

Still have 2 prison petes, 2 mordauts, leo, pillary, and frog gonna try solving em if you want help or to borrow accounts PM me.

Nava2

2009-12-11 18:58:25

Committed, I hope they work ;) I couldn't compile it.

Wanted

2009-12-30 16:41:22

Updated Beepuzzle, the old one failed at guessing and the cords for the destination/start points were a little off. Now it should really work, I made a new sorting system. See first post for attachment/script

Cheers.