weird bug I'm hitting
This is the thread's initial revision.
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);
}