Britbot
static bool Britbot.Navigator.IsReachable ( Location  group,
Location  target,
HeadingVector  targetHeading 
) [inline, static]

This method calculates if you would be able to reach an enemy group or it would run away.

Parameters:
groupyour location
targetEnemy group location
targetHeadingEnemy direction
Returns:
true if it is possible to reach, else otherwise

Definition at line 211 of file Navigator.cs.

        {
            //if the target is stationary then return true
            if (targetHeading.Norm() == 0)
                return true;
            //first check if it is running away (its direction is about the same as the difference between you
            if (HeadingVector.CalcDifference(group, target) * targetHeading > 0)
                return false;


            //----------------------calculation of naive maximum intersection----------------------
            HeadingVector diffVector = HeadingVector.CalcDifference(target, group);

            double cosAlpha = diffVector.Normalize() * targetHeading.Normalize();
            double sacleCoeff = diffVector.Norm() * cosAlpha;

            Location maxIntersection = HeadingVector.AddvanceByVector(target, sacleCoeff * targetHeading.Normalize());
            //----------------------------------------------------------------------------------------

            //to account for numeric mistakes we take antitolerance coefficient
            const int antiToleranceCoeff = 2;

            //compare distances
            //check who is closer
            if (Bot.Game.Distance(group, maxIntersection) <
                Bot.Game.Distance(target, maxIntersection) - antiToleranceCoeff)
                return true;

            return false;
        }