当前位置: 首页>>代码示例>>C++>>正文


C++ Agent::GetWorldState方法代码示例

本文整理汇总了C++中Agent::GetWorldState方法的典型用法代码示例。如果您正苦于以下问题:C++ Agent::GetWorldState方法的具体用法?C++ Agent::GetWorldState怎么用?C++ Agent::GetWorldState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Agent的用法示例。


在下文中一共展示了Agent::GetWorldState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: mWorldState

BehaviorAttackData::BehaviorAttackData(Agent & agent):
	mAgent ( agent ),
    mWorldState ( agent.GetWorldState() ),
    mBallState ( agent.GetWorldState().GetBall() ),
	mSelfState ( agent.Self() ),
	mPositionInfo ( agent.Info().GetPositionInfo()),
	mInterceptInfo ( agent.Info().GetInterceptInfo()),
	mStrategy (agent.GetStrategy()),
    mFormation ( agent.GetFormation() )
{
	mFormation.Update(Formation::Offensive, "Offensive");
}
开发者ID:antiphoton,项目名称:wrighteaglebase,代码行数:12,代码来源:BehaviorBase.cpp

示例2: UpdateTackleData

/**
 * Update data used by tackle.
 * \param agent.
 */
void Tackler::UpdateTackleData(const Agent & agent)
{
    if (mAgentID == agent.GetAgentID())  {
        return; /** no need to update */
    }

    mAgentID = agent.GetAgentID();

    const BallState & ball_state     = agent.GetWorldState().GetBall();
    const PlayerState & player_state = agent.GetSelf();
    Vector ball_2_player = (ball_state.GetPos() - player_state.GetPos()).Rotate(-player_state.GetBodyDir());

    Vector ball_vel;
    mMaxTackleSpeed = -1.0;
    mDirMap.clear();

    const double max_tackle_power = ServerParam::instance().maxTacklePower();
    const double min_back_tackle_power = ServerParam::instance().maxBackTacklePower();

    double factor = 1.0 - 0.5 * (fabs(Deg2Rad(ball_2_player.Dir())) / M_PI);

    for (AngleDeg tackle_angle = -180.0 + FLOAT_EPS; tackle_angle <= 180.0 + FLOAT_EPS; tackle_angle += 1.0) {
    	Vector ball_vel(ball_state.GetVel());
        double eff_power = (min_back_tackle_power + ((max_tackle_power - min_back_tackle_power) * (1.0 - fabs(Deg2Rad(tackle_angle)) / M_PI))) * ServerParam::instance().tacklePowerRate();
        eff_power *= factor;
        ball_vel += Polar2Vector(eff_power, tackle_angle + player_state.GetBodyDir());
        ball_vel = ball_vel.SetLength(Min(ball_vel.Mod(), ServerParam::instance().ballSpeedMax()));

        int angle_idx = ang2idx(tackle_angle);
        int dir_idx = dir2idx(ball_vel.Dir());

        mTackleAngle[angle_idx] = tackle_angle;
        mBallVelAfterTackle[angle_idx] = ball_vel;
        mDirMap[dir_idx].push_back(std::make_pair(angle_idx, ang2idx(tackle_angle + 1.0)));

        if (ball_vel.Mod() > mMaxTackleSpeed){
            mMaxTackleSpeed = ball_vel.Mod();
        }

        if (ball_vel.Mod() * ServerParam::instance().ballDecay() < FLOAT_EPS) {
        	mCanTackleStopBall = true;
        	mTackleStopBallAngle = tackle_angle;
        }
    }
//
//
//    for (AngleDeg tackle_angle = -180.0 + 0.3; tackle_angle <= 180.0 + FLOAT_EPS; tackle_angle += 1.0) {
//    	Vector ball_vel = GetBallVelAfterTackle(agent, tackle_angle);
//    	AngleDeg tackle_angle2 = 0.0;
//    	GetTackleAngleToDir(agent, ball_vel.Dir(), & tackle_angle2);
//
//    	std::cout << tackle_angle << " " << tackle_angle2 << std::endl;
//    }
//
//    exit(0);
}
开发者ID:antiphoton,项目名称:wrighteaglebase,代码行数:60,代码来源:Tackler.cpp

示例3: GetBall

