SRL Archive - SRL Archives

PercentBlackMM


Richard

2009-06-06 17:39:48

I made it a bit more useful, gets the percent of a set area of the MM. Thanks to Zeph and mixster for fixing the annoying errors :)

{*******************************************************************************
function PercentBlackMM(StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
By: Richard
Description: Gets the percent of an area of the minimap which is black, defined
by the radials, and the radius.
*******************************************************************************}

function PercentBlackMM(StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
var
TPA: TPointArray;
A, Ps: Integer;
Sector1, Sector2, Area: Extended;
begin
A := EndRadial - StartRadial;
FindColors(TPA, 65536, MMX1, MMY1, MMX2, MMY2);
FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
Sector1 := (Pi * (StartRadius * StartRadius)) * (A / 360.0);
Sector2 := (Pi * (EndRadius * EndRadius)) * (A / 360.0);
Area := Sector2 - Sector1;
Ps := Length(TPA);
Result := Round((Ps * 100) / Area);
end;

Naum

2009-06-06 17:46:53

aPercentBlackMM(StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;

Might want to change that :).

Looks good though, you can get rid of 2 variables by using them directly.

Richard

2009-06-06 17:48:52

From: NaumanAkhlaQ
aPercentBlackMM(StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;

Might want to change that :).

Looks good though, you can get rid of 2 variables by using them directly.


Actually I could kill 3 variables, but this way is more readable.

Naum

2009-06-06 17:51:19

From: Richard
Actually I could kill 3 variables, but this way is more readable.


Then to make it more readable, add StartRadius * StartRadius and visa versa, to another variable :)

Richard

2009-06-06 18:01:04

function PercentBlackMM(StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
var
TPA: TPointArray;
begin
FindColors(TPA, 65536, MMX1, MMY1, MMX2, MMY2);
FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
Result := Round((Length(TPA) * 100) / ((Pi * (EndRadius * EndRadius)) * ((EndRadial - StartRadial) / 360.0)-((Pi * (StartRadius * StartRadius)) * ((EndRadial - StartRadial) / 360.0))));
end;

There you go dear, if you like long sums :)

Naum

2009-06-06 18:02:56

From: Richard
function PercentBlackMM(StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
var
TPA: TPointArray;
begin
FindColors(TPA, 65536, MMX1, MMY1, MMX2, MMY2);
FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
Result := Round((Length(TPA) * 100) / ((Pi * (EndRadius * EndRadius)) * ((EndRadial - StartRadial) / 360.0)-((Pi * (StartRadius * StartRadius)) * ((EndRadial - StartRadial) / 360.0))));
end;

There you go dear, if you like long sums :)


Ahh yeah! I love long sums!!

Rep++! :)

Richard

2009-06-06 19:00:19

From: NaumanAkhlaQ
Ahh yeah! I love long sums!!

Rep++! :)


Thanks :)

You're saying you would rather have that complicated thing than the easier to read version? :p

ZephyrsFury

2009-06-07 06:50:23

From: Richard
Thanks :)

You're saying you would rather have that complicated thing than the easier to read version? :p


Complicated things make you seem more 1337. Like in Smart.scar:


SmartSetup('http://'+prefix+'.runescape.com/', 'plugin.js?param=o0,a' + IntToStr((Integer(not(Signed)) + 1) * Integer(not((SuperDetail and Signed)))) + ',m' + IntToStr(Integer(Members)));

ian.

2009-06-07 06:58:53

What would this be used for? :o haha

Richard

2009-06-07 14:26:17

From: 99_
What would this be used for? :o haha


Dungeon walking mainly, gets you facing the right direction depending on the amount of black.

I'm currently using it for a FoG script me and ToF are working on.

MylesMadness

2009-06-07 17:03:59

From: ZephyrsFury
Complicated things make you seem more 1337. Like in Smart.scar:


SmartSetup('http://'+prefix+'.runescape.com/', 'plugin.js?param=o0,a' + IntToStr((Integer(not(Signed)) + 1) * Integer(not((SuperDetail and Signed)))) + ',m' + IntToStr(Integer(Members)));
Thats so funny :p

