The formula for calculating this is:
double advancingvelocity = -Math.cos(e.getHeadingRadians()-absbearing)*e.getVelocity();absbearing is the absolute bearing to your target. If you take off the negative sign, I suppose it would be the retreating velocity. --Kawigi
I tried using the sign of the advancing velocity in CassiusClay version 1.9.6.10. But I think maybe I did that segmentation the wrong way. This is the relevant code:
double approachVelocity = e.getVelocity() * -Math.cos(e.getHeadingRadians() - enemyBearing); wave.approachSignIndex = 1 + (approachVelocity == 0 ? 0 : PUtils.sign(approachVelocity));-- PEZ
This is how I calculate advancing velocity, so assuming enemyBearing above is the abs bearing then it's exactly the same.
double advancingvelocity = -Math.cos(firedAt.getValue(firedAt.heading, stepsBack)-PulsarMax.robotStats.getAbsBearingTo(firedAt, stepsBack))*firedAt.getValue(firedAt.velocity, stepsBack);Clearer:
double advancingvelocity = -Math.cos(enemyHeading-absBearingToEnemy)*enemyVelocity;But most of all I think comparing that double to 0 is way to restrictive. Have some margin instead perhaps? This is coming from somone with 50 less score of course though...
-- Pulsar
Yes, I always forget about the danger in comparing doubles to 0. But in this case it might hold since it's a true zero value in the velocity reading I want to check for. I'll test with some debug outputting now. Thanks! -- PEZ