Robo Home | Segmentation | Changes | Preferences | AllPages


When gathering data for a statistical operation, you will segment on one or more of these variables. Here are most of the variables that are segmented on, feel free to add variables and how to collect them to the list.



I have a question about the calculation of LateralVelocity and AdvancingVelocity. This page says to multiply the velocity by the sin and cos, respectively, of this angle:
(e.getHeadingRadians() - e.getBearingRadians() + getHeadingRadians())
But it seems to me it should be this:
(Math.PI - (e.getHeadingRadians() - (e.getBearingRadians() + getHeadingRadians()))
Let's take two example situations. The opponent is directly above me, and we're both facing up (zero radians). The first solution gives 0 (sin=0, cos=1), the second gives Pi (sin=0, cos=-1). Clearly they are both right for the LateralVelocity, but the first gives them a positive AdvancingVelocity while the second gives a negative. Second example: we're in the same positions, but now my heading is Pi/4 (45 degrees). The first equation now calculates to (0 - (-Pi/4) + Pi/4) = Pi/2 (sin=1, cos=0), while the second calculates to (Pi - (0 - (Pi/4 - Pi/4))) = Pi (sin=0, cos=-1); the same as it did in the first situation. I see no way they should be 100% lateral and 0% advancing in this situation.

The "Math.Pi - ..." thing could be dropped if positive advancing = moving away from you, but it sounds like the opposite of that. Could somebody please just confirm to me that my assessment is correct? I'm pretty new to Robocode, and I'm afraid I'm just misunderstanding something here... Thanks. -- Voidious

Take another look at AdvancingVelocity:

double advancingvelocity = -Math.cos(e.getHeadingRadians()-absbearing)*e.getVelocity();
Note you make Math.cos(angle) negative to get the AdvancingVelocity vector. Hope that helps. --Corbos

Yes, now I see that... Thanks. This means that I am looking at it correctly. It was still wrong on this page, though, as the last two pieces of the "angle" expression would need parens to be subtracing the absolute bearing. I'll go ahead and edit them here... -- Voidious

I believe I fixed the formula for relative heading, but I wouldn't mind somebody double checking it ;) (This page has been around a while...) -- Voidious

Robo Home | Segmentation | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited February 8, 2006 6:02 EST by Voidious (diff)