hedgewars/uAI.pas
changeset 5396 4a0a8f32b7e3
parent 5394 924584407e01
child 5495 272ed78e59a7
child 5600 c6da15eddab3
equal deleted inserted replaced
5394:924584407e01 5396:4a0a8f32b7e3
    72     if (Targets.ar[i].Score >= 0) and (not StopThinking) then
    72     if (Targets.ar[i].Score >= 0) and (not StopThinking) then
    73        begin
    73        begin
    74        with CurrentHedgehog^ do
    74        with CurrentHedgehog^ do
    75             a:= CurAmmoType;
    75             a:= CurAmmoType;
    76        aa:= a;
    76        aa:= a;
       
    77        
       
    78        ThreadSwitch();
       
    79        
    77        repeat
    80        repeat
    78         if (CanUseAmmo[a]) and
    81         if (CanUseAmmo[a]) and
    79            ((not isMoved) or ((AmmoTests[a].flags and amtest_OnTurn) = 0)) then
    82            ((not isMoved) or ((AmmoTests[a].flags and amtest_OnTurn) = 0)) then
    80            begin
    83            begin
    81 {$HINTS OFF}
    84 {$HINTS OFF}
   260            and ((steps mod 4) = 0) then TestAmmos(Actions, Me, true);
   263            and ((steps mod 4) = 0) then TestAmmos(Actions, Me, true);
   261        if GoInfo.FallPix >= FallPixForBranching then
   264        if GoInfo.FallPix >= FallPixForBranching then
   262           Push(ticks, Actions, Me^, Me^.Message xor 3); // aia_Left xor 3 = aia_Right
   265           Push(ticks, Actions, Me^, Me^.Message xor 3); // aia_Left xor 3 = aia_Right
   263        end;
   266        end;
   264 
   267 
   265     ThreadSwitch();
       
   266 
       
   267     if BestRate > BaseRate then exit
   268     if BestRate > BaseRate then exit
   268     end
   269     end
   269 end;
   270 end;
   270 
   271 
   271 function Think(Me: Pointer): ptrint;
   272 function Think(Me: Pointer): ptrint;
   282       WalkMe:= BackMe;
   283       WalkMe:= BackMe;
   283       Walk(@WalkMe);
   284       Walk(@WalkMe);
   284       if (StartTicks > GameTicks - 1500) and not StopThinking then SDL_Delay(1000);
   285       if (StartTicks > GameTicks - 1500) and not StopThinking then SDL_Delay(1000);
   285       if BestActions.Score < -1023 then
   286       if BestActions.Score < -1023 then
   286          begin
   287          begin
   287          addfilelog('AI: best score ' + inttostr(bestactions.score));
       
   288          BestActions.Count:= 0;
   288          BestActions.Count:= 0;
   289          AddAction(BestActions, aia_Skip, 0, 250, 0, 0);
   289          AddAction(BestActions, aia_Skip, 0, 250, 0, 0);
   290          end;
   290          end;
   291       end else
   291       end else
   292 else begin
   292 else begin