# HG changeset patch # User unc0rr # Date 1321614332 -14400 # Node ID bb04d7a9f7e24a99e7ddf002fd0e44837b8195b3 # Parent f0a9042e7387f0f28d29390f9af7abe6d43f3606 Make AI be less scared by crates. Actually, now it starts using switcher just to pick a crate up. diff -r f0a9042e7387 -r bb04d7a9f7e2 hedgewars/uAI.pas --- a/hedgewars/uAI.pas Fri Nov 18 00:32:52 2011 +0100 +++ b/hedgewars/uAI.pas Fri Nov 18 15:05:32 2011 +0400 @@ -132,6 +132,7 @@ begin BestActions:= Actions; inc(BestActions.Score, Score); + BestActions.isWalkingToABetterPlace:= false; if (ap.Angle > 0) then AddAction(BestActions, aia_LookRight, 0, 200, 0, 0) else if (ap.Angle < 0) then AddAction(BestActions, aia_LookLeft, 0, 200, 0, 0); @@ -245,6 +246,7 @@ if Rate > BestRate then begin BestActions:= Actions; + BestActions.isWalkingToABetterPlace:= true; BestRate:= Rate; Me^.State:= Me^.State or gstAttacked // we have better place, go there and do not use ammo end @@ -307,11 +309,12 @@ inc(switchesNum); until (not (switchImmediatelyAvailable or switchAvailable)) or StopThinking - or (itHedgehog = currHedgehogIndex); + or (itHedgehog = currHedgehogIndex) + or BestActions.isWalkingToABetterPlace; if (StartTicks > GameTicks - 1500) and (not StopThinking) then SDL_Delay(1000); - if BestActions.Score < -1023 then + if (BestActions.Score < -1023) and (not BestActions.isWalkingToABetterPlace) then begin BestActions.Count:= 0; AddAction(BestActions, aia_Skip, 0, 250, 0, 0); @@ -349,6 +352,7 @@ BestActions.Count:= 0; BestActions.Pos:= 0; BestActions.Score:= Low(LongInt); +BestActions.isWalkingToABetterPlace:= false; StopThinking:= false; ThinkingHH:= Me; diff -r f0a9042e7387 -r bb04d7a9f7e2 hedgewars/uAIActions.pas --- a/hedgewars/uAIActions.pas Fri Nov 18 00:32:52 2011 +0100 +++ b/hedgewars/uAIActions.pas Fri Nov 18 15:05:32 2011 +0400 @@ -57,6 +57,7 @@ Count, Pos: Longword; actions: array[0..Pred(MAXACTIONS)] of TAction; Score: LongInt; + isWalkingToABetterPlace: boolean; end; procedure AddAction(var Actions: TActions; Action: Longword; Param: LongInt; TimeDelta: Longword; X, Y: LongInt);