130 if Actions.Score + Score > BestActions.Score then |
130 if Actions.Score + Score > BestActions.Score then |
131 if (BestActions.Score < 0) or (Actions.Score + Score > BestActions.Score + Byte(BotLevel) * 2048) then |
131 if (BestActions.Score < 0) or (Actions.Score + Score > BestActions.Score + Byte(BotLevel) * 2048) then |
132 begin |
132 begin |
133 BestActions:= Actions; |
133 BestActions:= Actions; |
134 inc(BestActions.Score, Score); |
134 inc(BestActions.Score, Score); |
|
135 BestActions.isWalkingToABetterPlace:= false; |
135 |
136 |
136 if (ap.Angle > 0) then AddAction(BestActions, aia_LookRight, 0, 200, 0, 0) |
137 if (ap.Angle > 0) then AddAction(BestActions, aia_LookRight, 0, 200, 0, 0) |
137 else if (ap.Angle < 0) then AddAction(BestActions, aia_LookLeft, 0, 200, 0, 0); |
138 else if (ap.Angle < 0) then AddAction(BestActions, aia_LookLeft, 0, 200, 0, 0); |
138 |
139 |
139 AddAction(BestActions, aia_Weapon, Longword(a), 300 + random(400), 0, 0); |
140 AddAction(BestActions, aia_Weapon, Longword(a), 300 + random(400), 0, 0); |
243 Actions.actions[Pred(Actions.Count)].Param:= hwRound(Me^.X); |
244 Actions.actions[Pred(Actions.Count)].Param:= hwRound(Me^.X); |
244 Rate:= RatePlace(Me); |
245 Rate:= RatePlace(Me); |
245 if Rate > BestRate then |
246 if Rate > BestRate then |
246 begin |
247 begin |
247 BestActions:= Actions; |
248 BestActions:= Actions; |
|
249 BestActions.isWalkingToABetterPlace:= true; |
248 BestRate:= Rate; |
250 BestRate:= Rate; |
249 Me^.State:= Me^.State or gstAttacked // we have better place, go there and do not use ammo |
251 Me^.State:= Me^.State or gstAttacked // we have better place, go there and do not use ammo |
250 end |
252 end |
251 else if Rate < BestRate then break; |
253 else if Rate < BestRate then break; |
252 if ((Me^.State and gstAttacked) = 0) |
254 if ((Me^.State and gstAttacked) = 0) |
305 until (itHedgehog = currHedgehogIndex) or (CurrentTeam^.Hedgehogs[itHedgehog].Gear <> nil); |
307 until (itHedgehog = currHedgehogIndex) or (CurrentTeam^.Hedgehogs[itHedgehog].Gear <> nil); |
306 |
308 |
307 inc(switchesNum); |
309 inc(switchesNum); |
308 until (not (switchImmediatelyAvailable or switchAvailable)) |
310 until (not (switchImmediatelyAvailable or switchAvailable)) |
309 or StopThinking |
311 or StopThinking |
310 or (itHedgehog = currHedgehogIndex); |
312 or (itHedgehog = currHedgehogIndex) |
|
313 or BestActions.isWalkingToABetterPlace; |
311 |
314 |
312 if (StartTicks > GameTicks - 1500) and (not StopThinking) then SDL_Delay(1000); |
315 if (StartTicks > GameTicks - 1500) and (not StopThinking) then SDL_Delay(1000); |
313 |
316 |
314 if BestActions.Score < -1023 then |
317 if (BestActions.Score < -1023) and (not BestActions.isWalkingToABetterPlace) then |
315 begin |
318 begin |
316 BestActions.Count:= 0; |
319 BestActions.Count:= 0; |
317 AddAction(BestActions, aia_Skip, 0, 250, 0, 0); |
320 AddAction(BestActions, aia_Skip, 0, 250, 0, 0); |
318 end; |
321 end; |
319 |
322 |