body_dribble2006.h

説明を見る。
00001 // -*-c++-*-
00002 
00008 /*
00009  *Copyright:
00010 
00011  Copyright (C) Hidehisa AKIYAMA
00012 
00013  This code is free software; you can redistribute it and/or
00014  modify it under the terms of the GNU Lesser General Public
00015  License as published by the Free Software Foundation; either
00016  version 2.1 of the License, or (at your option) any later version.
00017 
00018  This library is distributed in the hope that it will be useful,
00019  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  Lesser General Public License for more details.
00022 
00023  You should have received a copy of the GNU Lesser General Public
00024  License along with this library; if not, write to the Free Software
00025  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 
00027  *EndCopyright:
00028  */
00029 
00031 
00032 #ifndef RCSC_ACTION_BODY_DRIBBLE_2006_H
00033 #define RCSC_ACTION_BODY_DRIBBLE_2006_H
00034 
00035 #include <rcsc/player/soccer_action.h>
00036 #include <rcsc/geom/vector_2d.h>
00037 
00038 #include <functional>
00039 
00040 namespace rcsc {
00041 
00042 class WorldModel;
00043 
00048 class Body_Dribble2006
00049     : public BodyAction {
00050 public:
00051 
00056     struct KeepDribbleInfo {
00057         Vector2D first_ball_vel_; 
00058         int dash_count_; 
00059         double min_opp_dist_; 
00060 
00067         KeepDribbleInfo( const Vector2D & first_ball_vel,
00068                          const int dash_count,
00069                          const double & min_opp_dist )
00070             : first_ball_vel_( first_ball_vel )
00071             , dash_count_( dash_count )
00072             , min_opp_dist_( min_opp_dist )
00073           { }
00074     };
00075 
00080     struct KeepDribbleCmp
00081         : public std::binary_function< KeepDribbleInfo,
00082                                        KeepDribbleInfo,
00083                                        bool > {
00088         result_type operator()( const first_argument_type & lhs,
00089                                 const second_argument_type & rhs ) const
00090           {
00091               if ( lhs.dash_count_ > rhs.dash_count_ )
00092               {
00093                   return true;
00094               }
00095               if ( lhs.dash_count_ == rhs.dash_count_ )
00096               {
00097                   return ( lhs.min_opp_dist_ < rhs.min_opp_dist_ );
00098               }
00099               return false;
00100           }
00101     };
00102 
00103 private:
00105     const Vector2D M_target_point;
00107     const double M_dist_thr;
00109     double M_dash_power;
00111     int M_dash_count;
00113     const bool M_dodge_mode;
00114 public:
00125     Body_Dribble2006( const Vector2D & target_point,
00126                       const double & dist_thr,
00127                       const double & dash_power,
00128                       const int dash_count,
00129                       const bool dodge = true )
00130         : M_target_point( target_point )
00131         , M_dist_thr( dist_thr )
00132         , M_dash_power( dash_power )
00133         , M_dash_count( dash_count )
00134         , M_dodge_mode( dodge )
00135       { }
00136 
00142     bool execute( PlayerAgent* agent );
00143 
00144 private:
00145 
00156     bool doAction( PlayerAgent * agent,
00157                    const Vector2D & target_point,
00158                    const double & dash_power,
00159                    const int dash_count,
00160                    const bool dodge );
00161 
00169     bool doTurnOnly( PlayerAgent * agent,
00170                      const Vector2D & target_point,
00171                      const double & dash_power );
00172 
00178     bool doCollideWithBall( PlayerAgent * agent );
00179 
00189     bool doCollideForTurn( PlayerAgent * agent,
00190                            const double & dir_diff_abs,
00191                            const bool kick_first );
00192 
00201     bool doKickTurnsDash( PlayerAgent * agent,
00202                           const Vector2D & target_point,
00203                           const double & dir_margin_abs,
00204                           const double & dash_power );
00205 
00215     bool doKickDashes( PlayerAgent * agent,
00216                        const Vector2D & target_point,
00217                        const double & dash_power,
00218                        const int dash_count );
00219 
00224     bool doKickDashesWithBall( PlayerAgent * agent,
00225                                const double & dash_power );
00226 
00227     bool existKickableOpponent( const WorldModel & wm,
00228                                 const Vector2D & ball_pos,
00229                                 double * min_opp_dist ) const;
00230 
00237     bool doDodge( PlayerAgent * agent,
00238                   const Vector2D & target_point );
00239 
00246     bool doAvoidKick( PlayerAgent * agent,
00247                       const AngleDeg & avoid_angle );
00254     bool isDodgeSituation( const PlayerAgent * agent,
00255                            const Vector2D & target_point );
00256 
00265     bool canKickAfterDash( const PlayerAgent * agent,
00266                            double * dash_power );
00267 
00275     bool existCloseOpponent( const PlayerAgent * agent,
00276                              AngleDeg * keep_angle );
00277 
00284     AngleDeg getAvoidAngle( const PlayerAgent * agent,
00285                             const AngleDeg & target_angle );
00286 
00287 };
00288 
00289 }
00290 
00291 #endif

librcscに対してThu May 1 15:41:20 2008に生成されました。  doxygen 1.5.0