hedgewars/uAIAmmoTests.pas
changeset 107 b08ce0293a51
parent 82 2f4f3236cccc
child 108 08f1fe6f21f8
equal deleted inserted replaced
106:98cb6606bf67 107:b08ce0293a51
    68 begin
    68 begin
    69 Result:= abs(x1 - x2) + abs(y1 - y2)
    69 Result:= abs(x1 - x2) + abs(y1 - y2)
    70 end;
    70 end;
    71 
    71 
    72 function TestBazooka(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
    72 function TestBazooka(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
    73 var Vx, Vy, r: real;
    73 var Vx, Vy, r: Double;
    74     rTime: real;
    74     rTime: Double;
    75     Score, EX, EY: integer;
    75     Score, EX, EY: integer;
    76 
    76 
    77     function CheckTrace: integer;
    77     function CheckTrace: integer;
    78     var x, y, dX, dY: real;
    78     var x, y, dX, dY: Double;
    79         t: integer;
    79         t: integer;
    80     begin
    80     begin
    81     x:= Me.X;
    81     x:= Me.X;
    82     y:= Me.Y;
    82     y:= Me.Y;
    83     dX:= Vx;
    83     dX:= Vx;
   123 until (rTime >= 4500)
   123 until (rTime >= 4500)
   124 end;
   124 end;
   125 
   125 
   126 function TestGrenade(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
   126 function TestGrenade(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
   127 const tDelta = 24;
   127 const tDelta = 24;
   128 var Vx, Vy, r: real;
   128 var Vx, Vy, r: Double;
   129     Score, EX, EY: integer;
   129     Score, EX, EY: integer;
   130     TestTime: Longword;
   130     TestTime: Longword;
   131 
   131 
   132     function CheckTrace: integer;
   132     function CheckTrace: integer;
   133     var x, y, dY: real;
   133     var x, y, dY: Double;
   134         t: integer;
   134         t: integer;
   135     begin
   135     begin
   136     x:= Me.X;
   136     x:= Me.X;
   137     y:= Me.Y;
   137     y:= Me.Y;
   138     dY:= -Vy;
   138     dY:= -Vy;
   175      end
   175      end
   176 until (TestTime = 5000)
   176 until (TestTime = 5000)
   177 end;
   177 end;
   178 
   178 
   179 function TestShotgun(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
   179 function TestShotgun(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
   180 var Vx, Vy, x, y: real;
   180 var Vx, Vy, x, y: Double;
   181 begin
   181 begin
   182 ExplR:= 0;
   182 ExplR:= 0;
   183 if Metric(round(Me.X), round(Me.Y), Targ.X, Targ.Y) < 80 then
   183 if Metric(round(Me.X), round(Me.Y), Targ.X, Targ.Y) < 80 then
   184    begin
   184    begin
   185    Result:= BadTurn;
   185    Result:= BadTurn;
   204 until (abs(Targ.X - x) + abs(Targ.Y - y) < 4) or (x < 0) or (y < 0) or (x > 2048) or (y > 1024);
   204 until (abs(Targ.X - x) + abs(Targ.Y - y) < 4) or (x < 0) or (y < 0) or (x > 2048) or (y > 1024);
   205 Result:= BadTurn
   205 Result:= BadTurn
   206 end;
   206 end;
   207 
   207 
   208 function TestDesertEagle(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
   208 function TestDesertEagle(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
   209 var Vx, Vy, x, y, t: real;
   209 var Vx, Vy, x, y, t: Double;
   210     d: Longword;
   210     d: Longword;
   211 begin
   211 begin
   212 ExplR:= 0;
   212 ExplR:= 0;
   213 if abs(Me.X - Targ.X) + abs(Me.Y - Targ.Y) < 80 then
   213 if abs(Me.X - Targ.X) + abs(Me.Y - Targ.Y) < 80 then
   214    begin
   214    begin