SRL Archive - MSI Suggestions

Implimenting Reflection Walking


Coh3n

2010-03-14 23:07:27

I started to try to add the reflection walking (I did manage to add the path to and from the bank - update and look at Walking_Reflection), and I ran into a few problems that I could use some help with. From my understanding, we would like to use reflection walking, with color failsafes, correct? We would also like to have the option to disable the reflection if the hooks are outdated. We would do this using Defines, right?

Problem:

Using reflection and color failsafes isn't as simple as saying:

if (not ReflectionWalk) then
ColorWalk;
What if the reflection walk failed on the third point on the path? That would leave the color method in the wrong location to start, thus causing it to most likely fail.

Well, okay, simple, just do each point individually. Well, again, not so simple. It could easily be done, but then we would have to include reflection no matter what because the color failsafe would have to be right in the MSI_Walk function, which is in a {$IFDEF REFLECTION}.

Possible Solution:

Keep reflection and color walking completely separate. Use one or the other, not both. Let's be honest, what exactly are the chances that the reflection walking is going to fail? This way, the user can easily comment out the {$DEFINE REFLECTION}, telling the script to only use color. I'm sure you know, but it would be useful for when the hooks are outdated, or when using a script that doesn't include any walking.

I, personally, don't see the need for using a failsafe for reflection. I say either use one or the other. You can disagree with me all you want, but I'm easily persuaded to another opinion if I'm presented with reasonable information. :rolleyes:

If everyone is content on using color failsafes, please figure out a way to use it efficiently because I can't. :p

Boreas

2010-03-14 23:40:52

For what's it worth I agree reflection with color backup is pointless. Color with reflection backup is the best way to go. You can start with an implementation that is pretty much the same as reflection with color backup, but it really gets good when you add to it. You can then add data collection methods such as screen shots for when the color does fail, to help you improve the color walking (which will need to get better and better for those mondays/tuesdays without reflection). To go even further, you can add a SmartColors type of system where the script will improve the color walking by itself, knowing what a miss is without actually making the miss. You can also add a global bool for the reflection backup not be used, for those mondays/tuesdays/runetek6.

Coh3n

2010-03-14 23:46:00

From: Boreas
For what's it worth I agree reflection with color backup is pointless. Color with reflection backup is the best way to go. You can start with an implementation that is pretty much the same as reflection with color backup, but it really gets good when you add to it. You can then add data collection methods such as screen shots for when the color does fail, to help you improve the color walking (which will need to get better and better for those mondays/tuesdays without reflection). To go even further, you can add a SmartColors type of system where the script will improve the color walking by itself, knowing what a miss is without actually making the miss. You can also add a global bool for the reflection backup not be used, for those mondays/tuesdays/runetek6.

I really like the screenshots idea, but why would you use reflection as a backup to color? That seems like a step backwards to me. Like what if the color finding didn't fail to find the color, but failed to click the proper area on the minimap and in turn that caused the reflection failsafe tile to not be on the minimap?

Sir R. M8gic1an

2010-03-15 06:05:54

Color walking will aim at certain points. Have reflection aiming at those same points.

If one fails, the other will be in the right place to proceed.

Also, by having color as main with reflection back up you are able to improve color walk.


If not ColorWalkX then
begin
TakeScreenShot;
RecordColors;
end;

Also, walking with reflection, you can collect a whole lotta data for color walking. This is actually one very smart idea. Use reflection to collect data when ref works, meaning that walks will be 100% and we'll have data to make color walks better, and so when ref doesn't work, the color walk should be pretty good.

~RM

Boreas

2010-03-15 09:19:28

From: Coh3n
that caused the reflection failsafe tile to not be on the minimap?


It could be configured to check with reflection after looking at colors but before actually clicking, so you will know you got the wrong color, but don't actually move to the wrong place.

The other way around means that when reflection is down (whether it is hours/days/months) you will be left with color routines that have hardly been used/tested/debugged/developed, exactly at the time when you need them most.

The Claw

2010-03-15 09:45:42

Reflection walking is working?

Coh3n

2010-03-15 11:15:37

From: Rasta Magician
Color walking will aim at certain points. Have reflection aiming at those same points.

If one fails, the other will be in the right place to proceed.

Also, by having color as main with reflection back up you are able to improve color walk.


