hedgewars/uAI.pas
changeset 7110 c91d33837b0d
parent 7078 a3408d9ba5ad
child 7132 baf3351646f4
equal deleted inserted replaced
7020:846cea23aea2 7110:c91d33837b0d
    40     ThinkThread: PSDL_Thread = nil;
    40     ThinkThread: PSDL_Thread = nil;
    41 {$ELSE}
    41 {$ELSE}
    42     ThinkThread: TThreadID;
    42     ThinkThread: TThreadID;
    43 {$ENDIF}
    43 {$ENDIF}
    44     hasThread: LongInt;
    44     hasThread: LongInt;
       
    45     StartTicks: Longword;
    45 
    46 
    46 procedure FreeActionsList;
    47 procedure FreeActionsList;
    47 begin
    48 begin
    48 AddFileLog('FreeActionsList called');
    49     AddFileLog('FreeActionsList called');
    49 if hasThread <> 0 then
    50     if hasThread <> 0 then
    50     begin
    51     begin
    51     AddFileLog('Waiting AI thread to finish');
    52         AddFileLog('Waiting AI thread to finish');
    52     StopThinking:= true;
    53         StopThinking:= true;
    53     repeat
    54         repeat
    54         SDL_Delay(10)
    55             SDL_Delay(10)
    55     until hasThread = 0
    56         until hasThread = 0
    56     end;
    57     end;
    57 
    58 
    58 with CurrentHedgehog^ do
    59     with CurrentHedgehog^ do
    59     if Gear <> nil then
    60         if Gear <> nil then
    60         if BotLevel <> 0 then
    61             if BotLevel <> 0 then
    61             StopMessages(Gear^.Message);
    62                 StopMessages(Gear^.Message);
    62 
    63 
    63 BestActions.Count:= 0;
    64     BestActions.Count:= 0;
    64 BestActions.Pos:= 0
    65     BestActions.Pos:= 0
    65 end;
    66 end;
    66 
    67 
    67 
    68 
    68 
    69 
    69 const cBranchStackSize = 12;
    70 const cBranchStackSize = 12;
   112     ap: TAttackParams;
   113     ap: TAttackParams;
   113     Score, i: LongInt;
   114     Score, i: LongInt;
   114     a, aa: TAmmoType;
   115     a, aa: TAmmoType;
   115 begin
   116 begin
   116 BotLevel:= Me^.Hedgehog^.BotLevel;
   117 BotLevel:= Me^.Hedgehog^.BotLevel;
       
   118 windSpeed:= hwFloat2Float(cWindSpeed);
   117 
   119 
   118 for i:= 0 to Pred(Targets.Count) do
   120 for i:= 0 to Pred(Targets.Count) do
   119     if (Targets.ar[i].Score >= 0) and (not StopThinking) then
   121     if (Targets.ar[i].Score >= 0) and (not StopThinking) then
   120         begin
   122         begin
   121         with Me^.Hedgehog^ do
   123         with Me^.Hedgehog^ do
   443     ThinkThread:= ThinkThread;
   445     ThinkThread:= ThinkThread;
   444 end;
   446 end;
   445 
   447 
   446 procedure freeModule;
   448 procedure freeModule;
   447 begin
   449 begin
   448 
   450     FreeActionsList();
   449 end;
   451 end;
   450 
   452 
   451 end.
   453 end.