Talk:Advancing Velocity

From Robowiki
Jump to navigation Jump to search

Migrated from old wiki

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

Yup. You are entirely right. I get very few hits in the middle bucket the above way. In fact I get exactly what I asked for when thinking zero velocity would be the mid bucket. That's not very good... -- PEZ

There are no threads on this page yet.