Thread history

From User talk:Voidious
Viewing a history listing
Jump to navigation Jump to search
Time User Activity Comment
07:12, 2 June 2012 Voidious (talk | contribs) New thread created  
08:09, 2 June 2012 Wompi (talk | contribs) New reply created (Reply to weird bug I'm hitting)
11:33, 2 June 2012 Skilgannon (talk | contribs) New reply created (Reply to weird bug I'm hitting)
15:14, 2 June 2012 Rednaxela (talk | contribs) New reply created (Reply to weird bug I'm hitting)
18:52, 2 June 2012 Voidious (talk | contribs) New reply created (Reply to weird bug I'm hitting)
06:03, 3 June 2012 Rednaxela (talk | contribs) New reply created (Reply to weird bug I'm hitting)

weird bug I'm hitting

I'm hitting a bizarre bug in either Robocode or my JVM. Basically, I calculate the enemy's position each tick, and on successive ticks, the distance between the positions is greater than 8, which should be impossible. Frequently it's like 11 or 15, occasionally more like 40 or 70. Can anyone else duplicate this? It seems to only happen when running minimized, so I don't think it's any issue with my code. And I'm checking that e.getTime() is only 1 apart, so it's not skipped turns. And it is happening in 1v1 with a radar lock.

For a while this came in the form of thinking my freshly rewritten scan interpolation had a bug. (Which seemed a lot like the "bug" in the old interpolation code...)

This is the right calculation of enemy location, right?

 Point2D.Double enemyLocation = 
     project(new Point2D.Double(getX(), getY()), Utils.normalAbsoluteAngle(
         e.getBearingRadians() + getHeadingRadians()),
         e.getDistance());
 public static Point2D.Double project(Point2D.Double sourceLocation,
     double angle, double length) {
   return project(sourceLocation, Math.sin(angle), Math.cos(angle), length);
 }
 public static Point2D.Double project(Point2D.Double sourceLocation,
     double sinAngle, double cosAngle, double length) {
   return new Point2D.Double(sourceLocation.x + sinAngle * length,
       sourceLocation.y + cosAngle * length);
 }

Voidious07:12, 2 June 2012

Works fine for me (mac).

Wompi08:09, 2 June 2012
 

Your code here looks fine. Have you tried a simple radar + test bot?

Skilgannon11:33, 2 June 2012
 

Hm, the code looks fine to me. Can you perhaps have Robocode save a replay file, and make note of the ticks your robot notices things moving too fast? That way we could compare this to Robocode's internal representation of things, so it would be easier to tell where the problem is.

Rednaxela15:14, 2 June 2012
 

Wow, good call on the replay file, never looked at one of these before. So it's pretty clear something about the ScannedRobotEvent from the previous tick was wrong - I suspect it's an old ScannedRobotEvent with the wrong time. (I noticed when doing some unit tests that SRE's don't take time in the constructor, guessing they just get it from Robocode engine?)

So here's data I collected from successive ticks in my onScannedRobot:

IMPOSSIBLE: Enemy traveled 23.960320897363644
Round:      3
Ticks:      172 - 173
enemy 1: Point2D.Double[672.296759493604, 268.4670336402143]
enemy 2: Point2D.Double[670.937650031281, 292.3887768662851]
dista 1: 645.4602889259664
dista 2: 643.0225154806783
myloc 1: Point2D.Double[28.46985554539938, 314.3571451334465]
myloc 2: Point2D.Double[28.067090293868013, 306.3672903067204]
heading 1: 3.1650118725284133
heading 2: 3.1919596027245163
bearing 1: -1.5230587899322943
bearing 2: -1.5994228013460932

And here's data for those ticks from the replay:

    <turn round="3" turn="172" ver="1">
      <robots>
        <robot id="0" vsName="ScanTester*" state="ACTIVE" energy="84.0" x="28.46985554539938"
               y="314.3571451334465" bodyHeading="3.1650118725284133" gunHeading="1.6650151674145717"
               radarHeading="1.78588401972672" gunHeat="1.1999999999999997" velocity="8.0"
               teamName="voidious.ScanTester*" name="voidious.ScanTester*" sName="ScanTester*" ver="2">
          <debugProperties/>
          <score name="voidious.ScanTester*" totalScore="116.0" ...<snipped>.../>
        </robot>
        <robot id="1" vsName="Phoenix 1.02" state="ACTIVE" energy="70.10000000000005"
               x="671.8062575598343" y="284.43607160572503" bodyHeading="3.0567611234507766"
               gunHeading="4.4695696509271885" radarHeading="4.843960979524177" gunHeat="0.0"
               velocity="-8.0" teamName="davidalves.Phoenix 1.02" name="davidalves.Phoenix 1.02"
               sName="Phoenix 1.02" bodyColor="FF404040" gunColor="FF404040"
               radarColor="FF00FFFF" ver="2">
          <debugProperties/>
          <score name="davidalves.Phoenix 1.02" totalScore="284.74" ...<snipped>.../>
        </robot>
      </robots>
      <bullets>...<snipped>...</bullets>
    </turn>
    <turn round="3" turn="173" ver="1">
      <robots>
        <robot id="0" vsName="ScanTester*" state="ACTIVE" energy="84.0" x="28.067090293868013"
               y="306.3672903067204" bodyHeading="3.1919596027245163"
               gunHeading="1.641953082596119" radarHeading="1.498022145465518"
               gunHeat="1.0999999999999996" velocity="8.0" teamName="voidious.ScanTester*"
               name="voidious.ScanTester*" sName="ScanTester*" ver="2">
          <debugProperties/>
          <score name="voidious.ScanTester*" totalScore="116.0"...<snipped>.../>
        </robot>
        <robot id="1" vsName="Phoenix 1.02" state="ACTIVE" energy="68.11000000000006"
               x="670.937650031281" y="292.3887768662851" bodyHeading="3.0328022439880638"
               gunHeading="4.449386601269055" radarHeading="4.698449464559538" gunHeat="1.298"
               velocity="-8.0" teamName="davidalves.Phoenix 1.02" name="davidalves.Phoenix 1.02"
               sName="Phoenix 1.02" bodyColor="FF404040" gunColor="FF404040"
               radarColor="FF00FFFF" ver="2">
          <debugProperties/>
          <score name="davidalves.Phoenix 1.02" totalScore="284.74"...<snipped>.../>
        </robot>
      </robots>
      <bullets>...<snipped>...</bullets>
    </turn>

So my location and heading is right for both ticks, enemy location on the latter tick is right, but wrong for the previous tick. The e.getDistance() is in the same ballpark, but the bearing has to be way off to have projected a point 24 distance away from the next tick. (Didn't actually do the math...)

This definitely only happens at high speeds / loads. This is a modified Jen and I couldn't get it to happen vs Raiko until I added a few hundred thousand sqrt operations into the run loop. It happened against Phoenix without any such hacks. Both only when minimized.

Voidious18:52, 2 June 2012
 

Hmm, I've tried to reproduce this but it never seems to occur unless a turn was skipped.

Rednaxela06:02, 3 June 2012