本文整理汇总了C++中WorldModel::ourSide方法的典型用法代码示例。如果您正苦于以下问题:C++ WorldModel::ourSide方法的具体用法?C++ WorldModel::ourSide怎么用?C++ WorldModel::ourSide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldModel
的用法示例。
在下文中一共展示了WorldModel::ourSide方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: direction
/*!
*/
void
DebugClient::toStr( const WorldModel & world,
const ActionEffector & effector )
{
std::ostringstream ostr;
ostr << "((debug (format-version 3)) (time "
<< world.time().cycle() << ")";
// self
/*
SELF ::= (s SIDE PLAYER_NUMBER POS_X POS_Y VEL_X VEL_Y
BODY_DIRECTION FACE_DIRECTION [(c "COMMENT")])
where SIDE is 'l' or 'r'.
where PLAYER_NUMBER is 1 to 11.
where POS_X and POS_Y is absolute coordinate.
where VEL_X and VEL_Y is absolute velocity.
where BODY_DIRECTION is absolute player body direction (degree).
where NECK_DIRECTION is body relative face direction (degree).
This is equals to (absolute_face_direction - BODY_DIRECTION).
where COMMENT is a string.
Typically, it is used as information accuracy.
*/
if ( world.self().posValid() )
{
ostr << " (s "
<< ( world.ourSide() == LEFT ? "l " : "r " )
<< world.self().unum() << ' '
<< ROUND(world.self().pos().x, 0.01) << ' '
<< ROUND(world.self().pos().y, 0.01) << ' '
<< ROUND(world.self().vel().x, 0.01) << ' '
<< ROUND(world.self().vel().y, 0.01) << ' '
<< ROUND(world.self().body().degree(), 0.1) << ' '
<< ROUND(world.self().neck().degree(), 0.1) << " (c \""
<< world.self().posCount() << ' '
//<< '(' << ROUND(world.self().posError().x, 0.001)
//<< ", " << ROUND(world.self().posError().y, 0.001) << ") "
<< world.self().velCount() << ' '
<< world.self().faceCount();
if ( world.self().card() == YELLOW ) ostr << "y";
ostr << "\"))";
}
// ball
/*
BALL_INFO ::= (b POS_X POS_Y [VEL_X VEL_Y] [(c "COMMENT")])
*/
if ( world.ball().posValid() )
{
ostr << " (b "
<< ROUND(world.ball().pos().x, 0.01) << ' '
<< ROUND(world.ball().pos().y, 0.01);
if ( world.ball().velValid() )
{
ostr << ' ' << ROUND(world.ball().vel().x, 0.01)
<< ' ' << ROUND(world.ball().vel().y, 0.01);
}
ostr << " (c \"g" << world.ball().posCount()
<< 'r' << world.ball().rposCount()
//<< "(" << ROUND(world.ball().rpos().x, 0.01)
// << ", " << ROUND(world.ball().rpos().y, 0.01) << ')'
<< 'v' << world.ball().velCount()
//<< "(" << ROUND(world.ball().vel().x, 0.01)
// << ", " << ROUND(world.ball().vel().y, 0.01) << ')'
<< "\"))";
}
// players
/*
PLAYER_INFO ::= (TEAM [PLAYER_NUMBER] POS_X POS_Y
[(bd BODY_DIRECTION)] [(c "COMMENT")])
TEAM is one of follows.
't' (teammate), 'o' (opponent),
'u' (unknown), 'ut' (unknown teammate), 'ut' (unknown opponent).
When TEAM is 't' or 'o', PLAYER_NUMBER must be specified.
Otherwise PLAYER_NUMBER must not be specified.
Body direction and comment is optional.
*/
std::for_each( world.teammates().begin(),
world.teammates().end(),
PlayerPrinter( ostr, 't' ) );
std::for_each( world.opponents().begin(),
world.opponents().end(),
PlayerPrinter( ostr, 'o' ) );
std::for_each( world.unknownPlayers().begin(),
world.unknownPlayers().end(),
PlayerPrinter( ostr, 'u' ) );
// say message
if ( ! effector.getSayMessage().empty() )
{
ostr << " (say \"";
for ( std::vector< const SayMessage * >::const_iterator it = effector.sayMessageCont().begin();
//.........这里部分代码省略.........
示例2:
/*!
*/
double
Neck_ScanPlayers::calculate_score( const WorldModel & wm,
const Vector2D & next_self_pos,
const AngleDeg & left_angle,
const AngleDeg & right_angle )
{
double score = 0.0;
double view_buffer = 90.0;
const int our_min = std::min( wm.interceptTable()->selfReachCycle(),
wm.interceptTable()->teammateReachCycle() );
const int opp_min = wm.interceptTable()->opponentReachCycle();
const bool our_ball = ( our_min <= opp_min );
const AbstractPlayerCont::const_iterator end = wm.allPlayers().end();
for ( AbstractPlayerCont::const_iterator p = wm.allPlayers().begin();
p != end;
++p )
{
if ( (*p)->isSelf() ) continue;
Vector2D pos = (*p)->pos() + (*p)->vel();
AngleDeg angle = ( pos - next_self_pos ).th();
if ( ! angle.isRightOf( left_angle )
|| ! angle.isLeftOf( right_angle ) )
{
continue;
}
double pos_count = (*p)->seenPosCount();
if ( (*p)->isGhost()
&& (*p)->ghostCount() % 2 == 1 )
{
pos_count = std::min( 2.0, pos_count );
}
pos_count += 1.0;
if ( our_ball )
{
if ( (*p)->side() == wm.ourSide()
&& ( (*p)->pos().x > wm.ball().pos().x - 10.0
|| (*p)->pos().x > 30.0 ) )
{
pos_count *= 2.0;
}
}
double base_val = std::pow( pos_count, 2 );
double rate = std::exp( - std::pow( (*p)->distFromSelf(), 2 )
/ ( 2.0 * std::pow( 20.0, 2 ) ) ); // Magic Number
score += base_val * rate;
double buf = std::min( ( angle - left_angle ).abs(),
( angle - right_angle ).abs() );
#ifdef DEBUG_PRINT
dlog.addText( Logger::ACTION,
"__ %c_%d (%.2f %.2f) count=%d base=%f rate=%f +%f buf=%.1f",
(*p)->side() == LEFT ? 'L' : (*p)->side() == RIGHT ? 'R' : 'N',
(*p)->unum(),
(*p)->pos().x, (*p)->pos().y,
(*p)->posCount(),
base_val, rate, base_val * rate,
buf );
#endif
if ( buf < view_buffer )
{
view_buffer = buf;
}
}
// The bigger view buffer, the bigger rate
// range: [1.0:2.0]
// double rate = 2.0 - std::exp( - std::pow( view_buffer, 2 )
// / ( 2.0 * std::pow( 180.0, 2 ) ) ); // Magic Number
double rate = 1.0 + view_buffer / 90.0;
#ifdef DEBUG_PRINT
dlog.addText( Logger::ACTION,
"base_score=%.1f view_buf=%.1f rate=%f -> %f",
score,
view_buffer,
rate,
score * rate );
#endif
score *= rate;
return score;
}
示例3: switch
/*!
*/
Formation::Ptr
Strategy::getFormation( const WorldModel & wm ) const
{
//
// play on
//
if ( wm.gameMode().type() == GameMode::PlayOn )
{
switch ( M_current_situation ) {
case Defense_Situation:
return M_defense_formation;
case Offense_Situation:
return M_offense_formation;
default:
break;
}
return M_normal_formation;
}
//
// kick in, corner kick
//
if ( wm.gameMode().type() == GameMode::KickIn_
|| wm.gameMode().type() == GameMode::CornerKick_ )
{
if ( wm.ourSide() == wm.gameMode().side() )
{
// our kick-in or corner-kick
return M_kickin_our_formation;
}
else
{
return M_setplay_opp_formation;
}
}
//
// our indirect free kick
//
if ( ( wm.gameMode().type() == GameMode::BackPass_
&& wm.gameMode().side() == wm.theirSide() )
|| ( wm.gameMode().type() == GameMode::IndFreeKick_
&& wm.gameMode().side() == wm.ourSide() ) )
{
return M_indirect_freekick_our_formation;
}
//
// opponent indirect free kick
//
if ( ( wm.gameMode().type() == GameMode::BackPass_
&& wm.gameMode().side() == wm.ourSide() )
|| ( wm.gameMode().type() == GameMode::IndFreeKick_
&& wm.gameMode().side() == wm.theirSide() ) )
{
return M_indirect_freekick_opp_formation;
}
//
// after foul
//
if ( wm.gameMode().type() == GameMode::FoulCharge_
|| wm.gameMode().type() == GameMode::FoulPush_ )
{
if ( wm.gameMode().side() == wm.ourSide() )
{
//
// opponent (indirect) free kick
//
if ( wm.ball().pos().x < ServerParam::i().ourPenaltyAreaLineX() + 1.0
&& wm.ball().pos().absY() < ServerParam::i().penaltyAreaHalfWidth() + 1.0 )
{
return M_indirect_freekick_opp_formation;
}
else
{
return M_setplay_opp_formation;
}
}
else
{
//
// our (indirect) free kick
//
if ( wm.ball().pos().x > ServerParam::i().theirPenaltyAreaLineX()
&& wm.ball().pos().absY() < ServerParam::i().penaltyAreaHalfWidth() )
{
return M_indirect_freekick_our_formation;
}
else
{
return M_setplay_our_formation;
}
}
}
//
//.........这里部分代码省略.........