Robo Home | Jekyl | Changes | Preferences | AllPages

I am trying to determine the angle of my bot relative to the angle of the enemy bot. What I am trying to determine is if I am heading directly at my target or directly away. I have tried a couple of different thigns with no success and I now suspect that I have looked at it so long that I can not see the obvious. I beleive that it should simply be a comparison between Enemy Bearing and getHeadingRadians() (assuming all radians in the measurement). To orbit I set me bearing to enemy bearing + PI. Works like a champ. But when I try to take the difference of these two angles, in situations where I know I am pointed directly at the enemy I am meeting with little success. So I put the question out there. I need this for a new wall smoothing algorithm I am working on which tends to move too much pointing directly at my enemy. I would like to be able to detect this and adjust accordingly. Thanks.

To orbit you want turnRight(e.getBearing()+PI/2); to tell if you are facing the enemy you want abs(relativeAngle(e.getBearing()))<10, i think. That would return true if you are within 10 degrees (it will work just as well if you use radians) of facing the enemy. -- Tango

Tango is mixing up some radians and degrees there, but whatever. Don't forget to add PI to your heading if you are going backward. -- Kawigi

I was kind of using pseudocode, so yes, you need to sort out the radians, you need to use robocode.utils.Utils or whatever it is. Good luck. -- Tango

Robo Home | Jekyl | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited December 14, 2003 13:55 EST by Tango (diff)