本文整理汇总了C++中PlayerState::IsKickable方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerState::IsKickable方法的具体用法?C++ PlayerState::IsKickable怎么用?C++ PlayerState::IsKickable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerState
的用法示例。
在下文中一共展示了PlayerState::IsKickable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
//.........这里部分代码省略.........
isPositioned = true;
}
if(mpAgent->GetSelfUnum() == 7){
Vector player_pos = Vector(-15.0, -15.0);
mpAgent->Move(player_pos);
isPositioned = true;
}
if(mpAgent->GetSelfUnum() == 8){
Vector player_pos = Vector(-15.0, 15.0);
mpAgent->Move(player_pos);
isPositioned = true;
}
if(mpAgent->GetSelfUnum() == 9){
Vector player_pos = Vector(0.0, -20.0);
mpAgent->Move(player_pos);
isPositioned = true;
}
if(mpAgent->GetSelfUnum() == 10){
Vector player_pos = Vector(0.0, 1.0);
mpAgent->Move(player_pos);
isPositioned = true;
}
if(mpAgent->GetSelfUnum() == 11){
Vector player_pos = Vector(0.0, 20.0);
mpAgent->Move(player_pos);
isPositioned = true;
}
std::cout << "Positioned" << std::endl;
}
}
else {
if(mpAgent->GetFollowBall()){
if(mpCurrentPlayerState.IsKickable()){
std::cout<<"player "<< mpAgent->GetSelfUnum()<<" - ball kickable"<<std::endl;
Vector nearestHole = RoundToNearestHole(myPosition);
if(PassPlayersAvailable()){
std::cout <<"--------------------------------------------------------"<<std::endl;
std::cout<<"player "<< mpAgent->GetSelfUnum()<<" - pass players available"<<std::endl;
if(PassToBestPlayer())
mpAgent->SetFollowBall(false);
}
else{
std::cout<<"player "<< mpAgent->GetSelfUnum()<<" - holding ball"<<std::endl;
ActiveBehavior beh = ActiveBehavior(*mpAgent, BT_Hold);
if (beh.GetType() != BT_None) {
mpAgent->SetActiveBehaviorInAct(beh.GetType());
if(beh.Execute());
//mpAgent->SetFollowBall(false);
//std::cout<<"Holding ball."<<std::endl;
}
}
}
else
Dasher::instance().GetBall(*mpAgent, -1, true, false);
//std::cout<<"Player "<<mpAgent->GetSelfUnum() <<" following ball"<<std::endl;
//std::cout<<mpAgent->RecvdMsg<<std::endl;
//mpIntransit = true;
//mpTarget = ballpos;
//mpAgent->SetFollowBall(false);
}
/*
if(mpAgent->GetFollowBall()){
mpIntransit = true;
mpTarget = ballpos;
示例2: Plan
void BehaviorPassPlanner::Plan(std::list<ActiveBehavior> & behavior_list)
{
std::cout<<"Inside pass plan"<<std::endl;
if (!mSelfState.IsKickable()) return;
const std::vector<Unum> & tm2ball = mPositionInfo.GetCloseTeammateToTeammate(mSelfState.GetUnum());
Unum _opp = mStrategy.GetFastestOpp();
if (!_opp) return;
PlayerState oppState = mWorldState.GetOpponent( _opp );
bool oppClose = oppState.IsKickable()|| oppState.GetTackleProb(true) > 0.65 ;
for (uint i = 0; i < tm2ball.size(); ++i) {
ActiveBehavior pass(mAgent, BT_Pass);
pass.mTarget = mWorldState.GetTeammate(tm2ball[i]).GetPredictedPos();
if(mWorldState.GetTeammate(tm2ball[i]).IsGoalie()){
continue;
}
Vector rel_target = pass.mTarget - mBallState.GetPos();
const std::vector<Unum> & opp2tm = mPositionInfo.GetCloseOpponentToTeammate(tm2ball[i]);
AngleDeg min_differ = HUGE_VALUE;
for (uint j = 0; j < opp2tm.size(); ++j) {
Vector rel_pos = mWorldState.GetOpponent(opp2tm[j]).GetPos() - mBallState.GetPos();
if (rel_pos.Mod() > rel_target.Mod() + 3.0) continue;
AngleDeg differ = GetAngleDegDiffer(rel_target.Dir(), rel_pos.Dir());
if (differ < min_differ) {
min_differ = differ;
}
}
if (min_differ < 10.0) continue;
pass.mEvaluation = Evaluation::instance().EvaluatePosition(pass.mTarget, true);
pass.mAngle = (pass.mTarget - mSelfState.GetPos()).Dir();
pass.mKickSpeed = ServerParam::instance().GetBallSpeed(5, pass.mTarget.Dist(mBallState.GetPos()));
pass.mKickSpeed = MinMax(2.0, pass.mKickSpeed, Kicker::instance().GetMaxSpeed(mAgent , pass.mAngle ,3 ));
if(oppClose){//in oppnent control, clear it
pass.mDetailType = BDT_Pass_Clear;
}
else pass.mDetailType = BDT_Pass_Direct;
mActiveBehaviorList.push_back(pass);
}
if (!mActiveBehaviorList.empty()) {
mActiveBehaviorList.sort(std::greater<ActiveBehavior>());
if(mActiveBehaviorList.front().mDetailType == BDT_Pass_Clear){
mActiveBehaviorList.front().mEvaluation = 1.0 + FLOAT_EPS;
}
behavior_list.push_back(mActiveBehaviorList.front());
}
else { //如果此周期没有好的动作
if (mAgent.IsLastActiveBehaviorInActOf(BT_Pass)) {
ActiveBehavior pass(mAgent, BT_Pass, BDT_Pass_Direct);
pass.mTarget = mAgent.GetLastActiveBehaviorInAct()->mTarget; //行为保持
pass.mEvaluation = Evaluation::instance().EvaluatePosition(pass.mTarget, true);
pass.mKickSpeed = ServerParam::instance().GetBallSpeed(5 + random() % 6, pass.mTarget.Dist(mBallState.GetPos()));
pass.mKickSpeed = MinMax(2.0, pass.mKickSpeed, ServerParam::instance().ballSpeedMax());
behavior_list.push_back(pass);
}
if(oppClose){
Vector p;
BallState SimBall = mBallState;
int MinTmInter = HUGE_VALUE, MinOppInter = HUGE_VALUE, MinTm;
Vector MinTmPos;
for(AngleDeg dir = -45 ; dir <= 45 ; dir += 2.5){
if(!Tackler::instance().CanTackleToDir(mAgent,dir)){
SimBall.UpdateVel(Polar2Vector(Kicker::instance().GetMaxSpeed(mAgent,mSelfState.GetBodyDir() + dir,1),mSelfState.GetBodyDir() + dir),0,1.0);
}
else
SimBall.UpdateVel(Polar2Vector(Max(Tackler::instance().GetBallVelAfterTackle(mAgent,dir).Mod(), Kicker::instance().GetMaxSpeed(mAgent,mSelfState.GetBodyDir() + dir,1)),mSelfState.GetBodyDir() + dir),0,1.0);
for(int i = 2 ; i <= 11 ; i ++){
if(fabs((mWorldState.GetTeammate(i).GetPos() - mSelfState.GetPos()).Dir() - dir) > 45 ){
continue;
}
if(!mWorldState.GetPlayer(i).IsAlive()){continue;}
PlayerInterceptInfo* a = mInterceptInfo.GetPlayerInterceptInfo(i);
mInterceptInfo.CalcTightInterception(SimBall,a,true);
if(MinTmInter > (*a).mMinCycle){
MinTm= i;
MinTmInter = (*a).mMinCycle;
MinTmPos = (*a).mInterPos;
}
}
for(int i = 1 ; i <= 11 ; i++){
if(fabs((mWorldState.GetOpponent(i).GetPos() - mSelfState.GetPos()).Dir() - dir) > 45 ){
continue;
}
PlayerInterceptInfo* a = mInterceptInfo.GetPlayerInterceptInfo(-i);
mInterceptInfo.CalcTightInterception(SimBall,a,true);
if(MinOppInter > (*a).mMinCycle){
MinOppInter = (*a).mMinCycle;
}
}
if(MinOppInter > MinTmInter){
Ray a(mSelfState.GetPos() , mSelfState.GetBodyDir() + dir);
//.........这里部分代码省略.........