Britbot
static void Britbot.Navigator.Node.BlockLocation ( Location  loc,
double  radSquared,
HeadingVector  heading 
) [inline, static, private]

Creates a gradiante of bad score around a specific location with a given radious.

Parameters:
locthe location of the danger
radSquaredthe square of the danger radious
headingthe heading of the danger, to make the danger zone elipse like

Definition at line 166 of file Node.cs.

            {
                //---------------#Magic_Numbers--------------------
                //important constants:
                //this determines how much we consider the heading of the danger, meaning how elipsy the 
                //danger zone will be
                const double headingFactor = 0.25;

                //reading some important parameters
                int rad = (int) Math.Sqrt(radSquared);
                int maxX = Bot.Game.GetCols() - 1;
                int maxY = Bot.Game.GetRows() - 1;

                //going over a square centered at loc
                for (int x = Math.Max(loc.Col - rad, 0); x <= Math.Min(loc.Col + rad, maxX); x++)
                {
                    for (int y = Math.Max(loc.Row - rad, 0); y <= Math.Min(loc.Row + rad, maxY); y++)
                    {
                        //the current location
                        Location currLoc = new Location(y, x);

                        //blocking stuff according to their radious and direction
                        HeadingVector diffVector = HeadingVector.CalcDifference(loc, currLoc);

                        //calculate the distance considering the heading of the danger
                        //if the current location is straight in the direction of the danger we add by proportion to headingFactor
                        //if it is in the opposite direction we subtract according to headingFactor
                        double distandeSquare = Bot.Game.EuclidianDistanceSquared(new Location(y, x), loc) +
                                                headingFactor * heading.Normalize() * diffVector;
                        if (distandeSquare <= radSquared)
                            Node.Map[y, x].Weight += Node.Infinity * (radSquared - distandeSquare) / radSquared;
                    }
                }
            }