Name the flags for fall tracking and indicating whether the explosion erases terrain.
authornemo
Thu, 31 May 2012 12:52:31 -0400
changeset 7161 21a9c70b2070
parent 7159 0cc7420c0b98
child 7163 7db1e3a7422a
Name the flags for fall tracking and indicating whether the explosion erases terrain.
hedgewars/uAIAmmoTests.pas
hedgewars/uAIMisc.pas
--- a/hedgewars/uAIAmmoTests.pas	Thu May 31 20:07:40 2012 +0400
+++ b/hedgewars/uAIAmmoTests.pas	Thu May 31 12:52:31 2012 -0400
@@ -163,7 +163,7 @@
         EX:= trunc(x);
         EY:= trunc(y);
         if Me^.Hedgehog^.BotLevel = 1 then
-            value:= RateExplosion(Me, EX, EY, 101, 3)
+            value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
         else value:= RateExplosion(Me, EX, EY, 101);
         if value = 0 then
             value:= - Metric(Targ.X, Targ.Y, EX, EY) div 64;
@@ -220,7 +220,7 @@
         EX:= trunc(x);
         EY:= trunc(y);
 
-        value:= RateShove(Me, trunc(x), trunc(y), 5, 1, trunc((abs(dX)+abs(dY))*20), -dX, -dY, 1);
+        value:= RateShove(Me, trunc(x), trunc(y), 5, 1, trunc((abs(dX)+abs(dY))*20), -dX, -dY, afTrackFall);
         if value = 0 then
             value:= - Metric(Targ.X, Targ.Y, EX, EY) div 64;
 
@@ -323,7 +323,7 @@
     EY:= trunc(y);
     if t < 50 then 
         if Me^.Hedgehog^.BotLevel = 1 then
-            Score:= RateExplosion(Me, EX, EY, 101, 3)
+            Score:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
         else Score:= RateExplosion(Me, EX, EY, 101)
     else 
         Score:= BadTurn;
@@ -650,7 +650,7 @@
 else
     ap.Angle:= - cMaxAngle div 4;
 
-valueResult:= RateShove(Me, trunc(x) + LongWord(10*hwSignf(Targ.X - x)), trunc(y), 15, 30, 115, hwSign(Me^.dX)*0.353, -0.353, 1);
+valueResult:= RateShove(Me, trunc(x) + LongWord(10*hwSignf(Targ.X - x)), trunc(y), 15, 30, 115, hwSign(Me^.dX)*0.353, -0.353, afTrackFall);
 if valueResult <= 0 then
     valueResult:= BadTurn
 else
@@ -688,7 +688,7 @@
 val1:= 0;
 for i:= 0 to 4 do
     begin
-    t:= RateShove(Me, trunc(x) + 10 * hwSignf(Targ.X - x), trunc(y) - 20 * i - 5, 10, 30, 40, hwSign(Me^.dX)*0.45, -0.9, 1);
+    t:= RateShove(Me, trunc(x) + 10 * hwSignf(Targ.X - x), trunc(y) - 20 * i - 5, 10, 30, 40, hwSign(Me^.dX)*0.45, -0.9, afTrackFall);
     if (val1 < 0) or (t < 0) then val1:= BadTurn
     else if t > 0 then val1:= t;
     end;
@@ -696,7 +696,7 @@
 val2:= 0;
 for i:= 0 to 4 do
     begin
-    t:= RateShove(Me, trunc(x) + 10 * hwSignf(Targ.X - x), trunc(y) - 20 * i - 5, 10, 30, 40, -hwSign(Me^.dX)*0.45, -0.9, 1);
+    t:= RateShove(Me, trunc(x) + 10 * hwSignf(Targ.X - x), trunc(y) - 20 * i - 5, 10, 30, 40, -hwSign(Me^.dX)*0.45, -0.9, afTrackFall);
     if (val2 < 0) or (t < 0) then val2:= BadTurn
     else if t > 0 then val2:= t;
     end;
@@ -732,19 +732,19 @@
 RateShove call)}
 v1:= RateShove(Me, trunc(x) - 15, trunc(y)
         , 30, 30, 40
-        , -1, -0.8, 1 or fSetSkip);
+        , -1, -0.8, afTrackFall or afSetSkip);
 v1:= v1 +
     RateShove(Me, trunc(x), trunc(y)
         , 30, 30, 40
-        , -1, -0.8, 1);
+        , -1, -0.8, afTrackFall);
 // now try opposite direction
 v2:= RateShove(Me, trunc(x) + 15, trunc(y)
         , 30, 30, 40
-        , 1, -0.8, 1 or fSetSkip);
+        , 1, -0.8, afTrackFall or afSetSkip);
 v2:= v2 +
     RateShove(Me, trunc(x), trunc(y)
         , 30, 30, 40
-        , 1, -0.8, 1);
+        , 1, -0.8, afTrackFall);
 
 if (v2 > v1) 
     or {don't encourage turning for no gain}((v2 = v1) and (not Me^.dX.isNegative)) then
--- a/hedgewars/uAIMisc.pas	Thu May 31 20:07:40 2012 +0400
+++ b/hedgewars/uAIMisc.pas	Thu May 31 12:52:31 2012 -0400
@@ -23,7 +23,12 @@
 uses SDLh, uConsts, uFloat, uTypes;
 
 const MAXBONUS = 1024;
-      fSetSkip = 4;
+
+      afTrackFall  = $00000001;
+      afErasesLand = $00000002;
+      afSetSkip    = $00000004;
+
+
 type TTarget = record
     Point: TPoint;
     Score: LongInt;
@@ -329,7 +334,6 @@
     end;
 end;
 
-// Flags are not defined yet but 1 for checking drowning and 2 for assuming land erasure.
 function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt;
 begin
     RateExplosion:= RateExplosion(Me, x, y, r, 0);
@@ -351,7 +355,7 @@
     end;
 // rate explosion
 dmgBase:= r + cHHRadius div 2;
-if (Flags and 2 <> 0) and (GameFlags and gfSolidLand = 0) then erasure:= r
+if (Flags and afErasesLand <> 0) and (GameFlags and gfSolidLand = 0) then erasure:= r
 else erasure:= 0;
 for i:= 0 to Targets.Count do
     with Targets.ar[i] do
@@ -362,7 +366,7 @@
 
         if dmg > 0 then
             begin
-            if Flags and 1 <> 0 then
+            if Flags and afTrackFall <> 0 then
                 begin
                 dX:= 0.005 * dmg + 0.01;
                 dY:= dX;
@@ -399,7 +403,7 @@
 for i:= 0 to Pred(Targets.Count) do
     with Targets.ar[i] do
       if skip then 
-        if (Flags and fSetSkip = 0) then skip:= false else {still skip}
+        if (Flags and afSetSkip = 0) then skip:= false else {still skip}
       else  
         begin
         dmg:= 0;
@@ -410,8 +414,8 @@
             end;
         if dmg > 0 then
             begin
-            if (Flags and fSetSkip <> 0) then skip:= true;
-            if (Flags and 1 <> 0) then 
+            if (Flags and afSetSkip <> 0) then skip:= true;
+            if (Flags and afTrackFall <> 0) then 
                 fallDmg:= trunc(TraceShoveFall(Me, Point.x, Point.y - 2, dX, dY) * dmgMod);
             if fallDmg < 0 then // drowning. score healthier hogs higher, since their death is more likely to benefit the AI
                 if Score > 0 then