SRL Archive - SRL Archives

'SmartColors'


tarajunky

2007-09-21 16:01:38

I have been using an array based color search strategy in my Chickenkiller and VEM scripts for about 6 months, and it works very well.

Most FindObj type procedures are based on searching for a color with tolerance. So, you find all the colors of that type and systematically move the mouse to each spot to check the uptext.

This strategy extends that functionality by then saving positive 'hits' to an array. The next time you search, it will first look for each of these exact known colors in the array. If none of them are found it will then revert back to a tolerance based scan. I also made it so that when a known color is found again, it will move that color forward in search priority within the array.

Here is an annotated example from my miner…


Function FindCopper:boolean;
var x,y,TestColor,a,l,m,i,red,green,blue:integer;
var p: array of Tpoint;
begin
FFlag(0);
Wait(50);
Status('Finding Copper');
l:=GetArrayLength(CopperColors); //Checks known colors first
if l>0 then
begin
for i:= 0 to l-1 do
begin
FindColorsSpiralTolerance(MSCX,MSCY,p,CopperColors[i],MSX1,MSY1,MSX2,MSY2,0);
m:=GetArrayLength(p);
if m>0 then
begin
for a:= 0 to m-1 do
begin
if CheckAndClick(p[a].x,p[a].y) then //Moves mouse to position, checks uptext and clicks if correct.
begin
result:=true;
if i>0 then //if the color is not in the first position of the array...
begin // Swap found color with the one ahead of it in the array
m:=CopperColors[i-1];
CopperColors[i-1]:=CopperColors[i];
CopperColors[i]:=m;
end;
exit; // We found our color, so we exit the function completely.
end;
end;
end;
end;
end;
//We didn't find any known colors, so continue on to the tolerance search
FindColorsSpiralTolerance(MSCX,MSCY,p,4153992,MSX1,MSY1,MSX2,MSY2,25);
l:=GetArrayLength(p);
if l>0 then
begin
for i:= 0 to l-1 do
begin
TestColor:=GetColor(p[i].x,p[i].y); //Additional autocoloring to reduce wrong points. (Optional)
red:=(TestColor mod 256);
green:=((TestColor/256) mod 256);
blue:=((TestColor/256) / 256);
if ((green-blue)<=46) then if ((green-blue)>=24) then
if ((red-green)>=26) then if ((red-green)<=51) then
if ((red-blue)>55) then if ((red-blue)<=94) then
begin
Wait(20);
ClickColor:=GetColor(p[i].x,p[i].y);
if CheckAndClick(p[i].x,p[i].y) then //Move mouse, check uptext and click
begin
result:=true;
FindColorsSpiralTolerance(x,y,p,ClickColor,MSX1,MSY1,MSX2,MSY2,0);
if GetArrayLength(p)<20 then //Make sure that the color is somewhat rare, and doesn't take up half the screen
begin
a:=GetArrayLength(CopperColors);
for i:= 0 to a-1 do
begin
if ClickColor=CopperColors[i] then //If color is already in the array...
begin
if i>0 then
begin // Move it up one spot in the array search priority
m:=CopperColors[i-1];
CopperColors[i-1]:=CopperColors[i];
CopperColors[i]:=m;
end;
exit;
end;
end;
// if it's not in the array yet, then add it to the end of the array
SetArrayLength(CopperColors,a+1);
CopperColors[a]:=ClickColor;
Writeln(IntToStr(ClickColor)+' added to Copper Color array');
end;
exit;
end;
end;
end;
end;
end;

This approach allows your script to 'learn' which colors best match the object you want to find as it runs. This is especially helpful for colors that either move around a little bit and change due to the background behind them, or for colors that are sometime hidden and sometimes there depending on the position and angle of the screen.

SKy Scripter

2007-09-21 16:13:36

Thats what i did kinda with my guild miner i was working on… it works very well…

Killerdou

2007-09-21 16:19:06

:mad: people need to learn to find entire objects, not just colors :mad:

WT-Fakawi

2007-09-21 16:22:13

When saving a positive hit, does it save the actual color it found, or the predefined color in the array? I was thinking about a function like that, that would replace the predefined colors with the actual colors found in the mainscreen, thereby increasing the found ratio to 100% and stopping the tol lag, since we dont need tol anymore.


EDIT: It would be wonderfull for finding Goblins and getting the colors right for the next couple of hours while running the script.

the scar noob

2007-09-21 16:35:46

It's a tiny advanced, can someone explain it a little better for me plz?

n3ss3s

2007-09-21 16:44:58

It would be wonderfull for finding Goblins and getting the colors right for the next couple of hours while running the script.


We are on the same brain "channel" when it comes to killing goblins ;)

people need to learn to find entire objects, not just colors


Haha, iluf is pissed since he has uber leet object finder but we need only one coordinate xD (no offense, its gr8 ;) )

But lets see umm, when compass faced north, sun shines always from left to right in rs, so the darker side of everything is on right, couldnt that be somehow abused in color finding?

Killerdou

2007-09-21 16:52:42

you have to agree though, this is perfection(200ms - 120ms for the drawing):

R0b0t1

