SRL Archive - Research & Development Lounge

Finding the correct stall


k9thebeast

2014-03-09 04:43:44

So there are three stalls next to eachother, and I'm using Auto Color Aid (ACA) to grab a color from one of them. DTMs are not working well for this. The only color that really works is the top of the stall, but there are three stalls right next to eachother. I can use the uptext function to check that the color it finds is on the correct stall.

If the color it finds and moves the mouse to isnt the correct stall, I have it re-search using a simple recursive call. However, sometimes it gets stuck in a loop always finding the same color in the same exact spot. I have experimented with moving the mouse in random directions before the recursive call, but that doesnt work.

The code is simple

If FindColorSpiralTolerance(X,Y,StallColor,MSX1,MSY1,MSX2,MSY2,0) Then

I have thought about editing the "search" x,y,x1,y1 values, but I really dont wan't to as this could lead to trouble I dont want to have to deal with. Does anyone have any ideas?
Thanks
k9

riwu

2014-03-09 06:55:04

You need to learn about TPAs and ATPAs for a much more reliable object searching method (grouping all points found, sorting from mid point, looping through with a text check etc)

k9thebeast

2014-03-09 07:01:42

From: riwu
You need to learn about TPAs and ATPAs for a much more reliable object searching method (grouping all points found, sorting from mid point, looping through with a text check etc)



Thanks for a response. This is on an rsps but ill definitely check this out. Thanks!

rj

2014-03-09 13:12:34

From: k9thebeast
Thanks for a response. This is on an rsps but ill definitely check this out. Thanks!


IF you use my rsps include (found at https://github.com/officerBarbrady/srlRSPS), you can check for uptext. Quick TPA/ATPA example:

{$I RSPS/srlRSPS.Simba}

var
someServer:_rsps_server;


procedure mmouse(p:TPoint);overload;
begin
mmouse(p.x, p.y, 0, 0);
end;

function findStall:boolean;
var
i:integer;
tpa:TPointArray;
atpa:T2dPointArray;
begin
// Find all colors of the color, and store the point into 'tpa'
findColorsTolerance(tpa, color, x1, y1, x2, y2, tolerance);
// if no colors are found then exit
if (length(tpa) = 0) then exit;
// group all the tpas into a array of tpa that are within 8 pixels
// of each other
atpa := tpa.cluster(8);
// loop through the array of tpa
for i := 0 to high(atpa) do
begin
// move mouse to middle of that tpa
mmouse(atpa[i].getMiddle());
//if the uptext is found then click
if (someServer.waitUpTextMulti(['tall', 'Stall'], 150)) then
begin
clickMouse2(mouse_left);
exit(true); // exit and return true
end;
end;
end;

begin
someServer.init(318, 'RSPS');
if findStall() then
writeln('We found the stall')
else
writeln('Did not find the stall');
end.

k9thebeast

2014-03-10 06:15:58

Thanks officer, Yea I have my own uptext function for the rsps

function findStall:boolean;
var
i,color,tol:integer;
tpa:TPointArray;
atpa:T2dPointArray;
begin
color := 0;
tol := 0;
findColorsTolerance(tpa, color, MIX1, MIY1, MIX2, MIY2, tol);
// if no colors are found then exit
if (length(tpa) = 0) then exit;
// group all the tpas into a array of tpa that are within 8 pixels
// of each other
atpa := tpa.cluster(8);
// loop through the array of tpa
for i := 0 to high(atpa) do
begin
// move mouse to middle of that tpa
mmouse(atpa[i].getMiddle());
//if the uptext is found then click
writeln(_317_getuptextBlue());
if (_317_getuptextBlue() = 'Scimitar Stall') then
begin
clickMouse2(mouse_left);
exit(true); // exit and return true
end;
end;

It keeps giving me an error Semicolon (';') expected at line 23 (which in my program is the line)

  // loop through the array of tpa

Any ideas?

Thanks!

Brotein

2014-03-10 16:20:22

I think you are missing an "end;", you have 3 begins and 2 ends.

rj

2014-03-10 16:30:18

From: k9thebeast
Thanks officer, Yea I have my own uptext function for the rsps

function findStall:boolean;
var
i,color,tol:integer;
tpa:TPointArray;
atpa:T2dPointArray;
begin
color := 0;
tol := 0;
findColorsTolerance(tpa, color, MIX1, MIY1, MIX2, MIY2, tol);
// if no colors are found then exit
if (length(tpa) = 0) then exit;
// group all the tpas into a array of tpa that are within 8 pixels
// of each other
atpa := tpa.cluster(8);
// loop through the array of tpa
for i := 0 to high(atpa) do
begin
// move mouse to middle of that tpa
mmouse(atpa[i].getMiddle());
//if the uptext is found then click
writeln(_317_getuptextBlue());
if (_317_getuptextBlue() = 'Scimitar Stall') then
begin
clickMouse2(mouse_left);
exit(true); // exit and return true
end;
end;

It keeps giving me an error Semicolon (';') expected at line 23 (which in my program is the line)

  // loop through the array of tpa

Any ideas?

Thanks!


Try adding

{$I srl-6/lib/utilities/types.simba}

at the top, because it probably doesn't recognize the functions like mmouse(atpa.getMiddle()); and atpa := tpa.cluster(8);


also can we get a screeny of the stall?