hedgewars/uAI.pas
changeset 3407 dcc129c4352e
parent 3236 4ab3917d7d44
child 3615 b78d7959540a
--- a/hedgewars/uAI.pas	Sun May 02 20:30:23 2010 +0000
+++ b/hedgewars/uAI.pas	Sun May 02 22:00:50 2010 +0000
@@ -30,7 +30,7 @@
 
 implementation
 uses uTeams, uConsts, SDLh, uAIMisc, uGears, uAIAmmoTests, uAIActions, uMisc,
-     uAmmos, uConsole, uCollisions, SysUtils{$IFDEF UNIX}, cthreads{$ENDIF};
+     uAmmos, uConsole, SysUtils{$IFDEF UNIX}, cthreads{$ENDIF};
 
 var BestActions: TActions;
     CanUseAmmo: array [TAmmoType] of boolean;
@@ -60,7 +60,7 @@
 end;
 
 procedure TestAmmos(var Actions: TActions; Me: PGear; isMoved: boolean);
-var BotLevel: Longword;
+var BotLevel: Byte;
     ap: TAttackParams;
     Score, i: LongInt;
     a, aa: TAmmoType;
@@ -77,9 +77,11 @@
         if (CanUseAmmo[a]) and
            ((not isMoved) or ((AmmoTests[a].flags and amtest_OnTurn) = 0)) then
            begin
+{$HINTS OFF}
            Score:= AmmoTests[a].proc(Me, Targets.ar[i].Point, BotLevel, ap);
+{$HINTS ON}
            if Actions.Score + Score > BestActions.Score then
-            if (BestActions.Score < 0) or (Actions.Score + Score > BestActions.Score + LongInt(BotLevel) * 2048) then
+            if (BestActions.Score < 0) or (Actions.Score + Score > BestActions.Score + Byte(BotLevel) * 2048) then
               begin
               BestActions:= Actions;
               inc(BestActions.Score, Score);
@@ -180,12 +182,14 @@
 
 
 var Actions: TActions;
-    ticks, maxticks, steps, BotLevel, tmp: Longword;
+    ticks, maxticks, steps, tmp: Longword;
     BaseRate, BestRate, Rate: integer;
     GoInfo: TGoInfo;
     CanGo: boolean;
     AltMe: TGear;
+    BotLevel: Byte;
 begin
+ticks:= 0; // avoid compiler hint
 Actions.Count:= 0;
 Actions.Pos:= 0;
 Actions.Score:= 0;
@@ -196,7 +200,7 @@
 Push(0, Actions, Me^, tmp);
 Push(0, Actions, Me^, tmp xor 3);
 
-if (Me^.State and gstAttacked) = 0 then maxticks:= max(0, TurnTimeLeft - 5000 - 4000 * BotLevel)
+if (Me^.State and gstAttacked) = 0 then maxticks:= max(0, TurnTimeLeft - 5000 - LongWord(4000 * BotLevel))
                                    else maxticks:= TurnTimeLeft;
 
 if (Me^.State and gstAttacked) = 0 then TestAmmos(Actions, Me, false);
@@ -214,7 +218,9 @@
 
     while (not StopThinking) and (not PosInThinkStack(Me)) do
        begin
+{$HINTS OFF}
        CanGo:= HHGo(Me, @AltMe, GoInfo);
+{$HINTS ON}
        inc(ticks, GoInfo.Ticks);
        if ticks > maxticks then break;