2007-09-21 19:34:19

Whoa? WTF? Did you get SCAR to draw that on the client? Well, no matter.


You've got me thinking again TaraJunky.

tarajunky

2007-09-21 21:13:41

From: WT-Fakawi
When saving a positive hit, does it save the actual color it found, or the predefined color in the array? I was thinking about a function like that, that would replace the predefined colors with the actual colors found in the mainscreen, thereby increasing the found ratio to 100% and stopping the tol lag, since we dont need tol anymore.


EDIT: It would be wonderfull for finding Goblins and getting the colors right for the next couple of hours while running the script.


The color array begins completely empty. Each successful search picks the actual color being shown on the screen and puts it into the array.

Not every color is going to be right! Like if you search for a brown color and find someone with bronze armor standing in front of your object, it might register as a positive hit, but it would never find the right object again once the player moves away. So, as it finds more and more colors, it automatically moves the colors that are working the best to the front of the array, while those that don't work very well get sent to the back of the line.

That's why I call it 'SmartColors', the script learns and improves as it runs.

The Claw

2007-09-21 21:44:24

Interesting approach, do you have any figures for the time that this takes compared to the time a normal search with tol would take?

R0b0t1

2007-09-21 22:20:34

Lolz, making a neuron system now… Must… Finish…


type
TNeuron = record
Data: String;
end;

Bourdou!

2007-09-21 22:23:08

Iloveit…



HOWYOUDOTHAT!? Seriously, teach me.

Kik

2007-09-21 22:35:10

Good idea tarajunky - the next step up from auto coloring.

From: iloveit8
you have to agree though, this is perfection(200ms - 120ms for the drawing):


That's amazing - I think somebody should forcibly make you post the script that's drawing that :stirthepot:

Bobarkinator

2007-09-22 01:15:52

From: tarajunky
The color array begins completely empty. Each successful search picks the actual color being shown on the screen and puts it into the array.

Not every color is going to be right! Like if you search for a brown color and find someone with bronze armor standing in front of your object, it might register as a positive hit, but it would never find the right object again once the player moves away. So, as it finds more and more colors, it automatically moves the colors that are working the best to the front of the array, while those that don't work very well get sent to the back of the line.

That's why I call it 'SmartColors', the script learns and improves as it runs.


Can't you just use uptext and get rid of all those "bad colors" that aren't really you're object? It would make your array better and you could still move the better ones to the top.

Wizzup?

2007-09-22 04:46:41

From: Bourdou
Iloveit…



HOWYOUDOTHAT!? Seriously, teach me.


Array sorting mainly..
You can do alike things with wizzyplugin I guess.

OnTopic, tara what if you have made sure something is a rock, do a findcolorstolerance with a 'high' (20) tolerance, shrink array and store all those 'colors'?

n3ss3s

2007-09-22 05:08:58

You can do alike things with wizzyplugin I guess.
Jealous much ?!?!!?

That's amazing - I think somebody should forcibly make you post the script that's drawing that


Its floatin somewhere on the forums, use search for "Love Advanced Object Finder"

Wizzup?

2007-09-22 05:53:19

From: n3ss3s
Jealous much ?!?!!?


I guess thats a joke?
If you want to continue this do that in the BBQ not here, Tarajunky made a nice function so let's discuss and praise that instead. :)

Markus

2007-09-22 07:51:15

This is a very nice way to reduce tolerances, saw it in your chicken killer :)

[offtopic]
140 ms, drawing and convering to a T2DBoolArray included. Still need to tweak the treshholds a bit.
[/offtopic]

rkroxpunk

2007-09-22 08:11:43

so this could potentially be faster/more accurate or a bit slower yes?

n3ss3s

2007-09-22 08:26:04

