Skip to content

Commit

Permalink
C++11/14 support (helios-base#18)
Browse files Browse the repository at this point in the history
* fix cmake configurations.

* replace CheckSymbolExists with CheckCXXSymbolExists

* fix a cmake problem. add a missing header file.

* デフォルトのインストール先を~/localへ変更

* formationファイルフォーマットv2のパーサを復帰 (helios-base#13)

* support a large value of synch_see_offset (helios-base#15)

* SeeState::canChangeViewToをcanSendChangeViewへリネーム.スタイルを一部修正.

* コード整理

* synch_see時の最大待ち時間を79msから30msへ変更

* TimeStampに<,>演算子を追加

* synch_see_offsetが大きい場合に部分的に対応。seeのタイミングを正確に判断するためにTimeStampを導入

Co-authored-by: Hidehisa Akiyama <[email protected]>

* replace some implementations with C++11/14  (helios-base#16)

* replace deprecated function adapters with lamda expressions

* 一部を範囲for文へ置き換え

* 一部を範囲for文、nullptrへ置換。

* 行動クラス群を範囲for文へ置換

* ann内の実装を範囲for文で置換

* clang内の実装を範囲for文で置換

* coach内の実装を範囲for文へ置換

* 範囲for文でiteratorを整理

* BallObjectの代入演算子を追加し、defaultとして定義

* boostのスマートポインタ、cstdintを標準へ置換

* boost::randomをstd::randomへ置換

* コンストラクタ・デストラクタのdefault,deleteを設定

* 自己位置推定の冗長コードを整理し、サンプリング動作を確認

* 一部のpush_backをemplace_backへ置き換え

* ヌルポインタとしての0キャストをnullptrへ置き換え

* 一部のstd::mapをstd::unordered_mapへ置き換え

* 一部のlexical_castを標準の変換関数へ置き換え

* 時間計測関係をstd::chronoで再実装

* TimeStamp::msecFromをelapsedSinceへリネーム

* 未使用のフォーメーションクラスをobsoleteへ移動

* 未使用コードを削除

* 一部の仮想メンバ関数にoverrideキーワードを追加

Co-authored-by: Hidehisa Akiyama <[email protected]>
  • Loading branch information
hidehisaakiyama and hidehisaakiyama authored Feb 28, 2022
1 parent 13de9c4 commit bf71940
Show file tree
Hide file tree
Showing 232 changed files with 4,786 additions and 6,035 deletions.
8 changes: 3 additions & 5 deletions rcsc/action/basic_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,16 @@ Neck_TurnToPoint::execute( PlayerAgent * agent )
const AngleDeg next_body = agent->effector().queuedNextSelfBody();
const double next_view_width = agent->effector().queuedNextViewWidth().width() * 0.5;

for ( std::vector< Vector2D >::const_iterator p = M_points.begin();
p != M_points.end();
++p )
for ( const Vector2D & p : M_points )
{
Vector2D rel_pos = *p - next_pos;
Vector2D rel_pos = p - next_pos;
AngleDeg rel_angle = rel_pos.th() - next_body;

if ( rel_angle.abs() < ServerParam::i().maxNeckAngle() + next_view_width - 5.0 )
{
dlog.addText( Logger::ACTION,
__FILE__": Neck_TurnToPoint (%.1f %.1f) rel_angle = %.1f",
p->x, p->y, rel_angle.degree() );
p.x, p.y, rel_angle.degree() );
return agent->doTurnNeck( rel_angle - agent->world().self().neck() );
}
}
Expand Down
10 changes: 5 additions & 5 deletions rcsc/action/bhv_scan_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bool
Bhv_ScanField::execute( PlayerAgent * agent )
{
dlog.addText( Logger::ACTION,
__FILE__": Bhf_ScanField" );
__FILE__": Bhv_ScanField" );

const WorldModel & wm = agent->world();

Expand Down Expand Up @@ -86,10 +86,10 @@ Bhv_ScanField::findBall( PlayerAgent * agent )
{
const WorldModel & wm = agent->world();

if ( wm.seeTime() != wm.time() )
if ( wm.seeTimeStamp() < wm.decisionTimeStamp() )
{
dlog.addText( Logger::ACTION,
__FILE__": (findBall) no current see info" );
__FILE__": (findBall) no see info after the previous decision" );
agent->doTurn( 0.0 );
agent->setNeckAction( new Neck_TurnToRelative( wm.self().neck() ) );
return;
Expand Down Expand Up @@ -143,10 +143,10 @@ Bhv_ScanField::scanAllField( PlayerAgent * agent )
{
const WorldModel & wm = agent->world();

if ( wm.seeTime() != wm.time() )
if ( wm.seeTimeStamp() < wm.decisionTimeStamp() )
{
dlog.addText( Logger::ACTION,
__FILE__":scanAllField) no current see info" );
__FILE__":scanAllField) no see info after the previous decision" );
agent->doTurn( 0.0 );
agent->setNeckAction( new Neck_TurnToRelative( wm.self().neck() ) );
return;
Expand Down
14 changes: 5 additions & 9 deletions rcsc/action/body_advance_ball2009.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,15 @@ calc_score( const PlayerAgent * agent,
const AngleDeg target_left_angle = target_angle - 30.0;
const AngleDeg target_right_angle = target_angle + 30.0;

for ( PlayerObject::Cont::const_iterator it = agent->world().opponentsFromSelf().begin(),
end = agent->world().opponentsFromSelf().end();
it != end;
++it )
for ( const PlayerObject * o : agent->world().opponentsFromSelf() )
{
if ( (*it)->distFromBall() > 40.0 ) continue;
if ( o->distFromBall() > 40.0 ) continue;

if ( (*it)->angleFromSelf().isWithin( target_left_angle,
target_right_angle ) )
if ( o->angleFromSelf().isWithin( target_left_angle, target_right_angle ) )
{
Vector2D project_point = angle_line.projection( (*it)->pos() );
Vector2D project_point = angle_line.projection( o->pos() );
double width = std::max( 0.0,
angle_line.dist( (*it)->pos() ) - kickable_area );
angle_line.dist( o->pos() ) - kickable_area );
double dist = agent->world().self().pos().dist( project_point );
score *= width / dist;
}
Expand Down
18 changes: 6 additions & 12 deletions rcsc/action/body_clear_ball2009.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,9 @@ get_minimum_evaluation( const AbstractPlayerObject::Cont & container,
{
double min_value = std::numeric_limits< double >::max();

for ( AbstractPlayerObject::Cont::const_iterator it = container.begin(),
end = container.end();
it != end;
++it )
for ( const AbstractPlayerObject * p : container )
{
double value = (*evaluator)( **it );
double value = (*evaluator)( *p );

if ( value < min_value )
{
Expand All @@ -97,14 +94,11 @@ get_free_angle( const WorldModel & wm,
// 360.0 );

double min_diff = 360.0;
for ( AbstractPlayerObject::Cont::const_iterator p = wm.theirPlayers().begin(),
end = wm.theirPlayers().end();
p != end;
++p )
for ( const AbstractPlayerObject * p : wm.theirPlayers() )
{
if ( (*p)->distFromBall() > 35.0 ) continue;
if ( p->distFromBall() > 35.0 ) continue;

double angle_diff = ( angle - (*p)->angleFromBall() ).abs();
double angle_diff = ( angle - p->angleFromBall() ).abs();
if ( angle_diff < min_diff )
{
min_diff = angle_diff;
Expand Down Expand Up @@ -315,7 +309,7 @@ get_clear_course( const WorldModel & wm )
s_update_time = wm.time();

#ifdef DEBUG_PROFILE
MSecTimer timer;
Timer timer;
#endif
s_last_angle = get_clear_course_recursive( wm,
25.0, /* safe angle */
Expand Down
Loading

0 comments on commit bf71940

Please sign in to comment.