If not ColorWalkX then
begin
TakeScreenShot;
RecordColors;
end;

Also, walking with reflection, you can collect a whole lotta data for color walking. This is actually one very smart idea. Use reflection to collect data when ref works, meaning that walks will be 100% and we'll have data to make color walks better, and so when ref doesn't work, the color walk should be pretty good.

~RM

Yes, but the walking returns true 99.9% of the time. The problem is that it's walked to the wrong are on the minimap. For example, I've had the walking end up standing beside the tea stall southeast of the bank, or in the Varrock museum.

@Boreas: How would you configure it to confirm with reflection before clicking? Reflection uses tiles, where the TPA walking uses pixels. It wouldn't be as easy as comparing the correct tile to the point found on the minimap.

@The Claw: Yes :) http://villavu.com/forum/showthread.php?t=55588 That's how I found out.

Boreas

2010-03-15 14:17:20

Using an array of tiles is botlike anyway, use an array of boxes to define good areas and convert to pixels.

Coh3n

2010-03-15 14:22:37

From: Boreas
Using an array of tiles is botlike anyway, use an array of boxes to define good areas and convert to pixels.

An array of tile boxes you mean? And how would you go about converting to pixels?

I also thought that if the color walking went to the wrong location, you could then go through the reflection path, and walk to the one it finds on the minimap. There should be at least one because the point it came from would appear on the map.

Blumblebee

2010-03-15 15:44:01

From: Coh3n
An array of tile boxes you mean? And how would you go about converting to pixels?

I also thought that if the color walking went to the wrong location, you could then go through the reflection path, and walk to the one it finds on the minimap. There should be at least one because the point it came from would appear on the map.


