hedgewars/uAIAmmoTests.pas
branch0.9.14
changeset 4296 53d98ea25ac0
parent 4226 b39ca9d087a2
child 4317 ba5d5a2f4c4b
equal deleted inserted replaced
4294:5f589af376a5 4296:53d98ea25ac0
   294       dY:= dY + cGravity;
   294       dY:= dY + cGravity;
   295       dec(t)
   295       dec(t)
   296     until TestCollExcludingMe(Me, hwRound(x), hwRound(y), 5) or (t = 0);
   296     until TestCollExcludingMe(Me, hwRound(x), hwRound(y), 5) or (t = 0);
   297     EX:= hwRound(x);
   297     EX:= hwRound(x);
   298     EY:= hwRound(y);
   298     EY:= hwRound(y);
   299     if t < 50 then CheckTrace:= RateExplosion(Me, EX, EY, 81)
   299     if t < 50 then CheckTrace:= RateExplosion(Me, EX, EY, 41)
   300               else CheckTrace:= BadTurn
   300               else CheckTrace:= BadTurn
   301     end;
   301     end;
   302 begin
   302 begin
   303 valueResult:= BadTurn;
   303 valueResult:= BadTurn;
   304 TestTime:= 0;
   304 TestTime:= 0;
   308   // Try to overshoot slightly, seems to pay slightly better dividends in terms of hitting cluster
   308   // Try to overshoot slightly, seems to pay slightly better dividends in terms of hitting cluster
   309   if Me^.X<int2hwFloat(Targ.X) then
   309   if Me^.X<int2hwFloat(Targ.X) then
   310       Vx:= (int2hwFloat(Targ.X+10) - Me^.X) / int2hwFloat(TestTime + tDelta)
   310       Vx:= (int2hwFloat(Targ.X+10) - Me^.X) / int2hwFloat(TestTime + tDelta)
   311   else
   311   else
   312       Vx:= (int2hwFloat(Targ.X-10) - Me^.X) / int2hwFloat(TestTime + tDelta);
   312       Vx:= (int2hwFloat(Targ.X-10) - Me^.X) / int2hwFloat(TestTime + tDelta);
   313   Vy:= cGravity * ((TestTime + tDelta) div 2) - (int2hwFloat(Targ.Y-25) - Me^.Y) / int2hwFloat(TestTime + tDelta);
   313   Vy:= cGravity * ((TestTime + tDelta) div 2) - (int2hwFloat(Targ.Y-150) - Me^.Y) / int2hwFloat(TestTime + tDelta);
   314   r:= Distance(Vx, Vy);
   314   r:= Distance(Vx, Vy);
   315   if not (r > _1) then
   315   if not (r > _1) then
   316      begin
   316      begin
   317      Score:= CheckTrace;
   317      Score:= CheckTrace;
   318      if valueResult < Score then
   318      if valueResult < Score then
   319         begin
   319         begin
   320         ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random(Level));
   320         ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random(Level));
   321         ap.Power:= hwRound(r * cMaxPower) + AIrndSign(random(Level) * 15);
   321         ap.Power:= hwRound(r * cMaxPower * _0_9) + AIrndSign(random(Level) * 15);
   322         ap.Time:= TestTime;
   322         ap.Time:= TestTime;
   323         ap.ExplR:= 90;
   323         ap.ExplR:= 90;
   324         ap.ExplX:= EX;
   324         ap.ExplX:= EX;
   325         ap.ExplY:= EY;
   325         ap.ExplY:= EY;
   326         valueResult:= Score
   326         valueResult:= Score