SRL Archive - Senior Scripts and Snippets

Ballon Solver... One step closer?


pwnaz0r

2007-11-19 18:08:43

Alright, well I have been trying to collecting data on and off for ScapeRune for around a week now. I am using the "scientific method" while trying to solve it so for now I have collected information. I feel I should simply "blog" my research and progress here as many here have abilities that far surpass mine, in SCAR or knowledge. So if you have anything to add, please feel free.


Animal Color Information


I have used a short color information displayer (I did not make this version of it, raymond did. He sent it to me so I thought why not use ;). Thanks raymond), yet it is very neat and displays most of the information I needed. Here are some of the animals color informations. This includes animals on both types of tiles, as well as animals against the wall. I will probably use HSL or CMYK, as they are good at finding unique colors.


Highest CMYK values = C: 0 | M: 83.248730964467 | Y: 10.8695652173913 | K: 45.8823529411765
Lowest CMYK values = C: 0 | M: 60.5714285714286 | Y: 1.53061224489797 | K: 22.7450980392157
Differ CMYK values = C: 0 | M: 22.6773023930384 | Y: 9.33895297249332 | K: 23.1372549019608
Middle CMYK values = C: 0 | M: 71.9100797679478 | Y: 6.20008873114463 | K: 34.3137254901961
Middle CMYK color = 10301352

Highest HSV values = H: 86.0507246376812 | S: 71.3043510913849 | V: 77.2549019607843
Lowest HSV values = H: 83.6666666666667 | S: 60.5714285714286 | V: 54.1176470588235
Differ HSV values = H: 2.38405797101449 | S: 22.6773023930384 | V: 23.1372549019608
Middle HSV values = H: 84.8586956521739 | S: 71.9100797679478 | V: 65.6862745098039
Middle HSV color = 10235816

Highest RGB values = R: 197 | G: 69 | B: 193
Lowest RGB values = R: 138 | G: 33 | B: 123
Differ RGB values = R: 59 | G: 36 | B: 70
Middle RGB values = R: 167 | G: 51 | B: 158
Middle RGB color = 10367911

Highest HSL values = H: 86.0507249832153 | S: 71.3043510913849 | L: 47.8431403636932
Lowest HSL values = H: 83.6666703224182 | S: 43.4426218271255 | L: 36.0784322023392
Differ HSL values = H: 2.38405466079712 | S: 27.8617292642593 | L: 11.7647081613541
Middle HSL values = H: 84.8586976528168 | S: 57.3734864592552 | L: 41.9607862830162
Middle HSL color = 10301096

Highest XYZ values = X: 33.3675843757578 | Y: 17.5400082031276 | Z: 52.0789692344544
Lowest XYZ values = X: 15.0333786732737 | Y: 8.78732418272284 | Z: 19.6426673945694
Differ XYZ values = X: 18.3342057024841 | Y: 8.75268402040476 | Z: 32.436301839885
Middle XYZ values = X: 24.2004815245158 | Y: 13.1636661929252 | Z: 35.8608183145119
Middle XYZ color = 10694314



Detecting the Animal type while it is spinning


I tried to utilize the scientific method here. Here is some data I collected:

  • Animals rotate on the same path over and over, the path is not spline
  • the best way to detect animals by color is to compare the colors with the color of the jail bars which are behind it
  • You can still see animals in the background and they vary, thus making countcolor detection HIGHLY inaccurate.
  • All animals, regardless of how many animals are behind it, have at least 7200 purple pixels if they are laying flat.
  • The RAM has more than 12000 pixels at almost all times.

So, I narrowed down my choices to DTM's, FindColors, Bitmaps, and masks. (I was looking for everything).

I thought about Masks first, since it was "off the wall". They lagged the client too much (of course), especially searching client often. This is where I first started to question whether searching the client continuously was a good idea.

I didn't even try Bitmaps, as they lag alot and they need to be very accurate to work.

So I had narrowed it down to DTM's and FindColors. I tryed both numerous times. Nethier seemed to be very accurate. I asked my self, how can I get the speed of Scanlines (FindColor) with the accuracy of DTMS? then it hit me : DTMs are just points different distances from each other right? So since the animals follow certain paths, they must be able to be found by these DTMs, if they are fast enough, because it could be found over and over.

