hedgewars/uAI.pas
changeset 351 29bc9c36ad5f
parent 295 8834f3cb620e
child 369 2aed85310727
equal deleted inserted replaced
350:c3ccec3834e8 351:29bc9c36ad5f
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    17  *)
    17  *)
    18 
    18 
    19 unit uAI;
    19 unit uAI;
    20 interface
    20 interface
       
    21 uses uFloat;
    21 {$INCLUDE options.inc}
    22 {$INCLUDE options.inc}
    22 procedure ProcessBot(FrameNo: Longword);
    23 procedure ProcessBot(FrameNo: Longword);
    23 procedure FreeActionsList;
    24 procedure FreeActionsList;
    24 
    25 
    25 implementation
    26 implementation
    26 uses uTeams, uConsts, SDLh, uAIMisc, uGears, uAIAmmoTests, uAIActions, uMisc,
    27 {uses uTeams, uConsts, SDLh, uAIMisc, uGears, uAIAmmoTests, uAIActions, uMisc,
    27      uAIThinkStack, uAmmos;
    28      uAIThinkStack, uAmmos;
    28 
    29 
    29 var BestActions: TActions;
    30 var BestActions: TActions;
    30     CanUseAmmo: array [TAmmoType] of boolean;
    31     CanUseAmmo: array [TAmmoType] of boolean;
    31     AIThinkStart: Longword;
    32     AIThinkStart: Longword;
    32     isThinking: boolean = false;
    33     isThinking: boolean = false;
    33 
    34 
    34 procedure FreeActionsList;
    35 }procedure FreeActionsList;
    35 begin
    36 begin
    36 isThinking:= false;
    37 {isThinking:= false;
    37 BestActions.Count:= 0;
    38 BestActions.Count:= 0;
    38 BestActions.Pos:= 0
    39 BestActions.Pos:= 0
    39 end;
    40 }end;
    40 
    41 {
    41 procedure TestAmmos(var Actions: TActions; Me: PGear);
    42 procedure TestAmmos(var Actions: TActions; Me: PGear);
    42 var Time, BotLevel: Longword;
    43 var Time, BotLevel: Longword;
    43     Angle, Power, Score, ExplX, ExplY, ExplR: integer;
    44     Angle, Power, Score, ExplX, ExplY, ExplR: integer;
    44     i: integer;
    45     i: integer;
    45     a, aa: TAmmoType;
    46     a, aa: TAmmoType;
   233 Push(0, BestActions, Me^, tmp);
   234 Push(0, BestActions, Me^, tmp);
   234 Push(0, BestActions, Me^, tmp xor 3);
   235 Push(0, BestActions, Me^, tmp xor 3);
   235 BestActions.Score:= Low(integer);
   236 BestActions.Score:= Low(integer);
   236 
   237 
   237 Think(Me)
   238 Think(Me)
   238 end;
   239 end; }
   239 
   240 
   240 procedure ProcessBot(FrameNo: Longword);
   241 procedure ProcessBot(FrameNo: Longword);
   241 const LastFrameNo: Longword = 0;
   242 //const LastFrameNo: Longword = 0;
   242 begin
   243 begin
   243 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
   244 {with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
   244      if (Gear <> nil)
   245      if (Gear <> nil)
   245         and ((Gear.State and gstHHDriven) <> 0)
   246         and ((Gear.State and gstHHDriven) <> 0)
   246         and (TurnTimeLeft < cHedgehogTurnTime - 50) then
   247         and (TurnTimeLeft < cHedgehogTurnTime - 50) then
   247         if not isThinking then
   248         if not isThinking then
   248            if (BestActions.Pos >= BestActions.Count) then StartThink(Gear)
   249            if (BestActions.Pos >= BestActions.Count) then StartThink(Gear)
   250         else if FrameNo <> LastFrameNo then
   251         else if FrameNo <> LastFrameNo then
   251                 begin
   252                 begin
   252                 LastFrameNo:= FrameNo;
   253                 LastFrameNo:= FrameNo;
   253                 Think(Gear)
   254                 Think(Gear)
   254                 end;
   255                 end;
   255 end;
   256 }end;
   256 
   257 
   257 end.
   258 end.