Nava2

2009-06-07 17:04:13

function PercentBlackMMEx(StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
var
TPA: TPointArray;
A: Integer;
Area: Extended;
begin
A := EndRadial - StartRadial;
FindColors(TPA, 65536, MMX1, MMY1, MMX2, MMY2);
FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
Area := (Pi * A / 360.0) * (sqr(StartRadius + 0.0) - sqr(EndRadius + 0.0));
Result := Round(Length(TPA) * 100 / Area) ;
end;

Check my math please, not sure if its accurate.. Factored your equations, dropped some variables. :)

Committed:

{*******************************************************************************
function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
By: Richard, and Nava2
Description: Returns the percentage of colour on the minimap section defined by
StartRadial, EndRadial, StartRadius, and EndRadius.
*******************************************************************************}
function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
var
TPA: TPointArray;
A: Integer;
Area: Extended;
begin
A := EndRadial - StartRadial;
FindColorsTolerance(TPA, Colour, MMX1, MMY1, MMX2, MMY2, Tol);
FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
Area := (Pi * A / 360.0) * (sqr(StartRadius + 0.0) - sqr(EndRadius + 0.0));
Result := Round(Length(TPA) * 100 / Area) ;
end;

Pure1993

2009-06-07 19:48:20

Nice, and grats on getting it into srl ^^
Personally, I preffere to create a circle close to the edge of the MM, and check on which points the MM is black. That way I can get every possible moving option… it's included in my essence miner… :)

Richard

2009-06-07 20:34:09

From: Nava2
function PercentBlackMMEx(StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
var
TPA: TPointArray;
A: Integer;
Area: Extended;
begin
A := EndRadial - StartRadial;
FindColors(TPA, 65536, MMX1, MMY1, MMX2, MMY2);
FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
Area := (Pi * A / 360.0) * (sqr(StartRadius + 0.0) - sqr(EndRadius + 0.0));
Result := Round(Length(TPA) * 100 / Area) ;
end;

Check my math please, not sure if its accurate.. Factored your equations, dropped some variables. :)

Committed:

{*******************************************************************************
function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
By: Richard, and Nava2
Description: Returns the percentage of colour on the minimap section defined by
StartRadial, EndRadial, StartRadius, and EndRadius.
*******************************************************************************}
function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
var
TPA: TPointArray;
A: Integer;
Area: Extended;
begin
A := EndRadial - StartRadial;
FindColorsTolerance(TPA, Colour, MMX1, MMY1, MMX2, MMY2, Tol);
FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
Area := (Pi * A / 360.0) * (sqr(StartRadius + 0.0) - sqr(EndRadius + 0.0));
Result := Round(Length(TPA) * 100 / Area) ;
end;


So thats how you square in delphi, I was trying x^y but it doesn't like that syntax.

Thanks for committing it :)

From: Pure1993
Nice, and grats on getting it into srl ^^
Personally, I preffere to create a circle close to the edge of the MM, and check on which points the MM is black. That way I can get every possible moving option… it's included in my essence miner… :)


If you mean a segment of a circle, I could have a go at some fun maths with that.

http://mathworld.wolfram.com/CircularSegment.html

Home

2009-06-07 21:31:52

Hey all.. Isn't this wrong ;)

{*******************************************************************************
function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
By: Richard, and Nava2
Description: Returns the percentage of colour on the minimap section defined by
StartRadial, EndRadial, StartRadius, and EndRadius.
*******************************************************************************}
function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
var
TPA: TPointArray;
A: Integer;
Area: Extended;
begin
A := EndRadial - StartRadial;
FindColorsTolerance(TPA, [COLOR="Red"][B]Colour[/B][/COLOR], MMX1, MMY1, MMX2, MMY2, Tol);
FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
Area := (Pi * A / 360.0) * (sqr(StartRadius + 0.0) - sqr(EndRadius + 0.0));
Result := Round(Length(TPA) * 100 / Area) ;
end;

Isn't it should be Color



~Home

