|
Britbot
|
Creates a gradiante of bad score around a specific location with a given radious.
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;
}
}
}
|
1.7.6.1