# HG changeset patch # User unc0rr # Date 1160503428 0 # Node ID 56885ea2920232193210659930ef2f333498fafa # Parent b644f61e803f8c9099351aba276e085d746b388f Fix bots regressions diff -r b644f61e803f -r 56885ea29202 hedgewars/CMakeLists.txt --- a/hedgewars/CMakeLists.txt Mon Oct 09 18:26:44 2006 +0000 +++ b/hedgewars/CMakeLists.txt Tue Oct 10 18:03:48 2006 +0000 @@ -24,12 +24,12 @@ string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}") string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}") math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}") - if (${fpc_ver} LESS "010906") - message("Minimum required version of FreePascal is 2.0.5") - else (${fpc_ver} LESS "010906") + if (fpc_ver LESS "010906") + message("Minimum required version of FreePascal is 1.9.6") + else (fpc_ver LESS "010906") set(pascal_compiler ${fpc_executable}) set(pascal_compiler_flags "-B" "-Sd" "-Xs" "-OG" "-O2" "-Cs2000000" ${hwengine_project}) - endif (${fpc_ver} LESS "010906") + endif (fpc_ver LESS "010906") endif (fpc_version) endif (dcc32version) diff -r b644f61e803f -r 56885ea29202 hedgewars/uAI.pas --- a/hedgewars/uAI.pas Mon Oct 09 18:26:44 2006 +0000 +++ b/hedgewars/uAI.pas Tue Oct 10 18:03:48 2006 +0000 @@ -114,8 +114,11 @@ isThinking:= false; exit end; + if ((Me.State and gstAttacked) = 0) then TestAmmos(Actions, Me); + AddAction(Actions, Me.Message, aim_push, 250); - AddAction(Actions, aia_WaitX, round(Me.X), 0); + if (Me.Message and gm_Left) <> 0 then AddAction(Actions, aia_WaitXL, round(Me.X), 0) + else AddAction(Actions, aia_WaitXR, round(Me.X), 0); AddAction(Actions, Me.Message, aim_release, 0); steps:= 0; @@ -123,12 +126,11 @@ begin if SDL_GetTicks - AIThinkStart > 3 then begin - writetoconsole(inttostr(SDL_GetTicks - AIThinkStart) + ' '); dec(Actions.Count, 3); Push(ticks, Actions, Me^, Me^.Message); exit end; - + CanGo:= HHGo(Me, @AltMe, GoInfo); inc(ticks, GoInfo.Ticks); if ticks > maxticks then break; @@ -157,17 +159,17 @@ exit end else if Rate < BaseRate then break; + if GoInfo.FallPix >= FallPixForBranching then + Push(ticks, Actions, Me^, Me^.Message xor 3); // aia_Left xor 3 = aia_Right + if ((Me.State and gstAttacked) = 0) and ((steps mod 4) = 0) then TestAmmos(Actions, Me); - if GoInfo.FallPix >= FallPixForBranching then - Push(ticks, Actions, Me^, Me^.Message xor 3); // aia_Left xor 3 = aia_Right end; until false end; procedure Think(Me: PGear); var BackMe, WalkMe: TGear; -// StartTicks: Longword; begin AIThinkStart:= SDL_GetTicks; BackMe:= Me^; @@ -183,12 +185,12 @@ BestActions.Count:= 0; AddAction(BestActions, aia_Skip, 0, 250); end; - Me.State:= Me.State and not gstHHThinking end end else else begin FillBonuses(true); - Walk(@WalkMe) + Walk(@WalkMe); + AddAction(BestActions, aia_Wait, GameTicks + 100, 100); end end; @@ -219,9 +221,11 @@ BestActions.Count:= 0; BestActions.Pos:= 0; BestActions.Score:= 0; +AddAction(BestActions, aia_Wait, GameTicks + 1500{ + Longword(random(1000))}, 1500); tmp:= random(2) + 1; Push(0, BestActions, Me^, tmp); Push(0, BestActions, Me^, tmp xor 3); +BestActions.Count:= 0; BestActions.Score:= Low(integer); Think(Me) @@ -230,8 +234,6 @@ procedure ProcessBot(FrameNo: Longword); const LastFrameNo: Longword = 0; begin -if FrameNo = LastFrameNo then exit; -LastFrameNo:= FrameNo; with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do if (Gear <> nil) and ((Gear.State and gstHHDriven) <> 0) @@ -239,7 +241,11 @@ if not isThinking then if (BestActions.Pos >= BestActions.Count) then StartThink(Gear) else ProcessAction(BestActions, Gear) - else Think(Gear) + else if FrameNo <> LastFrameNo then + begin + LastFrameNo:= FrameNo; + Think(Gear) + end; end; end. diff -r b644f61e803f -r 56885ea29202 hedgewars/uAIActions.pas --- a/hedgewars/uAIActions.pas Mon Oct 09 18:26:44 2006 +0000 +++ b/hedgewars/uAIActions.pas Tue Oct 10 18:03:48 2006 +0000 @@ -30,14 +30,15 @@ aia_Down = 6; aia_Weapon = $80000000; - aia_WaitX = $80000001; - aia_WaitY = $80000002; + aia_WaitXL = $80000001; + aia_WaitXR = $80000002; aia_LookLeft = $80000003; aia_LookRight = $80000004; aia_AwareExpl = $80000005; aia_HJump = $80000006; aia_LJump = $80000007; aia_Skip = $80000008; + aia_Wait = $80000009; aim_push = $80000000; aim_release = $80000001; @@ -71,7 +72,7 @@ ); {$IFDEF TRACEAIACTIONS} -const SpecActionIdToStr: array[$80000000..$80000008] of string[16] = ( +const SpecActionIdToStr: array[$80000000..$80000009] of string[16] = ( {aia_Weapon} 'aia_Weapon', {aia_WaitX} 'aia_WaitX', {aia_WaitY} 'aia_WaitY', @@ -80,7 +81,8 @@ {aia_AwareExpl} 'aia_AwareExpl', {aia_HJump} 'aia_HJump', {aia_LJump} 'aia_LJump', -{aia_Skip} 'aia_Skip' +{aia_Skip} 'aia_Skip', +{aia_Wait} 'aia_Wait' ); procedure DumpAction(Action: TAction; Me: PGear); @@ -89,7 +91,7 @@ WriteLnToConsole('AI action: '+ActionIdToStr[Action.Action]) else begin WriteLnToConsole('AI action: '+SpecActionIdToStr[Action.Action]); - if Action.Action = aia_WaitX then + if (Action.Action = aia_WaitXL) or (Action.Action = aia_WaitXR) then WriteLnToConsole('AI action Wait X = '+inttostr(Action.Param)+', current X = '+inttostr(round(Me.X))); end end; @@ -123,10 +125,20 @@ if (Action and ai_specmask) <> 0 then case Action of aia_Weapon: SetWeapon(TAmmoType(Param)); - aia_WaitX: if round(Me.X) = Param then Time:= GameTicks - else exit; - aia_WaitY: if round(Me.Y) = Param then Time:= GameTicks - else exit; + aia_WaitXL: if round(Me.X) = Param then Time:= GameTicks + else if Round(Me.X) < Param then + begin + OutError('AI: WaitXL assert'); + Actions.Count:= 0 + end + else exit; + aia_WaitXR: if round(Me.X) = Param then Time:= GameTicks + else if Round(Me.X) > Param then + begin + OutError('AI: WaitXR assert'); + Actions.Count:= 0 + end + else exit; aia_LookLeft: if Me.dX >= 0 then begin ParseCommand('+left'); @@ -141,6 +153,9 @@ aia_HJump: ParseCommand('hjump'); aia_LJump: ParseCommand('ljump'); aia_Skip: ParseCommand('skip'); + aia_Wait: if Param > GameTicks then exit + else with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do + Gear.State:= Gear.State and not gstHHThinking end else begin s:= ActionIdToStr[Action];