hedgewars/uAI.pas
changeset 7787 67c96b9c179c
parent 7453 92bdcd69bf2a
child 7789 838d2e06c377
equal deleted inserted replaced
7786:23a075cf4837 7787:67c96b9c179c
   226     a: TAmmoType;
   226     a: TAmmoType;
   227 begin
   227 begin
   228 ticks:= 0; // avoid compiler hint
   228 ticks:= 0; // avoid compiler hint
   229 Stack.Count:= 0;
   229 Stack.Count:= 0;
   230 
   230 
       
   231 clearAllMarks;
       
   232 
   231 for a:= Low(TAmmoType) to High(TAmmoType) do
   233 for a:= Low(TAmmoType) to High(TAmmoType) do
   232     CanUseAmmo[a]:= Assigned(AmmoTests[a].proc) and (HHHasAmmo(Me^.Hedgehog^, a) > 0);
   234     CanUseAmmo[a]:= Assigned(AmmoTests[a].proc) and (HHHasAmmo(Me^.Hedgehog^, a) > 0);
   233 
   235 
   234 BotLevel:= Me^.Hedgehog^.BotLevel;
   236 BotLevel:= Me^.Hedgehog^.BotLevel;
   235 
   237 
   274     {$HINTS ON}
   276     {$HINTS ON}
   275             inc(ticks, GoInfo.Ticks);
   277             inc(ticks, GoInfo.Ticks);
   276             if ticks > maxticks then
   278             if ticks > maxticks then
   277                 break;
   279                 break;
   278 
   280 
   279             if (BotLevel < 5) and (GoInfo.JumpType = jmpHJump) then // hjump support
   281             if (BotLevel < 5) 
       
   282                 and (GoInfo.JumpType = jmpHJump) 
       
   283                 and (not checkMark(hwRound(Me^.X), hwRound(Me^.Y), markHJumped))
       
   284                 then // hjump support
       
   285                 begin
   280                 // check if we could go backwards and maybe ljump over a gap after this hjump
   286                 // check if we could go backwards and maybe ljump over a gap after this hjump
       
   287                 addMark(hwRound(Me^.X), hwRound(Me^.Y), markHJumped);
   281                 if Push(ticks, Actions, AltMe, Me^.Message xor 3) then
   288                 if Push(ticks, Actions, AltMe, Me^.Message xor 3) then
   282                     begin
   289                     begin
   283                     with Stack.States[Pred(Stack.Count)] do
   290                     with Stack.States[Pred(Stack.Count)] do
   284                         begin
   291                         begin
   285                         if Me^.dX.isNegative then
   292                         if Me^.dX.isNegative then
   296                             AddAction(MadeActions, aia_LookRight, 0, 200, 0, 0);
   303                             AddAction(MadeActions, aia_LookRight, 0, 200, 0, 0);
   297                         end;
   304                         end;
   298                     // but first check walking forward
   305                     // but first check walking forward
   299                     Push(ticks, Stack.States[Pred(Stack.Count)].MadeActions, AltMe, Me^.Message)
   306                     Push(ticks, Stack.States[Pred(Stack.Count)].MadeActions, AltMe, Me^.Message)
   300                     end;
   307                     end;
   301             if (BotLevel < 3) and (GoInfo.JumpType = jmpLJump) then // ljump support
   308                 end;
   302                 begin
   309             if (BotLevel < 3) 
       
   310                 and (GoInfo.JumpType = jmpLJump) 
       
   311                 and (not checkMark(hwRound(Me^.X), hwRound(Me^.Y), markLJumped))
       
   312                 then // ljump support
       
   313                 begin
       
   314                 addMark(hwRound(Me^.X), hwRound(Me^.Y), markLJumped);
   303                 // at final check where we go after jump walking backward
   315                 // at final check where we go after jump walking backward
   304                 if Push(ticks, Actions, AltMe, Me^.Message xor 3) then
   316                 if Push(ticks, Actions, AltMe, Me^.Message xor 3) then
   305                     with Stack.States[Pred(Stack.Count)] do
   317                     with Stack.States[Pred(Stack.Count)] do
   306                         AddAction(MadeActions, aia_LJump, 0, 305 + random(50), 0, 0);
   318                         AddAction(MadeActions, aia_LJump, 0, 305 + random(50), 0, 0);
   307 
   319 
   332             else if Rate < BestRate then
   344             else if Rate < BestRate then
   333                 break;
   345                 break;
   334                 
   346                 
   335             if ((Me^.State and gstAttacked) = 0) and ((steps mod 4) = 0) then
   347             if ((Me^.State and gstAttacked) = 0) and ((steps mod 4) = 0) then
   336                 begin
   348                 begin
   337                 if (steps > 4) and checkMark(hwRound(Me^.X), hwRound(Me^.Y), markWasHere) then
   349                 if (steps > 4) and checkMark(hwRound(Me^.X), hwRound(Me^.Y), markWalkedHere) then
   338                     break;                    
   350                     break;                    
   339                 addMark(hwRound(Me^.X), hwRound(Me^.Y), markWasHere);
   351                 addMark(hwRound(Me^.X), hwRound(Me^.Y), markWalkedHere);
   340                 
   352                 
   341                 TestAmmos(Actions, Me, true);
   353                 TestAmmos(Actions, Me, true);
   342                 end;
   354                 end;
   343                 
   355                 
   344             if GoInfo.FallPix >= FallPixForBranching then
   356             if GoInfo.FallPix >= FallPixForBranching then
   447 if ((Me^.State and (gstAttacking or gstHHJumping or gstMoving)) <> 0)
   459 if ((Me^.State and (gstAttacking or gstHHJumping or gstMoving)) <> 0)
   448 or isInMultiShoot then
   460 or isInMultiShoot then
   449     exit;
   461     exit;
   450 
   462 
   451 //DeleteCI(Me); // this will break demo/netplay
   463 //DeleteCI(Me); // this will break demo/netplay
   452 clearAllMarks;
       
   453 
   464 
   454 Me^.State:= Me^.State or gstHHThinking;
   465 Me^.State:= Me^.State or gstHHThinking;
   455 Me^.Message:= 0;
   466 Me^.Message:= 0;
   456 
   467 
   457 BestActions.Count:= 0;
   468 BestActions.Count:= 0;