Yes wizzup ofcourse it was a joke!
-.- your post was friken scary :(


Markus, where is that from?

Killerdou

2007-09-22 08:35:40

he wont give it for free XD

Markus

2007-09-22 08:40:46

From: n3ss3s
Markus, where is that from?


Canny edge detection, in Delphi and C (hybrid)

From: iloveit8
he wont give it XD

Correction.

Bourdou!

2007-09-22 10:28:07

From: Markus
Canny edge detection, in Delphi and C (hybrid)
So I'm confused… Then you would search for the shape? And does it continually turn it like that, or just when it sits still? Seems like it would slow scar down quite a bit.

n3ss3s

2007-09-22 12:01:54

Correction.


Umm that means that you are selling it, right?

But if its for sale, we cant use it in our scripts, or I mean publish scripts than pwn using it? :(

umm how much you're planning the price to be?

Markus

2007-09-22 13:30:12

It's not for sale, it's part of a payscript, and only that single script is able to use it after a succesful authentication (so it's part of the auth system, XD)

Bourdou!

2007-09-22 13:31:03

Oh. That stinks :(.

nielsie95

2007-09-22 13:48:20

Ben has made such an edgedetector too, if you're interested..

But now on-toppic please.

tarajunky

2007-09-22 13:49:58

From: The Claw
Interesting approach, do you have any figures for the time that this takes compared to the time a normal search with tol would take?


The two main benefits to this strategy are SPEED and ACCURACY.

Since you are searching for exact colors with zero tolerance, the search is extremely accurate. And since you are only doing single color searches for each one, it is very fast.

You can scan the main screen for 10 or 20 colors in the time it takes to move the mouse over and check a single point. So, if you have have to search through 20 colors before you find a point, you still only have 1 mouse movement directly to the object for a click. Very fast, very accurate.

I can't speak for any other search method for speed or accuracy, but try this one out if it sounds like it would work for you.

oliver1205

2007-09-22 18:56:25

i saw this is ur chicken killer. it looks great

Lorax

2007-10-02 17:32:50

So basically color memorization..
Does the colors change when the screen moves? because of the 3d effects?
or could you have the same 3 colors and it would allways find the correct object?

I did a test and with 11 FindColors it takes around 109 ms..

so which is faster? FindColors, TPAtoATPA, Length, MiddleTPA
or 11 FindColors?

Someone will have to try it out ..

WT-Fakawi

2007-10-02 18:21:07

I would like a NPCColor scanner, that:
  • during an "initialisation" phase scans for unque colors (<- most NPC-colors are unique)
  • stores these to a assignable array of lets say 4-16 colors? so
    GoblinColor[] := ScanNPC('Goblin');
  • Uses a custom FindObj that handles arrays.
After that a FindObj('G'GoblinColor[])will be 100% accurate. No more wacky mouse movements, and very accurate spotting. Colors stay constant as long as you stay on one world AFAIK. The facing has great affect on the colors picked.

The Claw

2007-10-02 22:30:04

From: Lorax
So basically color memorization..
Does the colors change when the screen moves? because of the 3d effects?
or could you have the same 3 colors and it would allways find the correct object?

I did a test and with 11 FindColors it takes around 109 ms..

so which is faster? FindColors, TPAtoATPA, Length, MiddleTPA
or 11 FindColors?

Someone will have to try it out ..


In my Lumby swamp miner, I do an initial FindColor to get the first co-rds, then I do another FindColor to check for the rock colour around it. Then I do a FindColors of the rock color in that 20 x 20 box, and if the array is longer than 10, I say its a rock. Then I find the rock center, which has 2 CTS Changes, 2 FindColors, a Length check, then a CombineTPA of the 2. Then it adds all the x and y co-ords together, and divides by the array length. Lastly, if everything goes well, it does a GasFound above the rock. Then it clicks it.

It's a fair bit to do for each rock, but it takes between 200-600 ms in most cases, which is quite a lot on paper, but in game its not that much at all. It usually beats legits to the rock when one appears. To be completely accurate though, you would need to do the tests multiple times on the same computer, of course.

pwnaz0r

2007-10-03 13:36:58

Tara, I hope you dont mind if i use this in my script. I have a few functions made for it so if you could pm i would be grateful(or msn [email]Pwnaz0r@hotmail.com[/email])

thnx,
pwnaz0r

the scar noob

2007-11-24 09:47:37

I want to understand this and how to use this incredible way of storing the colors in an array.
Can someone explain me how I shouls use this please? If possible, a completely explained example of it should also help tons!:)

I'm really willing to understand this and use this way for finding objects.

Thanks in advance,

Regards,

-Tsn.

Negaal

2007-11-28 13:40:09

From: R0b0t1
Whoa? WTF? Did you get SCAR to draw that on the client? Well, no matter.



Yes, I got question about that too, how to make scar drawing something… i wanted to test does my script follows rock, i had to use movemouse :p

Anyone explains me that?

tarajunky

2007-11-28 16:07:52

Here, I wrote up this example script with annotations. It's pretty basic, and I'm not even sure it works, but if you want to try it out on some chickens, it might! Let me know if it helps you out.

From: the scar noob
I want to understand this and how to use this incredible way of storing the colors in an array.
Can someone explain me how I shouls use this please? If possible, a completely explained example of it should also help tons!:)

I'm really willing to understand this and use this way for finding objects.

Thanks in advance,

Regards,

-Tsn.

tarajunky

2007-11-28 20:51:55

LOL, sorry for double post, but it actually does find and attack chickens.

Of course, it doesn't stop and wait to walk over and fight the chicken, or clear the array for a new search once you find one, or any number of other problems, but I hope it demonstrates the principle behind finding an object with this method.

One thing that DEFINITELY needs to be added is an EXIT command after finding and clicking the object, so it doesn't just continue searching the screen. Other than that, it really depends on what you are doing with the script.

the scar noob

2007-12-04 13:44:16

From: tarajunky
Here, I wrote up this example script with annotations. It's pretty basic, and I'm not even sure it works, but if you want to try it out on some chickens, it might! Let me know if it helps you out.


First of all I wan tto thanks you , it's greatly appreciated that you spent your time helping me out, thank you very much!

I like the comments, even by just read it all quickly I understand a lot more.

Now comes the honestly part:)
I cannot study and test this now, because I'm studing for an exam for tomorrow atm.
I will surely (with that I mean, that I hope I won't forget this thread XD) read this again, test and try making my own object finding by using this method.

Again, greatly appreciated that you took the time to help me:)

Regards,

-Stijn.