コード例 #1
0
ファイル: SSC2.cpp プロジェクト: jeremiahishere/robocup
SSC2::SSC2(int numX, int numY, SoccerTeam2* team):m_pTeam(team)
{
    m_pBestSupportingSpot = NULL;
    const Region* PlayingField = team->Pitch()->PlayingArea();

    //calculate the positions of each sweet spot, create them and
    //store them in m_Spots
    double HeightOfSSRegion = PlayingField->Height() * 0.8;
    double WidthOfSSRegion  = PlayingField->Width() * 0.9;
    double SliceX = WidthOfSSRegion / numX ;
    double SliceY = HeightOfSSRegion / numY;

    double left  = PlayingField->Left() + (PlayingField->Width()-WidthOfSSRegion)/2.0 + SliceX/2.0;
    double right = PlayingField->Right() - (PlayingField->Width()-WidthOfSSRegion)/2.0 - SliceX/2.0;
    double top   = PlayingField->Top() + (PlayingField->Height()-HeightOfSSRegion)/2.0 + SliceY/2.0;

    for (int x=0; x<(numX/2)-1; ++x)
    {
        for (int y=0; y<numY; ++y)
        {
            if (m_pTeam->Color() == SoccerTeam::blue)
            {
                m_Spots.push_back(SupportSpot(Vector2D(left+x*SliceX, top+y*SliceY), 0.0));
            }

            else
            {
                m_Spots.push_back(SupportSpot(Vector2D(right-x*SliceX, top+y*SliceY), 0.0));
            }
        }
    }

    //create the regulator
    m_pRegulator = new Regulator(Prm.SupportSpotUpdateFreq);
}
コード例 #2
0
void SupportSpotCalculator::onInitialize() 
{
	mCoolingTime = addComponent(new CoolingTimeComponent(Prm.SupportSpotUpdateCoolTime, getName() + "CoolTime"));

	mSpots.clear();

	// Initialize support spots' positions
	float pitch_width = mTeam->getPitch()->getPlayingArea()->getWidth();
	float pitch_height = mTeam->getPitch()->getPlayingArea()->getHeight();
	float scale = 0.7;
	float px = pitch_width * 0.6 * (1 - scale) / 2;
	float py = pitch_height * (1 - scale) / 2;
	float dx = (pitch_width * 0.52 - px * 2) / (Prm.NumSupportSpotX - 1);
	float dy = (pitch_height - py * 2) / (Prm.NumSupportSpotY - 1);

	float left = mTeam->getPitch()->getPlayingArea()->getLeft();
	float right = mTeam->getPitch()->getPlayingArea()->getRight();
	float top = mTeam->getPitch()->getPlayingArea()->getTop();
	Ogre::SceneNode* scene_node = mTeam->getPitch()->getSceneNode();

	for (int i = 0; i < Prm.NumSupportSpotX; ++i)
	{
		for (int j = 0; j < Prm.NumSupportSpotY; ++j)
		{
			if (mTeam->getTeamColor() == Team::BLUE)
			{
				mSpots.push_back(SupportSpot(Ogre::Vector3(left + px + i * dx, 0, top + py + j * dy), 0.f));
				mSpots.back().drawer = std::shared_ptr<CircleDrawer>(new CircleDrawer(
					"Blue" + dt::Utils::toString(i * Prm.NumSupportSpotX + j), scene_node, 0.08f, "PlayerFlagBlue"));
				mSpots.back().drawer->setPos(mSpots.back().position);
			}
			else 
			{
				mSpots.push_back(SupportSpot(Ogre::Vector3(right - px - i * dx, 0, top + py + j * dy), 0.f));
				mSpots.back().drawer = std::shared_ptr<CircleDrawer>(new CircleDrawer(
					"Red" + dt::Utils::toString(i * Prm.NumSupportSpotX + j), scene_node, 0.08f, "PlayerFlagRed"));
				mSpots.back().drawer->setPos(mSpots.back().position);
			}
		}
	}

	mTotalScore = Prm.SpotCanShootScore + Prm.SpotPassSafeScore + Prm.SpotClosenessToSupportingPlayerScore + 
		Prm.SpotAheadOfAttackerScore + Prm.SpotDistFromCtrlPlayerScore;
}
コード例 #3
0
SupportSpotCalculator::SupportSpotCalculator(int numX, int numY, Team* team)
	:bestSupportSpot(NULL),
	team(team),
	frameCounter(0),
	noOfFramesBeforeUpdate(100)
{
	const PitchRegion* PlayingField = team->match->pitch->PitchArea();

	//calculate the positions of each sweet spot, create them and 
	//store them in m_Spots
	double HeightOfSSRegion = PlayingField->rect.h * 1;
	double WidthOfSSRegion  = PlayingField->rect.w * 0.5;
	double SliceX = WidthOfSSRegion / numX ;
	double SliceY = HeightOfSSRegion / numY;

	double left  = PlayingField->rect.x + (PlayingField->rect.w-WidthOfSSRegion)/2.0 + SliceX/2.0;
	double right = (PlayingField->rect.x + PlayingField->rect.w) - (PlayingField->rect.w-WidthOfSSRegion)/2.0 - SliceX/2.0;
	double top   = PlayingField->rect.y + (PlayingField->rect.h-HeightOfSSRegion)/2.0 + SliceY/2.0;
	double bottom = (PlayingField->rect.y + PlayingField->rect.h) - (PlayingField->rect.h - HeightOfSSRegion) / 2.0 - SliceY/2.0;

	for (int y=0; y< (numY / 2) -1; ++y)
	{
		for (int x=0; x< numX; ++x)
		{
			if (team->Home())
			{
				spots.push_back(SupportSpot(b2Vec2(left + x * SliceX, top + y * SliceY), 0.0));
			}

			else
			{
				spots.push_back(SupportSpot(b2Vec2(left + x * SliceX, bottom - y * SliceY), 0.0));
			}
		}
	}

	color = b2Color(1, 0, 0);
}