/**
* Caculate the get ball cycles and actions.
* @param agent the agent itself.
* @param act the atomic action to execute this cycle to get the ball.
* @param int_cycle the beginning cycle to do the action, while -1 means now.
* @param can_inverse true means allow runnning backwards to get the ball.
* @param turn_first true means the agent turn first to get the ball.
* @return a double to show the cycles needed and if it less than 0, that is to say impossible.
*/
double Dasher::GetBall(Agent & agent, AtomicAction & act, int int_cycle , bool can_inverse, bool turn_first)
{
	Assert(int_cycle == -1 || int_cycle >= 0);

	if (int_cycle == -1) {
		double min_diff = HUGE_VALUE;

		const int max_consider_cycle = Min(int(MobileState::Predictor::MAX_STEP), agent.GetStrategy().GetSureOppInterCycle() - 1);
		for (int i = 0; i <= max_consider_cycle; ++i) {
			Vector target = agent.GetWorldState().GetBall().GetPredictedPos(i);
			double my_cycle = RealCycleNeedToPoint(agent.GetSelf(), target, can_inverse);
			double diff = fabs(my_cycle - i + 1.0);

			if (diff < min_diff) {
				min_diff = diff;
				int_cycle = i;
			}
		}
	}

	if (int_cycle == -1) {
		int_cycle = Max(0, agent.GetStrategy().GetMyInterCycle());
	}
	//int_cycle = 1;
	//std::cout << "Max consider cycle " << int_cycle << std::endl;
	//std::cout << "Predicted Ball position " << agent.GetWorldState().GetBall().GetPredictedPos(int_cycle).X() << " " << agent.GetWorldState().GetBall().GetPredictedPos(int_cycle).Y() << std::endl;
	//std::cout << "Ball position " << agent.GetWorldState().GetBall().GetPos().X() <<  " " << agent.GetWorldState().GetBall().GetPos().Y() << std::endl;
	GoToPoint(
			agent,
			act,
			agent.GetWorldState().GetBall().GetPredictedPos(int_cycle),
			agent.GetSelf().GetKickableArea() - GETBALL_BUFFER,
			agent.GetSelf().CorrectDashPowerForStamina(ServerParam::instance().maxDashPower()),
			can_inverse,
			turn_first
	);

	return RealCycleNeedToPoint(agent.GetSelf(), agent.GetWorldState().GetBall().GetPredictedPos(int_cycle), can_inverse);
}
开发者ID:nehagarg,项目名称:projectCS6208,代码行数:48,代码来源:Dasher.cpp

示例4: mSelfState

ActionEffector::ActionEffector(Agent & agent):
	mAgent( agent ),
	mWorldState( agent.GetWorldState() ),
	mBallState( agent.GetWorldState().GetBall()),
    mSelfState( agent.GetSelf()),
	mTurn( agent ),
	mDash( agent ),
	mTurnNeck( agent ),
	mSay( agent ),
	mAttentionto( agent ),
	mKick( agent ),
	mTackle( agent ),
	mPointto( agent ),
	mCatch( agent ),
	mMove( agent ),
	mChangeView( agent ),
	mCompression( agent ),
	mSenseBody( agent ),
	mScore( agent ),
	mBye( agent ),
	mDone( agent ),
	mClang( agent ),
	mEar( agent ),
	mSynchSee( agent ),
	mChangePlayerType( agent ),
	mStart( agent ),
	mChangePlayMode( agent ),
	mMovePlayer( agent ),
	mMoveBall( agent ),
	mLook( agent ),
	mTeamNames( agent ),
	mRecover( agent ),
	mCheckBall( agent )
{
	mTurnCount          = 0;
	mDashCount          = 0;
	mTurnNeckCount      = 0;
	mSayCount           = 0;
	mAttentiontoCount   = 0;
	mKickCount          = 0;
	mTackleCount        = 0;
	mPointtoCount       = 0;
	mCatchCount         = 0;
	mMoveCount          = 0;
	mChangeViewCount    = 0;
	mCompressionCount   = 0;
	mSenseBodyCount     = 0;
	mScoreCount         = 0;
	mByeCount           = 0;
	mDoneCount          = 0;
	mClangCount         = 0;
	mEarCount           = 0;
	mSynchSeeCount      = 0;
	mChangePlayerTypeCount = 0;

	mIsMutex        = false;

	mIsTurn         = false;
	mIsDash         = false;
	mIsTurnNeck     = false;
	mIsSay          = false;
	mIsAttentionto  = false;
	mIsKick         = false;
	mIsTackle       = false;
	mIsPointto      = false;
	mIsCatch        = false;
	mIsMove         = false;
	mIsChangeView   = false;
	mIsCompression  = false;
	mIsSenseBody    = false;
	mIsScore        = false;
	mIsBye          = false;
	mIsDone         = false;
	mIsClang        = false;
	mIsEar          = false;
	mIsSynchSee     = false;
	mIsChangePlayerType = false;

	mIsSayMissed	= false;
    mLastCommandType = CT_None;
}
开发者ID:harshnisar,项目名称:WEFork,代码行数:81,代码来源:ActionEffector.cpp


注:本文中的Agent::GetWorldState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。