SRL Archive - Help and Support

Color challenge: Agility arena locating


masterBB

2011-07-07 10:14:30

Anybody up for a challenge? Cause I got one for you.

I'm making a agility arena script which needs some solid locating. I've tried many things; dtms, bitmap and TPAs. They are all to slow or unreliable.

Original map

Try: TPA map
In this example I filled a TPA with the black color and draw it white. I Also made a TPA from box with the size of the Minimap. I draw that one green. This took without drawing around 600-700 ms.


U notice the white dots on the green platform? Those are the points I need! My idea was to look between which ones I could make a green bridge, probably with a flood function. I could also count them to see if I'm on an edge. But to get them I used SplitTPA, this one however takes over 3,5 seconds! This is much to slow. I need to run this function every one or two obstacles to check if I'm still on track. And I only get 60 seconds to reach the next ticket machine.

Try: Bitmaps

Very time consuming. But I made a small bitmap of every platform. However cause of searching on the minimap. These are sometime a bit different. Searching for a deformed bitmap would solve this. But that function is even slower than previous method! I can't get it right.

Try: DTM

I tried making Dtms with the black dot as middle point. But this one gives to many results with high tolerance, or not enough with low tolerance. This is caused by the platforms having a lot of different colors. Which seems to be moving a bit.

Final

Does anyone has a better idea? Or even a piece of code? I can lend a members account for short amounts of time to anyone members+.

Thank you for reading.

Flight

2011-07-07 10:31:13

If I might throw my 2 cents in here…

First of all, set your camera to North and have it North the whole time. Detect the yellow color (yellow arrow) on your MM, and based off which relative angle it's located at from the center of the MM, will tell you to go N/E/S/W. Knowing the direction to go, search for any agility obstacles in that relative direction. When the distance from your yellow arrow to your center MM is within a certain range, search for the "tag box" and click it. Afterwards if the arrow is no longer present on the MM, then your "cycle" was successful.

Is this in line to what you're asking for?

masterBB

2011-07-07 10:38:23

From: Flight
If I might throw my 2 cents in here…

First of all, set your camera to North and have it North the whole time. Detect the yellow color (yellow arrow) on your MM, and based off which relative angle it's located at from the center of the MM, will tell you to go N/E/S/W. Knowing the direction to go, search for any agility obstacles in that relative direction. When the distance from your yellow arrow to your center MM is within a certain range, search for the "tag box" and click it. Afterwards if the arrow is no longer present on the MM, then your "cycle" was successful.

Is this in line to what you're asking for?


The problem with that strategy is that it will force me to a slower route, or even to walk through darts. I really need to know my position int the maze, there are only 25 platforms so it should be easy… Following the yellow arrow will be done after I know where the character is.

Flight

2011-07-07 10:55:28

Ohh ok, I guess I misunderstood then. I'll think about it a bit more. Maybe a mini-version of SPS? :p

Nava2

2011-07-07 11:44:51

Definitely use a flood fill for your Black. My suggestion would be to do a very simple "SplitTPA"-esque solution.

Here is my suggestion:

FindColors(BLACK_COLOUR, MINIMAP);
FilterPointsDist(MMCX, MMCY, MMX2-MMCX {perhaps make this a constant to save ticks}); // removes outside the edge of the minimap
for i := High(BLACK_POINTS) downto 0 do // make all pts relative to origin at 1 left and up from (MMX1, MMY1)
pts[i] := Point(pts[i].x+1-MMX1, pts[i].y+1-MMY2);
ColourStorage := TMufasaBitmap.Create(MMX2-MMX1+2, MMY2-MMY1+2);

ColourStorage.drawTPA(pts, clRed);
for x := ColourStorage.width-1 to 0 do // draw a box around the bitmap to match all the outside black
begin
ColourStorage.FastSetPixel(x, 0);
ColourStorage.FastSetPixel(x, MMY2-MMY1+1);
end;

for y := ColourStorage.height-1 to 0 do
ColourStorage.FastSetPixel(0, y);
ColourStorage.FastSetPixel(ColourStorage.width-1, y);
end;

ColourStorage.FloodFill(clGreen, 0, 0); // Fills alllll of the big black hopefully that was now Red
oldTarget := getTarget;
setTarget(ColourStorage);
FindColours(smallPts, clRed);
setTarget(oldTarget);

Result := smallPts;

This is all pseudo code, but it *should* work every time. No guarentee of speed, and theres LOADS of optimizations to be had there.

masterBB

2011-07-07 11:55:53

From: Flight
Ohh ok, I guess I misunderstood then. I'll think about it a bit more. Maybe a mini-version of SPS? :p


Not sure if that approach would work here. SPS got the whole minimap. I only got these platforms. But recreating SPS is my back up plan.

From: Nava2
Long awesome post


Definitively what I was looking for. So cool. I will try to work it out!

Rep+ for both of you!

edit: Can't rep flight. Need to spread it more before giving it again ;).