--- a/hedgewars/uAIAmmoTests.pas Thu Mar 15 22:46:37 2007 +0000
+++ b/hedgewars/uAIAmmoTests.pas Sat Mar 17 18:17:19 2007 +0000
@@ -63,7 +63,7 @@
function TestBazooka(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt;
var Vx, Vy, r: hwFloat;
- rTime: hwFloat;
+ rTime: LongInt;
Score, EX, EY: LongInt;
Result: LongInt;
@@ -76,7 +76,7 @@
y:= Me^.Y;
dX:= Vx;
dY:= -Vy;
- t:= hwRound(rTime);
+ t:= rTime;
repeat
x:= x + dX;
y:= y + dY;
@@ -98,10 +98,10 @@
Result:= BadTurn;
repeat
rTime:= rTime + 300 + Level * 50 + random(300);
- Vx:= - cWindSpeed * rTime * _0_5 + (Targ.X - hwRound(Me^.X)) / rTime;
- Vy:= cGravity * rTime * _0_5 - (Targ.Y - hwRound(Me^.Y)) / rTime;
+ Vx:= - cWindSpeed * rTime * _0_5 + (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(rTime);
+ Vy:= cGravity * rTime * _0_5 - (int2hwFloat(Targ.Y) - Me^.Y) / int2hwFloat(rTime);
r:= Distance(Vx, Vy);
- if not (r > 1) then
+ if not (r > _1) then
begin
Score:= CheckTrace;
if Result <= Score then
@@ -150,10 +150,10 @@
ExplR:= 0;
repeat
inc(TestTime, 1000);
- Vx:= (Targ.X - Me^.X) / (TestTime + tDelta);
- Vy:= cGravity * ((TestTime + tDelta) div 2) - (Targ.Y - Me^.Y) / (TestTime + tDelta);
+ Vx:= (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(TestTime + tDelta);
+ Vy:= cGravity * ((TestTime + tDelta) div 2) - (int2hwFloat(Targ.Y) - Me^.Y) / int2hwFloat(TestTime + tDelta);
r:= Distance(Vx, Vy);
- if not (r > 1) then
+ if not (r > _1) then
begin
Score:= CheckTrace;
if Result < Score then
@@ -180,8 +180,8 @@
Power:= 1;
if Metric(hwRound(Me^.X), hwRound(Me^.Y), Targ.X, Targ.Y) < 80 then
exit(BadTurn);
-Vx:= (Targ.X - Me^.X) * _1div1024;
-Vy:= (Targ.Y - Me^.Y) * _1div1024;
+Vx:= (int2hwFloat(Targ.X) - Me^.X) * _1div1024;
+Vy:= (int2hwFloat(Targ.Y) - Me^.Y) * _1div1024;
x:= Me^.X;
y:= Me^.Y;
Angle:= DxDy2AttackAngle(Vx, -Vy);
@@ -197,7 +197,7 @@
else dec(Result, Level * 4000);
exit(Result)
end
-until (hwAbs(Targ.X - x) + hwAbs(Targ.Y - y) < 4) or (x < 0) or (y < 0) or (x > 2048) or (y > 1024);
+until (Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 4) or (x < _0) or (y < _0) or (x > _2048) or (y > _1024);
TestShotgun:= BadTurn
end;
@@ -209,11 +209,11 @@
ExplR:= 0;
Time:= 0;
Power:= 1;
-if hwAbs(Me^.X - Targ.X) + hwAbs(Me^.Y - Targ.Y) < 80 then
+if Abs(hwRound(Me^.X) - Targ.X) + Abs(hwRound(Me^.Y) - Targ.Y) < 80 then
exit(BadTurn);
-t:= _0_5 / Distance(Targ.X - Me^.X, Targ.Y - Me^.Y);
-Vx:= (Targ.X - Me^.X) * t;
-Vy:= (Targ.Y - Me^.Y) * t;
+t:= _0_5 / Distance(int2hwFloat(Targ.X) - Me^.X, int2hwFloat(Targ.Y) - Me^.Y);
+Vx:= (int2hwFloat(Targ.X) - Me^.X) * t;
+Vy:= (int2hwFloat(Targ.Y) - Me^.Y) * t;
x:= Me^.X;
y:= Me^.Y;
Angle:= DxDy2AttackAngle(Vx, -Vy);
@@ -223,9 +223,9 @@
y:= y + vY;
if ((hwRound(x) and $FFFFF800) = 0)and((hwRound(y) and $FFFFFC00) = 0)
and (Land[hwRound(y), hwRound(x)] <> 0) then inc(d);
-until (hwAbs(Targ.X - x) + hwAbs(Targ.Y - y) < 4) or (x < 0) or (y < 0) or (x > 2048) or (y > 1024) or (d > 200);
-if hwAbs(Targ.X - x) + hwAbs(Targ.Y - y) < 2 then Result:= max(0, (4 - d div 50) * 7 * 1024)
- else Result:= Low(LongInt);
+until (Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 4) or (x < _0) or (y < _0) or (x > _2048) or (y > _1024) or (d > 200);
+if Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 3 then Result:= max(0, (4 - d div 50) * 7 * 1024)
+ else Result:= Low(LongInt);
TestDesertEagle:= Result
end;
@@ -233,13 +233,14 @@
var Result: LongInt;
begin
ExplR:= 0;
-if (Level > 2) and not (hwAbs(Me^.X - Targ.X) + hwAbs(Me^.Y - Targ.Y) < 25) then
+if (Level > 2) and not (Abs(hwRound(Me^.X) - Targ.X) + Abs(hwRound(Me^.Y) - Targ.Y) < 25) then
exit(BadTurn);
Time:= 0;
Power:= 1;
-Angle:= DxDy2AttackAngle(hwSign(Targ.X - Me^.X), 1);
-Result:= RateShove(Me, hwRound(Me^.X) + 10 * hwSign(Targ.X - Me^.X), hwRound(Me^.Y), 15, 30);
+if (Targ.X) - hwRound(Me^.X) >= 0 then Angle:= cMaxAngle div 4
+ else Angle:= - cMaxAngle div 4;
+Result:= RateShove(Me, hwRound(Me^.X) + 10 * hwSign(int2hwFloat(Targ.X) - Me^.X), hwRound(Me^.Y), 15, 30);
if Result <= 0 then Result:= BadTurn else inc(Result);
TestBaseballBat:= Result
end;
@@ -251,12 +252,13 @@
Time:= 0;
Power:= 1;
Angle:= 0;
-if (hwAbs(Me^.X - Targ.X) > 25) or (hwAbs(Me^.Y - 50 - Targ.Y) > 50) then
+if (Abs(hwRound(Me^.X) - Targ.X) > 25) or (Abs(hwRound(Me^.Y) - 50 - Targ.Y) > 50) then
exit(BadTurn);
Result:= 0;
for i:= 0 to 4 do
- Result:= Result + RateShove(Me, hwRound(Me^.X) + 10 * hwSign(Targ.X - Me^.X), hwRound(Me^.Y) - 20 * i - 5, 10, 30);
+ Result:= Result + RateShove(Me, hwRound(Me^.X) + 10 * hwSign(int2hwFloat(Targ.X) - Me^.X),
+ hwRound(Me^.Y) - 20 * i - 5, 10, 30);
if Result <= 0 then Result:= BadTurn else inc(Result);
TestFirePunch:= Result
end;