AI: Remove own gear from explosion/shove checks in kami/piano test
authorWuzzy <Wuzzy2@mail.ru>
Mon, 08 Jun 2020 19:45:11 +0200
changeset 15631 308930fe5f4a
parent 15630 899fd1841399
child 15632 4ae2ebe812be
AI: Remove own gear from explosion/shove checks in kami/piano test
hedgewars/uAIAmmoTests.pas
hedgewars/uAIMisc.pas
--- a/hedgewars/uAIAmmoTests.pas	Mon Jun 08 19:18:30 2020 +0200
+++ b/hedgewars/uAIAmmoTests.pas	Mon Jun 08 19:45:11 2020 +0200
@@ -1179,7 +1179,7 @@
         valueResult:= valueResult +
             RateShove(Me, trunc(x), trunc(y)
                 , 30, 30, 25
-                , cx, -0.9, trackFall or afSetSkip);
+                , cx, -0.9, trackFall or afSetSkip or afIgnoreMe);
         end;
 
     if (d < 10) and (dx = 0) then
@@ -1189,14 +1189,14 @@
         tx:= trunc(x);
         v:= RateShove(Me, tx, trunc(y)
                 , 30, 30, 25
-                , -cx, -0.9, trackFall);
+                , -cx, -0.9, trackFall or afIgnoreMe);
         for i:= 1 to 512 div step - 2 do
             begin
             y:= y + dy;
             v:= v +
                 RateShove(Me, tx, trunc(y)
                     , 30, 30, 25
-                    , -cx, -0.9, trackFall or afSetSkip);
+                    , -cx, -0.9, trackFall or afSetSkip or afIgnoreMe);
             end
         end;
 
@@ -1209,11 +1209,11 @@
 
     v:= RateShove(Me, trunc(x), trunc(y)
             , 30, 30, 25
-            , cx, -0.9, trackFall);
+            , cx, -0.9, trackFall or afIgnoreMe);
     valueResult:= valueResult + v - KillScore * friendlyfactor div 100 * 1024;
 
     if v < 65536 then
-        inc(valueResult, RateExplosion(Me, trunc(x), trunc(y), 30));
+        inc(valueResult, RateExplosion(Me, trunc(x), trunc(y), 30, afIgnoreMe));
 
     TestKamikaze:= valueResult;
 end;
@@ -1555,9 +1555,9 @@
     Y:= Y + 32;
     if TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(X), trunc(Y), 32) then
         begin
-        dmg[i]:= dmg[i] + RateExplosion(Me, trunc(X)-30, trunc(Y)+40, 161);
-        dmg[i]:= dmg[i] + RateExplosion(Me, trunc(X), trunc(Y)+40, 161);
-        dmg[i]:= dmg[i] + RateExplosion(Me, trunc(X)+30, trunc(Y)+40, 161);
+        dmg[i]:= dmg[i] + RateExplosion(Me, trunc(X)-30, trunc(Y)+40, 161, afIgnoreMe);
+        dmg[i]:= dmg[i] + RateExplosion(Me, trunc(X), trunc(Y)+40, 161, afIgnoreMe);
+        dmg[i]:= dmg[i] + RateExplosion(Me, trunc(X)+30, trunc(Y)+40, 161, afIgnoreMe);
         inc(i);
         Y:= Y + 48;
         end;
--- a/hedgewars/uAIMisc.pas	Mon Jun 08 19:18:30 2020 +0200
+++ b/hedgewars/uAIMisc.pas	Mon Jun 08 19:45:11 2020 +0200
@@ -27,6 +27,7 @@
       afTrackFall  = $00000001;
       afErasesLand = $00000002;
       afSetSkip    = $00000004;
+      afIgnoreMe   = $00000008;
 
       BadTurn = Low(LongInt) div 4;
 
@@ -539,20 +540,22 @@
 x:= round(CheckWrap(real(x)));
 fallDmg:= 0;
 rate:= 0;
-// add our virtual position
-with Targets.ar[Targets.Count] do
-    begin
-    Point.x:= hwRound(Me^.X);
-    Point.y:= hwRound(Me^.Y);
-    skip:= false;
-    matters:= true;
-    Kind:= gtHedgehog;
-    Density:= 1;
-    Radius:= cHHRadius;
-    Score:= - ThinkingHH^.Health
-    end;
+
+if (Flags and afIgnoreMe) = 0 then
+    with Targets.ar[Targets.Count] do
+        // add our virtual position
+        begin
+        Point.x:= hwRound(Me^.X);
+        Point.y:= hwRound(Me^.Y);
+        skip:= false;
+        matters:= true;
+        Kind:= gtHedgehog;
+        Density:= 1;
+        Radius:= cHHRadius;
+        Score:= - ThinkingHH^.Health
+        end;
+
 // rate explosion
-
 if (Flags and afErasesLand <> 0) and (GameFlags and gfSolidLand = 0) then erasure:= r
 else erasure:= 0;
 
@@ -561,8 +564,9 @@
 for i:= 0 to Targets.Count do
     if not Targets.ar[i].dead then
         with Targets.ar[i] do
-          if not matters then hadSkips:= true
-            else
+          if not matters then
+            hadSkips:= true
+          else
             begin
             dmg:= 0;
             dmgBase:= r + Radius div 2;