( 5 ) newX(T) = relativeX + http://kcl.kwokkie.net/klli87/images/sum.gif enemyVelocity*sin(initialHeading + t*turnrate) ( 6 ) newY(T) = relativeY + http://kcl.kwokkie.net/klli87/images/sum.gif enemyVelocity*cos(initialHeading + t*turnrate) |

( 5 ) newX(T) = relativeX + http://kcl.kwokkie.net/klli87/images/_sum.gif enemyVelocity*sin(initialHeading + t*turnrate) ( 6 ) newY(T) = relativeY + http://kcl.kwokkie.net/klli87/images/_sum.gif enemyVelocity*cos(initialHeading + t*turnrate) |

( 7 ) newX(T) = relativeX + enemyVelocity * http://kcl.kwokkie.net/klli87/images/integral.gif sin(initialHeading + t*turnrate) dt ( 8 ) newY(T) = relativeY + enemyVelocity * http://kcl.kwokkie.net/klli87/images/integral.gif cos(initialHeading + t*turnrate) dt |

( 7 ) newX(T) = relativeX + enemyVelocity * http://kcl.kwokkie.net/klli87/images/_integral.gif sin(initialHeading + t*turnrate) dt ( 8 ) newY(T) = relativeY + enemyVelocity * http://kcl.kwokkie.net/klli87/images/_integral.gif cos(initialHeading + t*turnrate) dt |

--- The loop is only necessary to work out the time `t` when the bullet will hit the robot. If you can guess `t` beforehand, you can avoid the looping and just shoot at where the enemy will be at time `t` . A working estimate for `t` is the time it takes to shoot a bullet into the centre of the enemy's movement:double t = Math.sqrt(Math.pow(getX() - movementCentreX?, 2) + Math.pow(getY() - movementCentreY?, 2))/bulletSpeed; Plug this into equations (9) and (10) above and you have co-ordinates to shoot at. This might not give you the smallest possible value of `t` for a given bullet speed (I haven't checked, but the code seems to do rather poorly against sample.Corners), but it'll give you a value that works. The only way I know to get a smaller value of `t` will require iteration as you're essentially backing out roots from a trig function.Of course, it goes without saying that a delooped circular targeting gun will be useless against anything that doesn't move in great arcs. If you want to hit those robots, you're better off sticking with the iterative method. But since a delooped circular targeting gun runs in constant time, it can form part of a virtual guns system without causing you to skip turns on massive battlefields. --duyn |