I think this is what Boreas means: maybe we should make tile boxes in reflection, get a point in color and check if the point in color is inside the designated reflection box, if not then the script walks to set point inside the box? (although I don't really know how you convert a TPoint to a tile).

or else is there a different way to determine if the color walking didn't walk to a good point?

Sir R. M8gic1an

2010-03-15 15:45:15

Simple Color+Ref integration:

var
TargetC, TargetR: TPoint;
Area: integer;
begin
TargetR := TileToMM(NextTile);
TargetC := //color stuff here, returning the final TPoint to click on the MM

if (distance(TargetR.x, TargetR.y, TargetC.x, TargetC.y) > WALK_TOL) then
begin
Area := TakeScreenShotBMP;
//Paint the Reflection target on the BMP
//Paint the Color target on the BMP
SaveBitmap(Area, 'WalkFail_'+IntToStr(WhichWalk);
Mouse(TargetR.x, TargetR.Y, 3, 3, true);
end;
end;

Not properly coded out, but you get the idea.

~RM

Coh3n

2010-03-15 15:59:48

Yeah, but what about using JUST color if the hooks are outdated? Can you insert defines into that function so it'll work properly?

EDIT: Just a thought, we could keep the reflection/color walking we have and then make a hybrid function, then put that in defines in the mainloop walking procedures.

Sir R. M8gic1an

2010-03-15 16:31:27

It's easy to add defines in there, don't have the time atm.

~RM

Coh3n

2010-03-15 16:36:43

From: Rasta Magician
It's easy to add defines in there, don't have the time atm.

~RM

Yeah, whatever works. If we made a separate function, I think it would be nice and organized. Then the main loop would be something like:


function MSI_WalkToLoc: Boolean;
begin
if (not LoggedIn) then
Exit;

case PlayerSkills[CurrentPlayer][CurrentSkill] of
SKILL_WOODCUTTING:
case Players[CurrentPlayer].Integers[P_LOC] of
LOC_VE_BANK:
{$IFDEF REFLECTION}
Result := MSI_HybridWalk(LOC_VE_BANK, LOC_VE_TREES);
{$ELSE}
Result := MSI_ColorWalk(LOC_VE_BANK, LOC_VE_TREES);
{$ENDIF}

LOC_VE_TREES:
Result := True;

else
MSI_Debug('MSI_WalkToLoc', 'Invalid location for woodcutting skill.', DEBUG_FUNCTIONS);
end;
else
MSI_Debug('MSI_WalkToLoc', 'Invalid player skill!', DEBUG_FUNCTIONS);
end;
end;

It may be easier to keep one function. I'm just throwing ideas out there.

Sir R. M8gic1an

2010-03-16 16:34:14

That's kinda ugly cohen…and way repetitive :p


var
TargetC, TargetR: TPoint;
Area: integer;
begin
TargetC := //color stuff here, returning the final TPoint to click on the MM

{$IFDEF REFLECTION}
TargetR := TileToMM(NextTile);


if (distance(TargetR.x, TargetR.y, TargetC.x, TargetC.y) > WALK_TOL) then
begin
Area := TakeScreenShotBMP;
//Paint the Reflection target on the BMP
//Paint the Color target on the BMP
SaveBitmap(Area, 'WalkFail_'+IntToStr(WhichWalk);
end;
Mouse(TargetR.x, TargetR.Y, 3, 3, true);
{$ELSE}

Mouse(TargetC.x, TargetC.y, 3, 3, true);

{$ENDIF}
end;

hum…
Actually it'd pretty much come down to having two functions anyway >.>

I guess it's a choice between having the clutter in the mainloop or somewhere else.

~RM

Coh3n

2010-03-16 16:53:07

From: Rasta Magician

hum…
Actually it'd pretty much come down to having two functions anyway >.>

I guess it's a choice between having the clutter in the mainloop or somewhere else.

~RM

We could have yet another function:

function MSI_PerformWalk(startLoc, endLoc: Integer): Boolean;
begin
{$IFDEF REFLECTION}
MSI_HybridWalk(startLoc, endLoc);
{$ELSE}
MSI_ColorWalk(startLoc, endLoc);
{$ENDIF}
end;
That may seem like too many extra functions, but that would get rid of the clutter you're talking about, and the main loop walking functions would have only one line. :p

Nava2

2010-03-16 17:25:49

Modularity:
http://en.wikipedia.org/wiki/Modular_programming

tl;dr: Every method should preform exactly one task. (Obviously some exceptions, main loop etc.)

Coh3n

2010-03-16 18:06:19

From: Nava2
Modularity:
http://en.wikipedia.org/wiki/Modular_programming

tl;dr: Every method should preform exactly one task. (Obviously some exceptions, main loop etc.)

Okay :)

What's tl;dr mean? I see it everywhere, but I've never asked. Lol

Sir R. M8gic1an

2010-03-19 07:38:00

From: Coh3n
Okay :)

What's tl;dr mean? I see it everywhere, but I've never asked. Lol


too long, didn't read.

~RM

Coh3n

2010-03-19 16:56:27

From: Rasta Magician
too long, didn't read.

~RM

Ah, so for those lazy people. :p

Sir R. M8gic1an

2010-03-20 10:56:05

From: Coh3n
We could have yet another function:

function MSI_PerformWalk(startLoc, endLoc: Integer): Boolean;
begin
{$IFDEF REFLECTION}
MSI_HybridWalk(startLoc, endLoc);
{$ELSE}
MSI_ColorWalk(startLoc, endLoc);
{$ENDIF}
end;
That may seem like too many extra functions, but that would get rid of the clutter you're talking about, and the main loop walking functions would have only one line. :p


Sounds Perfect ^ And the need for this has just been made more obvious as the hooks broke (again).

~RM

Coh3n

2010-03-20 12:27:24

From: Rasta Magician
Sounds Perfect ^ And the need for this has just been made more obvious as the hooks broke (again).

~RM

Wonderful…

Coh3n

2010-03-24 21:11:07

Alright, I came up with a rough draft of MSI_HybridWalk. The color walking needs to be slightly altered to work with this, but I've talked it over with NCDS and there's no problem at all.

const
WALK_TOL = 10; //the tolerance for a color point compared to a reflection point

function MSI_HybridWalk(startLoc, endLoc: Integer): Boolean;
var
colorPath: TIntegerArray;
refPath: TPointArray;
colorPoint, refPoint: TPoint;
begin
colorPath := MSI_LoadColorPath(startLoc, endLoc);
refPath := MSI_LoadRefPath(startLoc, endLoc);

for i := 0 to High(colorPath) do
begin
colorPoint := MSI_CreateWalkIndex(colorPath[i]);
refPoint := TileToMM(refPath[i]);

if (Distance(refPoint.x, refPoint.y, colorPoint.x, colorPoint.y) > WALK_TOL) then
begin
MSI_Debug('MSI_HybridWalk', 'Failed to color walk to ' + MSI_LocToStr(endLoc) + ', index ' + i, DEBUG_FUNCTIONS);
//do color gathering stuff here
Mouse(refPoint.x, refPoint.y, 4, 4, True);
end else
Mouse(colorPoint.x, colorPoint.y, 4, 4, True);

Result := (i = High(colorPath));
MSI_WaitWhileWalking;
end;

if (Result) then
MSI_Debug('MSI_HybridWalk', 'Hybrid walk successful!', DEBUG_FUNCTIONS);
end;

function MSI_PerformWalk(startLoc, endLoc: Integer): Boolean; //this would be the one to go in MSI_WalkToLoc and MSI_WalkToBank
begin
{$IFDEF REFLECTION}
MSI_HybridWalk(startLoc, endLoc);
{$ELSE}
MSI_ColorWalk(startLoc, endLoc);
{$ENDIF}
end;
Just wanted to see what you guys think so far. It's basically the same thing RM wrote further up on the thread. :)

Blumblebee

2010-03-25 00:50:44

I'm having issues with getting the correct hooks to get reflection walking working again, could I get a list of the hooks names (In the RSBot/Avalone/MGHTY) that are the correct resemblance for SRL's?

Coh3n

2010-03-25 12:14:13

From: Blumblebee
I'm having issues with getting the correct hooks to get reflection walking working again, could I get a list of the hooks names (In the RSBot/Avalone/MGHTY) that are the correct resemblance for SRL's?

They're just the walking ones. Wouldn't they have the same name as the ones in hooks.scar? All the ones that you don't need are set to 'null' I'm pretty sure.

Boreas

2010-03-25 15:02:47

Not always, varies depending on updater authors.

Coh3n

2010-03-25 15:24:35

From: Boreas
Not always, varies depending on updater authors.

Oh well in that case, Blumblebee, if you work it out, throw me a PM. ;)

