SRL Archive - SRL Bugs

Door Profiles?


Boreas

2010-02-18 12:43:55

Is it broken?

If so, please post what code you ran to test, what it outputted, what you were expecting it to output, and a screenshot of the minimap.

Secondly, if anyone has info on what the possible colors are, or has started work on this, please post.

Thirdly, if anyone would like to help, please post.

Naum

2010-02-20 18:07:54

Okay I did a test and this is what I got:

GetDoorPoints - Fails, due to the color and tolerance.
FilterDropDots - Fails due to IsDropDot not working, filters every point out.
IsDropDot - Doesn't work.

Due to these essential things not working, the rest of it doesn't work.
Main functions that need to be re-written are IsDropDot and GetDoorPoints, other functions are interdependent on these, hence their failure.

Regarding the door color, 227 with 39 tolerance finds all doors. Using CTS Mods will help sort this problem out. I'll get right onto it :).

Bad Boy JH

2010-02-21 00:34:10

I have done some minor things, and I have noticed that the angled door colors are different to the horizontal/vertical ones…if you know what I mean…

NCDS

2010-02-21 00:43:02

From: Bad Boy JH
I have done some minor things, and I have noticed that the angled door colors are different to the horizontal/vertical ones…if you know what I mean…


That could very well prove to be a good thing.

I'll look into this more tomorrow..

Boreas

2010-02-21 15:15:00

Originally I had GetDoorColor and GetSecondDoorColor to deal with that, but it looks like now LordSaturn has one function to get all colors.

Are door colors still only between 200 and 255 (meaning 0 G and B)?

Also, do the colors that also appear in drop dots only appear once per drop dot? And I assume each door is still 4 pixels of the same color? If yes to both, eliminating drop dots should be pretty easy.

Bad Boy JH

2010-02-21 23:31:30

Door colors aren't only between 200 and 255…The Doors are usually 4-5 pixels, all in a straight line, (diagonal, vertical or horizontal) but there are occasionally double doors, so 8-10 pixels max.
in my efforts to fix it up, which I couldn't, I have a autocolor already done.

Boreas

2010-02-22 08:28:49

Awesome.

Can anyone confirm that drop dots never have the same color in more than 1-2 pixels per dot?

Bad Boy JH

2010-02-22 20:39:36

I tested on a couple of dots, there was a couple of instances of the same color, but there was only two of any color ie two pixels the same color, but there was a couple of these groups…if you know what I mean…so yes confirmed…

Boreas

2010-02-22 22:03:03

Great. So we just need to autocolor the door color to tpa, then go thru atpa and take out groups smaller than 3.

Awkwardsaw

2010-02-22 22:21:59

i made an isdropdot fix, but it got discarded because people where saying it wasnt broken, :p

maby it needs to get changed around a little bit though

Bad Boy JH

2010-02-24 00:19:34

function GetRedDoorColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
H, S, L: Extended;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(1);

FindColorsSpiralTolerance(MMCX, MMCY, arP, 263918, MMX1, MMY1, MMX2, MMY2, 9);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToHSL(arC[i], H, S, L);

if (H >= 0.05) and (H <= 99.95) and (S >= 95.10) and (S <= 100.02) and (L >= 45.47) and (L <= 48.45) then
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 33.01) and (X <= 37.77) and (Y >= 17.11) and (Y <= 19.60) and (Z >= 1.58) and (Z <= 1.93) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;
end;

ColorToleranceSpeed(tmpCTS);

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;
I already had it made, I already tried to fix the DoorProfiles, but thats about as far as I got, It does work…

Boreas

2010-02-26 12:33:55

I was checking out the doors in draynor, and noticed the red dungeon arrow, so I decided to try filtering out everything but doors instead of just drop dots, and learn CTS2Mods and SIMBA at the same time. I'll convert it to SCAR when I get time if nobody else does.

program new;
{$define SMART}
{$i srl/srl.scar}
{$i srl/srl/misc/DoorProfiles.scar}
{$i srl/srl/misc/Debug.scar}
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
CurrentPlayer := 0;
NumberOfPlayers(HowManyPlayers);
with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Active := True;
end;
end;

