Lacky
11-04-2007, 02:23 AM
Hey,
Firstly, if I use this, will it look for gas and then run away form the gas then run back? (I added the run back and away thing):
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 (FindColorSpiralTolerance(Gx, Gy, Color[i], fx - 30, fy - 30,
fx + 30, fy + 30, 20)) then
begin
SetArrayLength(CountData, FindTimes);
while (n < FindTimes) do
begin
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;
procedure RunAwayFromGas;
begin
if GasFound then
RunAwayDirection(RunDirection);
wait(10000 + random(2000))
Runback;
end;
Will that work?
Second, what does this do? does it look for gas then run away if it finds it?
procedure LookGas;
begin
If (GasCheck(WhereGasFoundX, WhereGasFoundY)) then
WriteLn('Gas was found');
RunAwayDirection(RunDirection);
wait(10000 + random(2000))
RunBack;
end;
All help is appreciated.
Thanks
~Lacky
Firstly, if I use this, will it look for gas and then run away form the gas then run back? (I added the run back and away thing):
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 (FindColorSpiralTolerance(Gx, Gy, Color[i], fx - 30, fy - 30,
fx + 30, fy + 30, 20)) then
begin
SetArrayLength(CountData, FindTimes);
while (n < FindTimes) do
begin
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;
procedure RunAwayFromGas;
begin
if GasFound then
RunAwayDirection(RunDirection);
wait(10000 + random(2000))
Runback;
end;
Will that work?
Second, what does this do? does it look for gas then run away if it finds it?
procedure LookGas;
begin
If (GasCheck(WhereGasFoundX, WhereGasFoundY)) then
WriteLn('Gas was found');
RunAwayDirection(RunDirection);
wait(10000 + random(2000))
RunBack;
end;
All help is appreciated.
Thanks
~Lacky