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