Britbot
static int Britbot.Navigator.ComparePirateByDirection ( int  p1,
int  p2,
HeadingVector  hv 
) [inline, static]

Given two pirates (id) it tells you who is "more" in a specific direction than the other.

Parameters:
p1first pirate
p2second pirate
hvthe direction we compare in
Returns:

Definition at line 185 of file Navigator.cs.

        {
            HeadingVector originDif = new HeadingVector(Bot.Game.GetMyPirate(p1).Loc.Col,
                Bot.Game.GetMyPirate(p1).Loc.Row);
            int coef;

            if (originDif * hv > 0)
                coef = 1;
            else
                coef = -1;
            //calculate both pirates position on the line created by hv
            double p1Dist = Navigator.CalcDistFromLine(new Location(0, 0), (Bot.Game.GetMyPirate(p1)).Loc,
                hv.Orthogonal());
            double p2Dist = Navigator.CalcDistFromLine(new Location(0, 0), (Bot.Game.GetMyPirate(p2)).Loc,
                hv.Orthogonal());

            return coef * p1Dist.CompareTo(p2Dist);
        }