Make AI be less scared by crates. Actually, now it starts using switcher just to pick a crate up.
authorunc0rr
Fri, 18 Nov 2011 15:05:32 +0400
changeset 6395 bb04d7a9f7e2
parent 6394 f0a9042e7387
child 6396 71dd6b8494e5
Make AI be less scared by crates. Actually, now it starts using switcher just to pick a crate up.
hedgewars/uAI.pas
hedgewars/uAIActions.pas
--- a/hedgewars/uAI.pas	Fri Nov 18 00:32:52 2011 +0100
+++ b/hedgewars/uAI.pas	Fri Nov 18 15:05:32 2011 +0400
@@ -132,6 +132,7 @@
               begin
               BestActions:= Actions;
               inc(BestActions.Score, Score);
+              BestActions.isWalkingToABetterPlace:= false;
 
               if (ap.Angle > 0) then AddAction(BestActions, aia_LookRight, 0, 200, 0, 0)
               else if (ap.Angle < 0) then AddAction(BestActions, aia_LookLeft, 0, 200, 0, 0);
@@ -245,6 +246,7 @@
        if Rate > BestRate then
           begin
           BestActions:= Actions;
+          BestActions.isWalkingToABetterPlace:= true;
           BestRate:= Rate;
           Me^.State:= Me^.State or gstAttacked // we have better place, go there and do not use ammo
           end
@@ -307,11 +309,12 @@
             inc(switchesNum);
         until (not (switchImmediatelyAvailable or switchAvailable))
             or StopThinking 
-            or (itHedgehog = currHedgehogIndex);
+            or (itHedgehog = currHedgehogIndex)
+            or BestActions.isWalkingToABetterPlace;
 
         if (StartTicks > GameTicks - 1500) and (not StopThinking) then SDL_Delay(1000);
 
-        if BestActions.Score < -1023 then
+        if (BestActions.Score < -1023) and (not BestActions.isWalkingToABetterPlace) then
             begin
             BestActions.Count:= 0;
             AddAction(BestActions, aia_Skip, 0, 250, 0, 0);
@@ -349,6 +352,7 @@
 BestActions.Count:= 0;
 BestActions.Pos:= 0;
 BestActions.Score:= Low(LongInt);
+BestActions.isWalkingToABetterPlace:= false;
 
 StopThinking:= false;
 ThinkingHH:= Me;
--- a/hedgewars/uAIActions.pas	Fri Nov 18 00:32:52 2011 +0100
+++ b/hedgewars/uAIActions.pas	Fri Nov 18 15:05:32 2011 +0400
@@ -57,6 +57,7 @@
                 Count, Pos: Longword;
                 actions: array[0..Pred(MAXACTIONS)] of TAction;
                 Score: LongInt;
+                isWalkingToABetterPlace: boolean;
                 end;
 
 procedure AddAction(var Actions: TActions; Action: Longword; Param: LongInt; TimeDelta: Longword; X, Y: LongInt);