ZephyrsFury

2009-06-08 12:31:14

From: Home
Hey all.. Isn't this wrong ;)

{*******************************************************************************
function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
By: Richard, and Nava2
Description: Returns the percentage of colour on the minimap section defined by
StartRadial, EndRadial, StartRadius, and EndRadius.
*******************************************************************************}
function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
var
TPA: TPointArray;
A: Integer;
Area: Extended;
begin
A := EndRadial - StartRadial;
FindColorsTolerance(TPA, [COLOR="Red"][B]Colour[/B][/COLOR], MMX1, MMY1, MMX2, MMY2, Tol);
FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
Area := (Pi * A / 360.0) * (sqr(StartRadius + 0.0) - sqr(EndRadius + 0.0));
Result := Round(Length(TPA) * 100 / Area) ;
end;

Isn't it should be Color



~Home


No 'colour' is proper English, what are you thinking? :eek:

Home

2009-06-08 12:59:39

From: ZephyrsFury
No 'colour' is proper English, what are you thinking? :eek:


Once again.. I feel stupid.. It won't compile Zeph.. Because there is Missing Variable..

Well whatever :(

~Home

Narcle

2009-06-08 13:38:13

This is what Home was pointing out:
{*******************************************************************************
function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
By: Richard, and Nava2
Description: Returns the percentage of colour on the minimap section defined by
StartRadial, EndRadial, StartRadius, and EndRadius.
*******************************************************************************}
function PercentColorMMEx([B]Color[/B], Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
var
TPA: TPointArray;
A: Integer;
Area: Extended;
begin
A := EndRadial - StartRadial;
FindColorsTolerance(TPA, [B]Colour[/B], MMX1, MMY1, MMX2, MMY2, Tol);
FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
Area := (Pi * A / 360.0) * (sqr(StartRadius + 0.0) - sqr(EndRadius + 0.0));
Result := Round(Length(TPA) * 100 / Area) ;
end;

Color <> Colour

Da 0wner

2009-06-08 13:49:10

Color > Colour.

But use proper grammar when describing the function and author :(.
By: Richard, and Nava2

-> By: Richard and Nava2.

mastaraymond

2009-06-08 17:56:51

Patato patato!

Nava2

2009-06-08 18:50:33

From: mastaraymond
Patato patato!


You just failed so hard..

Potato. xD

mastaraymond

2009-06-08 19:20:05

From: Nava2
You just failed so hard..

Potato. xD

Proof me wrong

marpis

2009-06-09 02:14:25

From: mastaraymond
Proof me wrong


http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=patato&go=Go
http://es.wikipedia.org/w/index.php?title=Especial%3ASearch&search=patato&go=Ir

on the topic: very good function indeed.

ZephyrsFury

2009-06-16 09:59:23

There's something wrong with the current function. When its used in PercentBlackMM, the Result is -100. I did some testing. The Area for a full minimap (MinRad = 0, MaxRad = 76, Angles 0 - 360) the area turns out to be 18145.8 something, the actual area is 18163.

Nava2

2009-06-16 16:20:09

Hmm, the math is right for sure. I triple checked it. Cos bug maybe?

Richard

2009-06-16 21:04:30

That's weird, because it worked perfectly with 65536, not sure why it doesn't like other colours.

I'm looking into it and seeing what's wrong.

Richard

2009-06-21 15:26:02

function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
var
TPA: TPointArray;
begin
FindColorsTolerance(TPA, Color, MMX1, MMY1, MMX2, MMY2, Tol);
FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
Result := Round((Length(TPA) * 100) / ((Pi * (EndRadius * EndRadius)) * ((EndRadial - StartRadial) / 360.0)-((Pi * (StartRadius * StartRadius)) * ((EndRadial - StartRadial) / 360.0))));
end;

Fixed, and if anyone would be in need of a simpler version:

function PercentColorMM(Color, Tol): Integer;
begin
Result := PercentColorMMEx(Color, Tol, 0, 360, 0, 76);
end;

ZephyrsFury

2009-06-21 16:43:22

Ok committed. :)