and melon for Mutant
authornemo
Sun, 19 Aug 2018 09:54:46 -0400
changeset 13671 7a31a292fa84
parent 13670 fe20626ed80b
child 13672 8bd973ab9c9c
child 13673 1aa5e884326a
and melon for Mutant
hedgewars/uAIAmmoTests.pas
--- a/hedgewars/uAIAmmoTests.pas	Fri Aug 17 22:35:01 2018 -0400
+++ b/hedgewars/uAIAmmoTests.pas	Sun Aug 19 09:54:46 2018 -0400
@@ -650,7 +650,7 @@
 var Vx, Vy, r: real;
     Score, EX, EY, valueResult: LongInt;
     TestTime: Longword;
-    x, y, dY, meX, meY: real;
+    targXWrap, x, y, dY, meX, meY: real;
     t: LongInt;
 begin
 valueResult:= BadTurn;
@@ -658,9 +658,15 @@
 ap.ExplR:= 0;
 meX:= hwFloat2Float(Me^.X);
 meY:= hwFloat2Float(Me^.Y);
+if (WorldEdge = weWrap) then
+    if (Targ.Point.X < meX) then
+         targXWrap:= Targ.Point.X + (RightX-LeftX)
+    else targXWrap:= Targ.Point.X - (RightX-LeftX);
 repeat
     inc(TestTime, 900);
-    Vx:= (Targ.Point.X - meX) / (TestTime + tDelta);
+    if (WorldEdge = weWrap) and (random(2)=0) then
+		 Vx:= (targXWrap - meX) / (TestTime + tDelta)
+    else Vx:= (Targ.Point.X - meX) / (TestTime + tDelta);
     Vy:= cGravityf * ((TestTime + tDelta) div 2) - ((Targ.Point.Y-50) - meY) / (TestTime + tDelta);
     r:= sqr(Vx)+sqr(Vy);
     if not (r > 1) then
@@ -670,6 +676,7 @@
         dY:= -Vy;
         t:= TestTime;
         repeat
+            x:= CheckWrap(x);
             x:= x + Vx;
             y:= y + dY;
             dY:= dY + cGravityf;