diff -r 6dc7ccc0b043 -r a46ce1812419 hedgewars/uAI.pas --- a/hedgewars/uAI.pas Wed Jul 25 22:36:39 2012 +0400 +++ b/hedgewars/uAI.pas Wed Jul 25 22:46:03 2012 +0400 @@ -31,7 +31,7 @@ implementation uses uConsts, SDLh, uAIMisc, uAIAmmoTests, uAIActions, uAmmos, SysUtils{$IFNDEF USE_SDLTHREADS} {$IFDEF UNIX}, cthreads{$ENDIF} {$ENDIF}, uTypes, - uVariables, uCommands, uUtils, uDebug; + uVariables, uCommands, uUtils, uDebug, uAILandMarks; var BestActions: TActions; CanUseAmmo: array [TAmmoType] of boolean; @@ -212,7 +212,7 @@ end; procedure Walk(Me: PGear; var Actions: TActions); -const FallPixForBranching = cHHRadius * 2 + 8; +const FallPixForBranching = cHHRadius; var ticks, maxticks, steps, tmp: Longword; BaseRate, BestRate, Rate: integer; @@ -275,6 +275,7 @@ if (BotLevel < 5) and (GoInfo.JumpType = jmpHJump) then // hjump support if Push(ticks, Actions, AltMe, Me^.Message) then + begin with Stack.States[Pred(Stack.Count)] do begin if Me^.dX.isNegative then @@ -290,11 +291,21 @@ else AddAction(MadeActions, aia_LookRight, 0, 200, 0, 0); end; + + // check if we could go backwards and maybe ljump over a gap after this hjump + Push(ticks, Stack.States[Pred(Stack.Count)].MadeActions, AltMe, Me^.Message xor 3) + end; if (BotLevel < 3) and (GoInfo.JumpType = jmpLJump) then // ljump support begin - // push current position so we proceed from it after checking jump opportunities + // at final check where we go after jump walking backward + if Push(ticks, Actions, AltMe, Me^.Message xor 3) then + with Stack.States[Pred(Stack.Count)] do + AddAction(MadeActions, aia_LJump, 0, 305 + random(50), 0, 0); + + // push current position so we proceed from it after checking jump+forward walk opportunities if CanGo then Push(ticks, Actions, Me^, Me^.Message); - // first check where we go after jump + + // first check where we go after jump walking forward if Push(ticks, Actions, AltMe, Me^.Message) then with Stack.States[Pred(Stack.Count)] do AddAction(MadeActions, aia_LJump, 0, 305 + random(50), 0, 0); @@ -317,8 +328,16 @@ end else if Rate < BestRate then break; + if ((Me^.State and gstAttacked) = 0) and ((steps mod 4) = 0) then + begin + if (steps > 4) and checkMark(hwRound(Me^.X), hwRound(Me^.Y), markWasHere) then + break; + addMark(hwRound(Me^.X), hwRound(Me^.Y), markWasHere); + TestAmmos(Actions, Me, true); + end; + if GoInfo.FallPix >= FallPixForBranching then Push(ticks, Actions, Me^, Me^.Message xor 3); // aia_Left xor 3 = aia_Right end {while}; @@ -426,7 +445,9 @@ or isInMultiShoot then exit; -//DeleteCI(Me); // this might break demo +//DeleteCI(Me); // this will break demo/netplay +clearAllMarks; + Me^.State:= Me^.State or gstHHThinking; Me^.Message:= 0;