本文整理汇总了C++中WorldModel::theirPlayers方法的典型用法代码示例。如果您正苦于以下问题:C++ WorldModel::theirPlayers方法的具体用法?C++ WorldModel::theirPlayers怎么用?C++ WorldModel::theirPlayers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldModel
的用法示例。
在下文中一共展示了WorldModel::theirPlayers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pos
/*!
*/
void
CrossGenerator::updateOpponents( const WorldModel & wm )
{
const double opponent_dist_thr2 = std::pow( 20.0, 2 );
const Vector2D goal = ServerParam::i().theirTeamGoalPos();
const AngleDeg goal_angle_from_ball = ( goal - M_first_point ).th();
for ( AbstractPlayerCont::const_iterator
p = wm.theirPlayers().begin(),
end = wm.theirPlayers().end();
p != end;
++p )
{
AngleDeg opponent_angle_from_ball = ( (*p)->pos() - M_first_point ).th();
if ( ( opponent_angle_from_ball - goal_angle_from_ball ).abs() > 90.0 )
{
continue;
}
if ( (*p)->pos().dist2( M_first_point ) > opponent_dist_thr2 )
{
continue;
}
M_opponents.push_back( *p );
#ifdef DEBUG_PRINT
dlog.addText( Logger::PASS,
"Cross opponent %d pos(%.1f %.1f)",
(*p)->unum(),
(*p)->pos().x, (*p)->pos().y );
#endif
}
}
示例2: ball_ray
/*!
*/
int
TackleGenerator::predictOpponentsReachStep( const WorldModel & wm,
const Vector2D & first_ball_pos,
const Vector2D & first_ball_vel,
const AngleDeg & ball_move_angle )
{
int first_min_step = 50;
#if 1
const ServerParam & SP = ServerParam::i();
const Vector2D ball_end_point = inertia_final_point( first_ball_pos,
first_ball_vel,
SP.ballDecay() );
if ( ball_end_point.absX() > SP.pitchHalfLength()
|| ball_end_point.absY() > SP.pitchHalfWidth() )
{
Rect2D pitch = Rect2D::from_center( 0.0, 0.0, SP.pitchLength(), SP.pitchWidth() );
Ray2D ball_ray( first_ball_pos, ball_move_angle );
Vector2D sol1, sol2;
int n_sol = pitch.intersection( ball_ray, &sol1, &sol2 );
if ( n_sol == 1 )
{
first_min_step = SP.ballMoveStep( first_ball_vel.r(), first_ball_pos.dist( sol1 ) );
#ifdef DEBUG_PRINT
dlog.addText( Logger::CLEAR,
"(predictOpponent) ball will be out. step=%d reach_point=(%.2f %.2f)",
first_min_step,
sol1.x, sol1.y );
#endif
}
}
#endif
int min_step = first_min_step;
for ( AbstractPlayerCont::const_iterator
o = wm.theirPlayers().begin(),
end = wm.theirPlayers().end();
o != end;
++o )
{
int step = predictOpponentReachStep( *o,
first_ball_pos,
first_ball_vel,
ball_move_angle,
min_step );
if ( step < min_step )
{
min_step = step;
}
}
return ( min_step == first_min_step
? 1000
: min_step );
}