// Used this with 230 255 0 10 0 10 to create function below
{procedure RGBRangeToCTS2ModMMTPAFinder(MinR, MaxR, MinG, MaxG, MinB, MaxB: integer);
var
H,S,L,MinH,MaxH,MinS,MaxS,MinL,MaxL,HMod,SMod: extended;
R,G,B,Tol,Color:integer;
begin
MinH:=200.0;
MinS:=200.0;
MinL:=200.0;
MaxH:=0.0;
MaxS:=0.0;
MaxL:=0.0;
for R := MinR to MaxR do
for G := MinG to MaxG do
for B := MinB to MaxB do
begin
RGBToHSL(R,G,B,H,S,L);
if H < MinH then MinH := H;
if S < MinS then MinS := S;
if L < MinL then MinL := L;
if H > MaxH then MaxH := H;
if S > MaxS then MaxS := S;
if L > MaxL then MaxL := L;
end;
H := (MinH+MaxH)/2.0;
if (MaxH-MinH)> 50 then
begin
MinH := MinH+100.0;
H := (MinH+MaxH)/2.0;
if H>100.0 then
H := H-100.0;
end;
S := (MinS+MaxS)/2.0;
L := (MinL+MaxL)/2.0;
Tol := round(MaxL-L);
HMod := round((MaxH-H)/Tol);
if MinH>MaxH then
begin
HMod := round((MinH-H)/Tol);
end;
SMod := round((MaxS-S)/Tol);
Color := HSLToColor(H,S,L);

writeln(FloatToStr(H)+' '+FloatToStr(MinH)+' '+FloatToStr(MaxH));
writeln(FloatToStr(S)+' '+FloatToStr(MinS)+' '+FloatToStr(MaxS));
writeln(FloatToStr(L)+' '+FloatToStr(MinL)+' '+FloatToStr(MaxL));
writeln(FloatToStr(HMod)+' '+FloatToStr(SMod)+' '+FloatToStr(Tol));
writeln('');

writeln('function FindCTSMod2Points: tpointarray;');
writeln('var');
writeln(' TolSpeed:integer;');
writeln(' HMod, SMod: extended;');
writeln('begin');
writeln(' TolSpeed := GetToleranceSpeed;');
writeln(' SetColorToleranceSpeed(2);');
writeln(' GetToleranceSpeed2Modifiers(HMod, SMod);');
writeln(' SetToleranceSpeed2Modifiers('+FloatToStr(HMod)+', '+FloatToStr(SMod)+');');
writeln(' FindColorsTolerance(result, '+IntToStr(Color)+', MMX1, MMY1, MMX2, MMY2, '+IntToStr(ToL)+');');
writeln(' SetToleranceSpeed2Modifiers(HMod, SMod);');
writeln(' SetColorToleranceSpeed(TolSpeed);');
writeln('end;');
end; }
// used above function, then increased HMod from 0 to 0.2 (probably a rounding issue in above function
// increaed tol to 20 from 6 (probably didnt gather enough colors to give above function big enough RGB ranges)
function FindRedPoints: tpointarray;
var
TolSpeed:integer;
HMod, SMod: extended;
begin
TolSpeed := GetToleranceSpeed;
SetColorToleranceSpeed(2);
GetToleranceSpeed2Modifiers(HMod, SMod);
SetToleranceSpeed2Modifiers(0.2, 1.000000000000);
FindColorsTolerance(result, 394738, MMX1, MMY1, MMX2, MMY2, 20);
SetToleranceSpeed2Modifiers(HMod, SMod);
SetColorToleranceSpeed(TolSpeed);
end;

function BGetDoorPoints: T2dpointarray;
var
i,i2:integer;
RedPoints: tpointarray;
begin
RedPoints:= FindRedPoints;
if length(RedPoints)=0 then
begin
writeln('FindRedPoints found no points');
exit;
end;
result := SplitTPA(RedPoints, 1); //split into groups if touching
repeat //check each group for length
if not (InRange(length(result[i]),3,10)) then //drop dots have less, dungeon arrows have more
begin
Setarraylength(result[i],length(result[high(result)])); //preparing to swap current tpa with last one
for i2:=0 to high(result[i]) do //copy all points from last one to current one
begin
result[i][i2] := result[high(result)][i2];
end;
setarraylength(result, high(result)); //delete last one
DecEx(i,1); //so that we check current one again
end;
IncEx(i,1);
until i=length(result);
end;
var Doors: t2dpointarray;
begin
SetupSRL;
DeclarePlayers;
LoginPlayer;
Doors:=BGetDoorPoints;
DebugATPA(Doors,'');
end.

Please test!

Naum

2010-02-26 12:41:44

Tried it in Falador:


It got the bottom part of the exclamation mark (dungeon). (Maximised it so it can be seen clearly)

E: I used this Scar version:

program New;
{.Include SRL/SRL.Scar}
{.Include SRL/SRL/Misc/Debug.Scar}
{.Include SRL/SRL/Misc/Users.Scar}

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
CurrentPlayer := 0;
NumberOfPlayers(HowManyPlayers);
with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Active := True;
end;
end;