So, made a program that counted pixels over 6,000. If it found a pixelcount more than 6,000 it would up date a highest pixel count variable with that number, and take a picture. it would continue doing that for 15 seconds until it finally got a very flat picture for every animal. But there was a problem. There were two angles on every animal, one when they were flat, and one were they were slightly curved. For this, I just made find colors for both of these for every animal. So now, I had the speed of Scanlines with the accuracy of "stacked" FindColorTolerances. Here is my definition of stacking to Hellbb, the person that let me borrow the account.



Prison Pete Detection


I have now made the autocolor procedure for the outside of the ScapeRune. (This would detect ScapeRune?)


function FindPrisonPeteColor: integer;
var
X, Y, Z, H, S, L: extended;
R, G, B, I, tcts: integer;
Points: TPointArray;
Colors: TIntegerArray;
begin
result:= -1;
tcts:= GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsTolerance(Points, 4541002, MMX1, MMY1, MMX2, MMY2, 27);
Colors:= GetColors(Points);
ClearSameIntegers(Colors);
for I:= 0 to High(Colors) do
begin
ColorToRGB(Colors[i], R, G, B)
if (R >= 58) and (R <= 91) then
if (G >= 57) and (G <= 91) then
if (B >= 53) and (B <= 85) then
begin
ColorToHSL(Colors[i], H, S, L);
if (H >= 10.6111111938953) and (H <= 17.166667163372) then
if (S >= 3.02941155433655) and (S <= 5.53597073256969) then
if (L >= 22.4411765933037) and (L <= 33.8333343267441) then
begin
ColorToXYZ(Colors[i], X, Y, Z);
if (X >= 3.90413637610972) and (X <= 9.38721634829529) then
if (Y >= 4.1593408918836) and (Y <= 10.0133503151708) then
if (Z >= 4.03755283596089) and (Z <= 9.72154366518613) then
begin
result:= Colors[i];
break;
end;
end;
end;
end;
ColorToleranceSpeed(tcts);
end;

function FindPrisonPete: boolean;
var
StartColor: integer;
begin
StartColor:= FindPrisonPeteColor;
if (StartColor <> -1)then
begin
if (CountColor(StartColor, MMX1, MMY1, MMX2, MMY2) >= 200)then
begin
result:= true;
Writeln('*** PRISON PETE FOUND ***');
Players[CurrentPlayer].Rand:= 'Prison Pete';
Logout;
end;
end;
end;

Why did I use all three colorspaces and not just RGB?


3687242 has passed the RGB test.
4213331 has passed the RGB test.
4344915 has passed the RGB test.
3488833 has passed the RGB test.
3884106 has passed the RGB test.
4016721 has passed the RGB test.
4410968 has passed the RGB test.
4543065 has passed the RGB test.

Special Ed

2007-11-19 19:03:16

Do you need a balloon account? I think I've got an account in there right now. Either way though, you seem to be onto something, I haven't really studied the balloon random all that much but it seems that your idea would work, in theory.

I think that if you where to do it that way it would need to be in a plugin, lest we have it create a large amount of lag.

Town

2007-11-19 20:18:15

Impressive, I'd like to take a crack at solving it if I can borrow an account. I've never tried it before.

If there are a bunch of people working on it at once then everyone can go ahead and keep their code posted so people can borrow stuff and try as many techniques as possible.

pwnaz0r

2007-11-19 23:23:13

By the way, I have not finished writing everything down. I will do it tomorrow. This is about 25% of the research. And yes, I could use another account :D

Wizzup?

2007-11-20 03:12:57

Maybe try to see what the max box is that they make?

Procedure GetTPABounds(TPA: TPointArray; Var X1, Y1, X2, Y2: Integer);

Var
I: Integer;
Begin
If Length(TPA) < 1 Then
Exit;
X1 := TPA[0].X;
Y1 := TPA[0].Y;
X2 := TPA[0].X;
Y2 := TPA[0].Y;
For I := 0 To High(TPA) Do
Begin
If X1 > TPA[I].X Then
X1 := TPA[I].X;
If Y1 > TPA[I].Y Then
Y1 := TPA[I].Y;
If X2 < TPA[I].X Then
X2 := TPA[I].X;
If Y2 < TPA[I].Y Then
Y2 := TPA[I].Y;
End;
End;

Town

2007-11-20 16:01:37

They can't walk through anything. They can be blocked by you or by each other and just sit in one place.

A thought may be to measure the animal by height, width, and length. You would have to change the camera angle to get the height. Since they are constantly in motion, you may want to copy the picture onto another canvas and then right click the balloon before you even start to try to identify it.

pwnaz0r

2007-11-24 13:35:25

Alright, got prison pete detection down. Check it :)