Try to make AI aware of dud mines by clearing gstAttacking on dud, and adding some rules on mine health/damage/dud probability to AI weighting.
authornemo
Wed, 02 Mar 2011 11:48:02 -0500
changeset 4977 c89cca0a8785
parent 4976 088d40d8aba2
child 4978 0ef650ea3b12
Try to make AI aware of dud mines by clearing gstAttacking on dud, and adding some rules on mine health/damage/dud probability to AI weighting.
hedgewars/GSHandlers.inc
hedgewars/uAIMisc.pas
--- a/hedgewars/GSHandlers.inc	Wed Mar 02 00:27:20 2011 +0100
+++ b/hedgewars/GSHandlers.inc	Wed Mar 02 11:48:02 2011 -0500
@@ -1741,7 +1741,7 @@
                     PlaySound(sndVaporize);
                     Gear^.Health := 0;
                     Gear^.Damage := 0;
-AddFileLog('initial mine damage:'+IntToStr(Gear^.Damage));
+                    Gear^.State := Gear^.State and not gstAttacking
                     end;
                 exit
                 end;
--- a/hedgewars/uAIMisc.pas	Wed Mar 02 00:27:20 2011 +0100
+++ b/hedgewars/uAIMisc.pas	Wed Mar 02 11:48:02 2011 -0500
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2005-2011 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -139,10 +139,13 @@
           gtCase: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 33, 25);
           gtFlame: if (Gear^.State and gsttmpFlag) <> 0 then
                   AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 20, -50);
-          gtMine: if (Gear^.State and gstAttacking) = 0 then
-                  AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -50)
-              else
-                  AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, -50); // mine is on
+// avoid mines unless they are very likely to be duds, or are duds. also avoid if they are about to blow 
+          gtMine:  if ((Gear^.State and gstAttacking) = 0) and 
+                      (((cMineDudPercent < 90) and (Gear^.Health <> 0)) or
+                       ((Gear^.Health = 0) and (Gear^.Damage > 30))) then
+                          AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -50)
+                      else if (Gear^.State and gstAttacking) <> 0 then
+                          AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, -50); // mine is on
           gtDynamite: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -75);
           gtHedgehog: begin
                       if Gear^.Damage >= Gear^.Health then