SetTurnGunRightRadians(Math.sin(targetBearing - getGunHeadingRadians() + Math.asin((vel * 0.4D + e.getVelocity() * 0.6D) / 14.0D * Math.sin(e.getHeadingRadians() - targetBearing)))) Refactored: double targetBearing = e.getBearingRadians() + getHeadingRadians() Since e.getBearingRadians() returns the target's bearing relative to your heading, var is the absolute target's bearing. Looks like var is being used to hold the result of the subexpression e.getBearingRadians() + getHeadingRadians(). ( EDIT: I've been out of robocode too long obfuscated-looking messes are likely the result of hand-optimizing for code size.) Let's try to unpick that one messy line, starting here: setTurnGunRightRadians(Math.sin((Guppy.var = e.getBearingRadians() + getHeadingRadians()) - getGunHeadingRadians() + Math.asin((vel * 0.4D + e.getVelocity() * 0.6D) / 14.0D * Math.sin(e.getHeadingRadians() - var)))) Painful style, too, assigning a variable and then using it within the same expression and randomly reusing static variables for different purposes. Of note to those familiar with trigonometry but not Robocode: Robocode's angular values are nonnegative and increase clockwise, rather than zero-centered and increasing counterclockwise as in trigonometric convention.
0 Comments
Leave a Reply. |