I'm trying to make a robot for robocode that always turns perpendicular when it sees a robot.
If you don't know what robocode is just imagine a top down game where direction is recorded in degrees
I've already made an equation that does what I want but it is very inefficient
(e.getHeading is the direction the target is facing, getHeading is the direction I'm facing note that also there is a method getBearing that shows angle relative to the enemy)
turnRight( (e.getHeading() + 90) - getHeading());
The problem though is that it will sometimes go the long way around rather than the shortest route. What better equation could I use to always turn the right way?