// Used this with 230 255 0 10 0 10 to create function below
{procedure RGBRangeToCTS2ModMMTPAFinder(MinR, MaxR, MinG, MaxG, MinB, MaxB: integer);
var
H,S,L,MinH,MaxH,MinS,MaxS,MinL,MaxL,HMod,SMod: extended;
R,G,B,Tol,Color:integer;
begin
MinH:=200.0;
MinS:=200.0;
MinL:=200.0;
MaxH:=0.0;
MaxS:=0.0;
MaxL:=0.0;
for R := MinR to MaxR do
for G := MinG to MaxG do
for B := MinB to MaxB do
begin
RGBToHSL(R,G,B,H,S,L);
if H < MinH then MinH := H;
if S < MinS then MinS := S;
if L < MinL then MinL := L;
if H > MaxH then MaxH := H;
if S > MaxS then MaxS := S;
if L > MaxL then MaxL := L;
end;
H := (MinH+MaxH)/2.0;
if (MaxH-MinH)> 50 then
begin
MinH := MinH+100.0;
H := (MinH+MaxH)/2.0;
if H>100.0 then
H := H-100.0;
end;
S := (MinS+MaxS)/2.0;
L := (MinL+MaxL)/2.0;
Tol := round(MaxL-L);
HMod := round((MaxH-H)/Tol);
if MinH>MaxH then
begin
HMod := round((MinH-H)/Tol);
end;
SMod := round((MaxS-S)/Tol);
Color := HSLToColor(H,S,L);

writeln(FloatToStr(H)+' '+FloatToStr(MinH)+' '+FloatToStr(MaxH));
writeln(FloatToStr(S)+' '+FloatToStr(MinS)+' '+FloatToStr(MaxS));
writeln(FloatToStr(L)+' '+FloatToStr(MinL)+' '+FloatToStr(MaxL));
writeln(FloatToStr(HMod)+' '+FloatToStr(SMod)+' '+FloatToStr(Tol));
writeln('');

writeln('function FindCTSMod2Points: tpointarray;');
writeln('var');
writeln(' TolSpeed:integer;');
writeln(' HMod, SMod: extended;');
writeln('begin');
writeln(' TolSpeed := GetToleranceSpeed;');
writeln(' SetColorToleranceSpeed(2);');
writeln(' GetToleranceSpeed2Modifiers(HMod, SMod);');
writeln(' SetToleranceSpeed2Modifiers('+FloatToStr(HMod)+', '+FloatToStr(SMod)+');');
writeln(' FindColorsTolerance(result, '+IntToStr(Color)+', MMX1, MMY1, MMX2, MMY2, '+IntToStr(ToL)+');');
writeln(' SetToleranceSpeed2Modifiers(HMod, SMod);');
writeln(' SetColorToleranceSpeed(TolSpeed);');
writeln('end;');
end; }
// used above function, then increased HMod from 0 to 0.2 (probably a rounding issue in above function
// increaed tol to 20 from 6 (probably didnt gather enough colors to give above function big enough RGB ranges)
function FindRedPoints: tpointarray;
var
TolSpeed:integer;
HMod, SMod: extended;
begin
TolSpeed := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
GetColorSpeed2Modifiers(HMod, SMod);
SetColorSpeed2Modifiers(0.2, 1.000000000000);
FindColorsTolerance(result, 394738, MMX1, MMY1, MMX2, MMY2, 20);
GetColorSpeed2Modifiers(HMod, SMod);
end;

function BGetDoorPoints: T2dpointarray;
var
i,i2:integer;
RedPoints: tpointarray;
begin
RedPoints:= FindRedPoints;
if length(RedPoints)=0 then
begin
writeln('FindRedPoints found no points');
exit;
end;
result := SplitTPA(RedPoints, 1); //split into groups if touching
repeat //check each group for length
if not (InRange(length(result[i]),3,10)) then //drop dots have less, dungeon arrows have more
begin
Setarraylength(result[i],length(result[high(result)])); //preparing to swap current tpa with last one
for i2:=0 to high(result[i]) do //copy all points from last one to current one
begin
result[i][i2] := result[high(result)][i2];
end;
setarraylength(result, high(result)); //delete last one
DecEx(i,1); //so that we check current one again
end;
IncEx(i,1);
until i=length(result);
end;
var Doors: t2dpointarray;
begin
SetupSRL;
DeclarePlayers;
LoginPlayer;
Doors:=BGetDoorPoints;
DebugATPA(Doors,'');
end.

It works very well :). Please note that this was hastily converted, so some of the code might have been wrong.

Boreas

2010-02-26 13:34:37

Thanks for converting and testing!

Should be ok to use in areas without exclamation points (and even with depending on how the doors are sorted). To filter it out, something that decides whether a group of points are in a line (at any angle) or in a blob might do it.