diff -r e095e3023682 -r 7f04ad2cda54 hedgewars/uAI.pas --- a/hedgewars/uAI.pas Sun Apr 21 01:36:08 2013 +0200 +++ b/hedgewars/uAI.pas Wed May 29 22:52:37 2013 +0400 @@ -126,10 +126,10 @@ then begin {$HINTS OFF} - Score:= AmmoTests[a].proc(Me, Targets.ar[i].Point, BotLevel, ap); + Score:= AmmoTests[a].proc(Me, Targets.ar[i], BotLevel, ap); {$HINTS ON} if Actions.Score + Score > BestActions.Score then - if (BestActions.Score < 0) or (Actions.Score + Score > BestActions.Score + Byte(BotLevel) * 2048) then + if (BestActions.Score < 0) or (Actions.Score + Score > BestActions.Score + Byte(BotLevel - 1) * 2048) then begin BestActions:= Actions; inc(BestActions.Score, Score); @@ -366,7 +366,6 @@ switchImmediatelyAvailable: boolean; Actions: TActions; begin -AddFileLog('Think thread started'); dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent; StartTicks:= GameTicks; currHedgehogIndex:= CurrentTeam^.CurrHedgehog; @@ -378,7 +377,7 @@ switchCount:= HHHasAmmo(PGear(Me)^.Hedgehog^, amSwitch) else switchCount:= 0; -if (Me^.State and gstAttacked) = 0 then +if ((Me^.State and gstAttacked) = 0) or isInMultiShoot then if Targets.Count > 0 then begin // iterate over current team hedgehogs @@ -427,7 +426,8 @@ else begin BackMe:= Me^; - while (not StopThinking) and (BestActions.Count = 0) do + i:= 12; + while (not StopThinking) and (BestActions.Count = 0) and (i > 0) do begin (* // Maybe this would get a bit of movement out of them? Hopefully not *toward* water. Need to check how often he'd choose that strategy @@ -440,6 +440,7 @@ Actions.Pos:= 0; Actions.Score:= 0; Walk(@WalkMe, Actions); + dec(i); if not StopThinking then SDL_Delay(100) end @@ -478,14 +479,16 @@ exit end; -FillBonuses((Me^.State and gstAttacked) <> 0); +FillBonuses(((Me^.State and gstAttacked) <> 0) and (not isInMultiShoot)); SDL_LockMutex(ThreadLock); ThinkThread:= SDL_CreateThread(@Think{$IFDEF SDL13}, 'think'{$ENDIF}, Me); SDL_UnlockMutex(ThreadLock); end; -//var scoreShown: boolean = false; +{$IFDEF DEBUGAI} +var scoreShown: boolean = false; +{$ENDIF} procedure ProcessBot; const cStopThinkTime = 40; @@ -507,17 +510,21 @@ if Gear^.Message <> 0 then exit; - //scoreShown:= false; +{$IFDEF DEBUGAI} + scoreShown:= false; +{$ENDIF} StartThink(Gear); StartTicks:= GameTicks end else begin - {if not scoreShown then +{$IFDEF DEBUGAI} + if not scoreShown then begin if BestActions.Score > 0 then ParseCommand('/say Expected score = ' + inttostr(BestActions.Score div 1024), true); scoreShown:= true - end;} + end; +{$ENDIF} ProcessAction(BestActions, Gear) end else if ((GameTicks - StartTicks) > cMaxAIThinkTime)