hedgewars/uAI.pas
branchwebgl
changeset 8096 453917e94e55
parent 8026 4a4f21070479
parent 8036 89740f927254
child 8833 c13ebed437cb
equal deleted inserted replaced
8053:2e836bebb518 8096:453917e94e55
   294                 addMark(hwRound(Me^.X), hwRound(Me^.Y), markHJumped);
   294                 addMark(hwRound(Me^.X), hwRound(Me^.Y), markHJumped);
   295                 if Push(ticks, Actions, AltMe, Me^.Message xor 3) then
   295                 if Push(ticks, Actions, AltMe, Me^.Message xor 3) then
   296                     begin
   296                     begin
   297                     with Stack.States[Pred(Stack.Count)] do
   297                     with Stack.States[Pred(Stack.Count)] do
   298                         begin
   298                         begin
   299                         if Me^.dX.isNegative then
   299                         if (Me^.Message and gmLeft) <> 0 then
   300                             AddAction(MadeActions, aia_LookRight, 0, 200, 0, 0)
   300                             AddAction(MadeActions, aia_LookRight, 0, 200, 0, 0)
   301                         else
   301                         else
   302                             AddAction(MadeActions, aia_LookLeft, 0, 200, 0, 0);
   302                             AddAction(MadeActions, aia_LookLeft, 0, 200, 0, 0);
   303                             
   303                             
   304                         AddAction(MadeActions, aia_HJump, 0, 305 + random(50), 0, 0);
   304                         AddAction(MadeActions, aia_HJump, 0, 305 + random(50), 0, 0);
   305                         AddAction(MadeActions, aia_HJump, 0, 350, 0, 0);
   305                         AddAction(MadeActions, aia_HJump, 0, 350, 0, 0);
   306                         
       
   307                         if Me^.dX.isNegative then
       
   308                             AddAction(MadeActions, aia_LookLeft, 0, 200, 0, 0)
       
   309                         else
       
   310                             AddAction(MadeActions, aia_LookRight, 0, 200, 0, 0);
       
   311                         end;
   306                         end;
   312                     // but first check walking forward
   307                     // but first check walking forward
   313                     Push(ticks, Stack.States[Pred(Stack.Count)].MadeActions, AltMe, Me^.Message)
   308                     Push(ticks, Stack.States[Pred(Stack.Count)].MadeActions, AltMe, Me^.Message)
   314                     end;
   309                     end;
   315                 end;
   310                 end;
   320                 begin
   315                 begin
   321                 addMark(hwRound(Me^.X), hwRound(Me^.Y), markLJumped);
   316                 addMark(hwRound(Me^.X), hwRound(Me^.Y), markLJumped);
   322                 // at final check where we go after jump walking backward
   317                 // at final check where we go after jump walking backward
   323                 if Push(ticks, Actions, AltMe, Me^.Message xor 3) then
   318                 if Push(ticks, Actions, AltMe, Me^.Message xor 3) then
   324                     with Stack.States[Pred(Stack.Count)] do
   319                     with Stack.States[Pred(Stack.Count)] do
       
   320                         begin
       
   321                         if (Me^.Message and gmLeft) <> 0 then
       
   322                             AddAction(MadeActions, aia_LookLeft, 0, 200, 0, 0)
       
   323                         else
       
   324                             AddAction(MadeActions, aia_LookRight, 0, 200, 0, 0);
       
   325 
   325                         AddAction(MadeActions, aia_LJump, 0, 305 + random(50), 0, 0);
   326                         AddAction(MadeActions, aia_LJump, 0, 305 + random(50), 0, 0);
       
   327                         end;
   326 
   328 
   327                 // 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
   328                 if CanGo then Push(ticks, Actions, Me^, Me^.Message);
   330                 if CanGo then Push(ticks, Actions, Me^, Me^.Message);
   329                 
   331                 
   330                 // first check where we go after jump walking forward
   332                 // first check where we go after jump walking forward
   356                 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
   357                     break;                    
   359                     break;                    
   358                 addMark(hwRound(Me^.X), hwRound(Me^.Y), markWalkedHere);
   360                 addMark(hwRound(Me^.X), hwRound(Me^.Y), markWalkedHere);
   359 
   361 
   360                 TestAmmos(Actions, Me, ticks shr 12 = oldticks shr 12);
   362                 TestAmmos(Actions, Me, ticks shr 12 = oldticks shr 12);
       
   363                 
   361                 end;
   364                 end;
   362                 
   365                 
   363             if GoInfo.FallPix >= FallPixForBranching then
   366             if GoInfo.FallPix >= FallPixForBranching then
   364                 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
   365 
   368 
   452             begin
   455             begin
   453             BestActions.Count:= 0;
   456             BestActions.Count:= 0;
   454             AddAction(BestActions, aia_Skip, 0, 250, 0, 0);
   457             AddAction(BestActions, aia_Skip, 0, 250, 0, 0);
   455             end;
   458             end;
   456 
   459 
   457         end else
   460         end else SDL_Delay(100)
   458 else
   461 else
   459     begin
   462     begin
   460     BackMe:= PGear(Me)^;
   463     BackMe:= PGear(Me)^;
   461     
   464     
   462 //{$IFNDEF AI_MAINTHREAD}
   465 //{$IFNDEF AI_MAINTHREAD}