Пример #1
0
bool GoalKeeper::BallWithinRangeForIntercept()const
{
	if(team->Home())
		return (DistanceSq(team->match->pitch->bottomGoal->GetPositionInPixels(), team->match->ball->GetPositionInPixels()) <=
		20000); // GoalKeeperInterceptRange
	else
		return (DistanceSq(team->match->pitch->topGoal->GetPositionInPixels(), team->match->ball->GetPositionInPixels()) <=
		20000); // GoalKeeperInterceptRange

}
Пример #2
0
float kexVec3::Distance(const kexVec3 &vec) const {
    return kexMath::Sqrt(DistanceSq(vec));
}
Пример #3
0
bool GoalKeeper::TooFarFromGoalMouth()const
{
	return (DistanceSq(GetPositionInPixels(), GetRearInterposeTarget()) >
		20000); // GoalKeeperInterceptRangeSq
}
Пример #4
0
bool SphereToBox(const VEC3 &SphereCenter, float SphereRadius, const BOX &Box)
{
	VEC3 PointInBox;
	ClosestPointInBox(&PointInBox, Box, SphereCenter);
	return DistanceSq(SphereCenter, PointInBox) < SphereRadius*SphereRadius;
}
//--------------------------- DetermineBestSupportingPosition -----------------
//
//  see header or book for description
//-----------------------------------------------------------------------------
b2Vec2 SupportSpotCalculator::DetermineBestSupportingPosition()
{
	//only update the spots every few frames                              

	frameCounter++;

	if((frameCounter < noOfFramesBeforeUpdate) && bestSupportSpot)
	{
		return bestSupportSpot->position;
	}

	frameCounter = 0; // reset the counter

	//reset the best supporting spot
	bestSupportSpot = NULL;

	double BestScoreSoFar = 0.0;

	std::vector<SupportSpot>::iterator curSpot;

	for (curSpot = spots.begin(); curSpot != spots.end(); ++curSpot)
	{
		//first remove any previous score. (the score is set to one so that
		//the viewer can see the positions of all the spots if he has the 
		//aids turned on)
		curSpot->score = 1.0;

		//Test 1. is it possible to make a safe pass from the ball's position 
		//to this position?
		if(team->isPassSafeFromAllOpponents(team->ControllingPlayer()->GetPositionInPixels(),
			curSpot->position,
			NULL,
			50)) //Prm.MaxPassingForce))
		{
			curSpot->score += 2.0; //Prm.Spot_PassSafeScore;
		}


		//Test 2. Determine if a goal can be scored from this position.  
		if( team->CanShoot(curSpot->position,            
			30)) //Prm.MaxPassingForce))
		{
			curSpot->score +=  1.0; //Prm.Spot_CanScoreFromPositionScore;
		}   


		//Test 3. calculate how far this spot is away from the controlling
		//player. The further away, the higher the score. Any distances further
		//away than OptimalDistance pixels do not receive a score.
		if (team->SupportingPlayer())
		{
			const double OptimalDistance = 40000.0;

			double dist = DistanceSq(team->ControllingPlayer()->GetPositionInPixels(),
				curSpot->position);

			double temp = fabs(OptimalDistance - dist);

			if (temp < OptimalDistance)
			{

				//normalize the distance and add it to the score
				curSpot->score += 2.0 * //Prm.Spot_DistFromControllingPlayerScore *
					(OptimalDistance-temp)/OptimalDistance;  
			}
		}

		//check to see if this spot has the highest score so far
		if (curSpot->score > BestScoreSoFar)
		{
			BestScoreSoFar = curSpot->score;

			bestSupportSpot = &(*curSpot);
		}    

	}

	return bestSupportSpot->position;
}