hedgewars/uAI.pas
changeset 8017 70d386de989f
parent 7790 040fc517fece
child 8036 89740f927254
equal deleted inserted replaced
8016:c1223ef70934 8017:70d386de989f
   315                 begin
   315                 begin
   316                 addMark(hwRound(Me^.X), hwRound(Me^.Y), markLJumped);
   316                 addMark(hwRound(Me^.X), hwRound(Me^.Y), markLJumped);
   317                 // at final check where we go after jump walking backward
   317                 // at final check where we go after jump walking backward
   318                 if Push(ticks, Actions, AltMe, Me^.Message xor 3) then
   318                 if Push(ticks, Actions, AltMe, Me^.Message xor 3) then
   319                     with Stack.States[Pred(Stack.Count)] do
   319                     with Stack.States[Pred(Stack.Count)] do
       
   320                         begin
       
   321                         if Me^.dX.isNegative then
       
   322                             AddAction(MadeActions, aia_LookLeft, 0, 200, 0, 0)
       
   323                         else
       
   324                             AddAction(MadeActions, aia_LookRight, 0, 200, 0, 0);
       
   325 
   320                         AddAction(MadeActions, aia_LJump, 0, 305 + random(50), 0, 0);
   326                         AddAction(MadeActions, aia_LJump, 0, 305 + random(50), 0, 0);
       
   327                         end;
   321 
   328 
   322                 // push current position so we proceed from it after checking jump+forward walk opportunities
   329                 // push current position so we proceed from it after checking jump+forward walk opportunities
   323                 if CanGo then Push(ticks, Actions, Me^, Me^.Message);
   330                 if CanGo then Push(ticks, Actions, Me^, Me^.Message);
   324                 
   331                 
   325                 // first check where we go after jump walking forward
   332                 // first check where we go after jump walking forward
   351                 if (steps > 4) and checkMark(hwRound(Me^.X), hwRound(Me^.Y), markWalkedHere) then
   358                 if (steps > 4) and checkMark(hwRound(Me^.X), hwRound(Me^.Y), markWalkedHere) then
   352                     break;                    
   359                     break;                    
   353                 addMark(hwRound(Me^.X), hwRound(Me^.Y), markWalkedHere);
   360                 addMark(hwRound(Me^.X), hwRound(Me^.Y), markWalkedHere);
   354 
   361 
   355                 TestAmmos(Actions, Me, ticks shr 12 = oldticks shr 12);
   362                 TestAmmos(Actions, Me, ticks shr 12 = oldticks shr 12);
       
   363                 
   356                 end;
   364                 end;
   357                 
   365                 
   358             if GoInfo.FallPix >= FallPixForBranching then
   366             if GoInfo.FallPix >= FallPixForBranching then
   359                 Push(ticks, Actions, Me^, Me^.Message xor 3); // aia_Left xor 3 = aia_Right
   367                 Push(ticks, Actions, Me^, Me^.Message xor 3); // aia_Left xor 3 = aia_Right
   360             end {while};
   368             end {while};
   427             begin
   435             begin
   428             BestActions.Count:= 0;
   436             BestActions.Count:= 0;
   429             AddAction(BestActions, aia_Skip, 0, 250, 0, 0);
   437             AddAction(BestActions, aia_Skip, 0, 250, 0, 0);
   430             end;
   438             end;
   431 
   439 
   432         end else
   440         end else SDL_Delay(100)
   433 else
   441 else
   434     begin
   442     begin
   435     BackMe:= PGear(Me)^;
   443     BackMe:= PGear(Me)^;
   436     while (not StopThinking) and (BestActions.Count = 0) do
   444     while (not StopThinking) and (BestActions.Count = 0) do
   437         begin
   445         begin