SRL Archive - Senior News and General

in the new gas check...


The Claw

2007-09-25 11:09:37

well ive already gotten 2 exception errors, due to it searching outside the screen (i think thats why). so should we put in some failsafes to make sure that doesnt happen? like this

function GasFound(fx, fy : Integer) : Boolean;
var
Color : array [1..2] of integer;
CountData : array of Integer;
i, Gx, Gy, count, n, FindTimes : Integer;
begin
Color[1] := 8296866;
Color[2] := 8951705;
Gx := fx;
Gy := fy;
FindTimes := 3;
for i := 1 to 2 do
begin
if Gx - 30 < 0 then Gx := MSCX - 30;
if Gy - 30 < 0 then Gy := MSCY - 30;
if (FindColorSpiralTolerance(Gx, Gy, Color[i], fx - 30, fy - 30,
fx + 30, fy + 30, 20)) then
begin
SetArrayLength(CountData, FindTimes);
while (n < FindTimes) do
begin
if Gx - 20 < 0 then Gx := MSCX - 20;
if Gy - 20 < 0 then Gy := MSCY - 20;
CountData[n] := CountColorTolerance(Color[i], Gx - 20, Gy - 20, Gx + 20, Gy + 20, 20);
n := n + 1;
if (n = FindTimes) then Break; // No need to Wait(100) again...
Wait(100);
end;
BubbleSort(CountData);
Count := iAbs(CountData[Length(CountData)-1] - CountData[0]);
if (Count > 40) then
begin
Result := FindGas(gx, gy);
if (Result) then
Writeln('** Found Gas ** Pixel Count Change is [' + inttostr(Count) + ']' );
end;
Gx := fx;
Gy := fy;
end;
end;
end;

i put in the "if Gx - 20…" 's.

SKy Scripter

2007-09-25 13:41:05

From: The Claw
well ive already gotten 2 exception errors, due to it searching outside the screen (i think thats why). so should we put in some failsafes to make sure that doesnt happen? like this

function GasFound(fx, fy : Integer) : Boolean;
var
Color : array [1..2] of integer;
CountData : array of Integer;
i, Gx, Gy, count, n, FindTimes : Integer;
begin
Color[1] := 8296866;
Color[2] := 8951705;
Gx := fx;
Gy := fy;
FindTimes := 3;
for i := 1 to 2 do
begin
if Gx - 30 < 0 then Gx := MSCX - 30;
if Gy - 30 < 0 then Gy := MSCY - 30;
if (FindColorSpiralTolerance(Gx, Gy, Color[i], fx - 30, fy - 30,
fx + 30, fy + 30, 20)) then
begin
SetArrayLength(CountData, FindTimes);
while (n < FindTimes) do
begin
if Gx - 20 < 0 then Gx := MSCX - 20;
if Gy - 20 < 0 then Gy := MSCY - 20;
CountData[n] := CountColorTolerance(Color[i], Gx - 20, Gy - 20, Gx + 20, Gy + 20, 20);
n := n + 1;
if (n = FindTimes) then Break; // No need to Wait(100) again...
Wait(100);
end;
BubbleSort(CountData);
Count := iAbs(CountData[Length(CountData)-1] - CountData[0]);
if (Count > 40) then
begin
Result := FindGas(gx, gy);
if (Result) then
Writeln('** Found Gas ** Pixel Count Change is [' + inttostr(Count) + ']' );
end;
Gx := fx;
Gy := fy;
end;
end;
end;

i put in the "if Gx - 20…" 's.




oops, i thought i fixed it -.- well any way the problem is CountColor….

all you need to do is replace countcolor with findcolorstolerance then get the length of the points for the count..

nielsie95

2007-09-25 13:44:00

No it's probably not that it's searching out of the client; Freddy integrated a feature that normalizes those values. I think it's CountColorTolerance, I've gotten errors with that one before.. So maybe a FindColorsTolerance will do?

Edit: SKy has beaten me by 3 minutes.

Pyro

2007-09-25 17:46:20

Tsk tsk told you sky.

The Claw

2007-09-25 19:00:14

ah ok, thanks for that. and btw, it worked alrite for me last night..solved 2 gasses, missed 3 though.

SKy Scripter

2007-09-26 00:13:13

From: The Claw
ah ok, thanks for that. and btw, it worked alrite for me last night..solved 2 gasses, missed 3 though.


?, ouch… it never failed me…

The Claw

2007-09-26 02:49:23

perhaps im using it wrong then..im using it like this:

if GasFound(Mx, My - 30) then

i always used to have to do - 30 when using CheckGas, but GasFound is probably different. so maybe the - 30 is messing it up?

SKy Scripter

2007-09-26 10:06:35

Works better to just find the center ? :)

The Claw

2007-09-26 10:10:56

i do, but gas is never exactly on where the rock is found..it floats above it :p thats what the -30 is for.

Wizzup?

2007-09-26 10:26:53

From: SKy Scripter
Works better to just find the center ? :)


Normal gascheck used gascheck(x, y-20), for better performance. :)

The Claw

2007-09-29 21:55:58

Just for the record I have had no problems with it after adding in the failsafes I posted, using the old CountColorTolerance.