hedgewars/uAI.pas
changeset 5163 1620a02d5282
parent 5162 60bc1af75c82
child 5286 22c1f4833a86
child 5388 73ef8e437231
equal deleted inserted replaced
5162:60bc1af75c82 5163:1620a02d5282
    84            if Actions.Score + Score > BestActions.Score then
    84            if Actions.Score + Score > BestActions.Score then
    85             if (BestActions.Score < 0) or (Actions.Score + Score > BestActions.Score + Byte(BotLevel) * 2048) then
    85             if (BestActions.Score < 0) or (Actions.Score + Score > BestActions.Score + Byte(BotLevel) * 2048) then
    86               begin
    86               begin
    87               BestActions:= Actions;
    87               BestActions:= Actions;
    88               inc(BestActions.Score, Score);
    88               inc(BestActions.Score, Score);
       
    89          addfilelog('AI: curr score ' + inttostr(bestactions.score));
    89 
    90 
    90               if (ap.Angle > 0) then AddAction(BestActions, aia_LookRight, 0, 200, 0, 0)
    91               if (ap.Angle > 0) then AddAction(BestActions, aia_LookRight, 0, 200, 0, 0)
    91               else if (ap.Angle < 0) then AddAction(BestActions, aia_LookLeft, 0, 200, 0, 0);
    92               else if (ap.Angle < 0) then AddAction(BestActions, aia_LookLeft, 0, 200, 0, 0);
    92 
    93 
    93               AddAction(BestActions, aia_Weapon, Longword(a), 300 + random(400), 0, 0);
    94               AddAction(BestActions, aia_Weapon, Longword(a), 300 + random(400), 0, 0);
   280       WalkMe:= BackMe;
   281       WalkMe:= BackMe;
   281       Walk(@WalkMe);
   282       Walk(@WalkMe);
   282       if (StartTicks > GameTicks - 1500) and not StopThinking then SDL_Delay(2000);
   283       if (StartTicks > GameTicks - 1500) and not StopThinking then SDL_Delay(2000);
   283       if BestActions.Score < -1023 then
   284       if BestActions.Score < -1023 then
   284          begin
   285          begin
       
   286          addfilelog('AI: best score ' + inttostr(bestactions.score));
   285          BestActions.Count:= 0;
   287          BestActions.Count:= 0;
   286          AddAction(BestActions, aia_Skip, 0, 250, 0, 0);
   288          AddAction(BestActions, aia_Skip, 0, 250, 0, 0);
   287          end;
   289          end;
   288       end else
   290       end else
   289 else begin
   291 else begin
   310 Me^.State:= Me^.State or gstHHThinking;
   312 Me^.State:= Me^.State or gstHHThinking;
   311 Me^.Message:= 0;
   313 Me^.Message:= 0;
   312 
   314 
   313 BestActions.Count:= 0;
   315 BestActions.Count:= 0;
   314 BestActions.Pos:= 0;
   316 BestActions.Pos:= 0;
   315 BestActions.Score:= Low(integer);
   317 BestActions.Score:= Low(LongInt);
   316 
   318 
   317 StopThinking:= false;
   319 StopThinking:= false;
   318 ThinkingHH:= Me;
   320 ThinkingHH:= Me;
   319 
   321 
   320 FillTargets;
   322 FillTargets;