Otherwise, I'll try to figure it out if I ever get my homework done.

Blumblebee

2010-03-25 16:22:38

From: Coh3n
Oh well in that case, Blumblebee, if you work it out, throw me a PM. ;)

Otherwise, I'll try to figure it out if I ever get my homework done.


I've been trying continuously for the last while to no avail. I will continue to try to get the proper names etc.

I'm using the avalone one's atm, which are identical to MGHTY's too. If I manage to get it figured out I'll let you know. I think I'll add onto Widget's hook stealer to rename the hooks and only steal the one's needed for walking.

Coh3n

2010-03-25 22:57:22

From: Blumblebee
I've been trying continuously for the last while to no avail. I will continue to try to get the proper names etc.

I'm using the avalone one's atm, which are identical to MGHTY's too. If I manage to get it figured out I'll let you know. I think I'll add onto Widget's hook stealer to rename the hooks and only steal the one's needed for walking.

Sounds great! Because I have no idea who/what Avalone/MGHTY are/is. I also know nothing about getting the hooks, etc. :p

Coh3n

2010-03-27 17:37:03

I have completed this and I'm testing it now. From what I've seen so far, it works awesome. Also, when I go to update my MSI folder I get this:

svn: 'http://www.villavu.com/repositories/msi' path not found
:confused:

Gu3st...

2010-03-27 19:20:55

From: Coh3n
I have completed this and I'm testing it now. From what I've seen so far, it works awesome. Also, when I go to update my MSI folder I get this:

svn: 'http://www.villavu.com/repositories/msi' path not found
:confused:
Take away the www silly ;) (i think it should work)
http://villavu.com/repositories/msi/

Coh3n

2010-03-27 19:32:35

That's weird though cause I've never changed the link since I did the original checkout. I'll try this when I get back home. Thanks

mastaraymond

2010-03-27 19:35:52

From: Coh3n
That's weird though cause I've never changed the link since I did the original checkout. I'll try this when I get back home. Thanks

Has to do with a recent change of server software (might be fixed by now)

Nava2

2010-03-27 20:11:28

It was because Wizzup was messing with the repos, bad timing on Coh3n's behalf. Not his fault though.

Coh3n

2010-03-27 23:01:34

From: Nava2
It was because Wizzup was messing with the repos, bad timing on Coh3n's behalf. Not his fault though.

Apparently. :p

It's working now. :)