Thread history

From Talk:Gilgalad/movementStrategy
Viewing a history listing
Jump to navigation Jump to search
Time User Activity Comment
20:45, 9 January 2013 MN (talk | contribs) New reply created (Reply to Bug with pathing)
20:27, 9 January 2013 Voidious (talk | contribs) New reply created (Reply to Bug with pathing)
19:39, 9 January 2013 AW (talk | contribs) New reply created (Reply to Bug with pathing)
18:36, 8 January 2013 AW (talk | contribs) New thread created  

Bug with pathing

So, I have found a bug with Gilgalad's pathing where the path's coordinate is occasionally about 0.002 units from the correct coordinate. This is seems to happen only when switching from positive to negative velocity, but I think I handle the current rule for that correctly:

			if (moveDir != Math.signum(currentVelocity)) {
				if (currentVelocity > 2.0) {
					currentVelocity -= 2.0;
				} else if (currentVelocity < -2.0) {
					currentVelocity += 2.0;
				} else {
					currentVelocity = moveDir
							* (1.0 - Math.abs(currentVelocity) * 0.5);
				}
			}


On oddity I noticed is that I will have -0.0 for my velocity when moving from 2.0 to 0.0, but I don't think that would cause problems. Perhaps my trig function is not exactly the same as that used by robocode and that causes the difference?

Thanks for any help.

AW18:36, 8 January 2013

Well, the problem seems to occur more when the angle is near a multiple of PI. Any interesting quirks with sin() or cos() near those angles?

AW19:39, 9 January 2013

There are quirks with fast math classes.

MN20:45, 9 January 2013
 

I did look at your code but couldn't figure anything to cause a small discrepancy. One thing to consider is a rounding error from the "1.0 - x" or the "x * 0.5", but that would be a much, much smaller error than .002.

You should be able to deduce whether it's the angle or the distance that's off. Like if it's 0.002 off along the same heading, it's the distance, while if the new and predicted points are the same distance from the previous point, it's the heading. Right?

Voidious20:27, 9 January 2013