hedgewars/uAI.pas
changeset 146 458f4f58c1b6
parent 144 e6084b0c9316
child 183 57c2ef19f719
equal deleted inserted replaced
145:e593d5266e01 146:458f4f58c1b6
    77            Score:= AmmoTests[a](Me, Targets.ar[i].Point, BotLevel, Time, Angle, Power, ExplX, ExplY, ExplR);
    77            Score:= AmmoTests[a](Me, Targets.ar[i].Point, BotLevel, Time, Angle, Power, ExplX, ExplY, ExplR);
    78            if Actions.Score + Score > BestActions.Score then
    78            if Actions.Score + Score > BestActions.Score then
    79               begin
    79               begin
    80               BestActions:= Actions;
    80               BestActions:= Actions;
    81               inc(BestActions.Score, Score);
    81               inc(BestActions.Score, Score);
       
    82               
    82               AddAction(BestActions, aia_Weapon, Longword(a), 500);
    83               AddAction(BestActions, aia_Weapon, Longword(a), 500);
    83               if Time <> 0 then AddAction(BestActions, aia_Timer, Time div 1000, 400);
    84               if Time <> 0 then AddAction(BestActions, aia_Timer, Time div 1000, 400);
    84               if (Angle > 0) then AddAction(BestActions, aia_LookRight, 0, 200)
    85               if (Angle > 0) then AddAction(BestActions, aia_LookRight, 0, 200)
    85               else if (Angle < 0) then AddAction(BestActions, aia_LookLeft, 0, 200);
    86               else if (Angle < 0) then AddAction(BestActions, aia_LookLeft, 0, 200);
    86               if (Ammoz[a].Ammo.Propz and ammoprop_NoCrosshair) = 0 then
    87               if (Ammoz[a].Ammo.Propz and ammoprop_NoCrosshair) = 0 then
   248 if (Me.State and gstAttacked) = 0 then
   249 if (Me.State and gstAttacked) = 0 then
   249    if Targets.Count > 0 then
   250    if Targets.Count > 0 then
   250       begin
   251       begin
   251       Walk(@WalkMe);
   252       Walk(@WalkMe);
   252       if (StartTicks > GameTicks - 1500) and not StopThinking then SDL_Delay(2000);
   253       if (StartTicks > GameTicks - 1500) and not StopThinking then SDL_Delay(2000);
   253       if BestActions.Score = BadTurn then AddAction(BestActions, aia_Skip, 0, 250);
   254       if BestActions.Score < -1023 then
       
   255          begin
       
   256          BestActions.Count:= 0;
       
   257          AddAction(BestActions, aia_Skip, 0, 250);
       
   258          end;
   254       end else
   259       end else
   255 else begin
   260 else begin
   256       Walk(@WalkMe);
   261       Walk(@WalkMe);
   257       while (not StopThinking) and (BestActions.Count = 0) do
   262       while (not StopThinking) and (BestActions.Count = 0) do
   258             begin
   263             begin
   260             FillBonuses(true);
   265             FillBonuses(true);
   261             WalkMe:= BackMe;
   266             WalkMe:= BackMe;
   262             Walk(@WalkMe)
   267             Walk(@WalkMe)
   263             end
   268             end
   264       end;
   269       end;
   265 
       
   266 Me.State:= Me.State and not gstHHThinking
   270 Me.State:= Me.State and not gstHHThinking
   267 end;
   271 end;
   268 
   272 
   269 procedure StartThink(Me: PGear);
   273 procedure StartThink(Me: PGear);
   270 var a: TAmmoType;
   274 var a: TAmmoType;