shoot_table.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_SHOOT_TABLE_H
00033 #define RCSC_ACTION_SHOOT_TABLE_H
00034 
00035 #include <rcsc/geom/line_2d.h>
00036 #include <rcsc/geom/vector_2d.h>
00037 #include <rcsc/game_time.h>
00038 
00039 #include <functional>
00040 #include <vector>
00041 
00042 namespace rcsc {
00043 
00044 class PlayerAgent;
00045 class PlayerObject;
00046 class WorldModel;
00047 
00052 class ShootTable {
00053 public:
00058     struct Shot {
00059         Vector2D point_; 
00060         Vector2D vel_; 
00061         double speed_; 
00062         AngleDeg angle_; 
00063         bool goalie_never_reach_; 
00064         int score_; 
00065 
00072         Shot( const Vector2D & point,
00073               const double & speed,
00074               const AngleDeg & angle )
00075             : point_( point )
00076             , vel_( Vector2D::polar2vector( speed, angle ) )
00077             , speed_( speed )
00078             , angle_( angle )
00079             , goalie_never_reach_( true )
00080             , score_( 0 )
00081           { }
00082     };
00083 
00085     typedef std::vector< Shot > ShotCont;
00086 
00091     struct ScoreCmp
00092         : public std::binary_function< Shot,
00093                                        Shot,
00094                                        bool > {
00100         result_type operator()( const first_argument_type & lhs,
00101                                 const second_argument_type & rhs ) const
00102           {
00103               return lhs.score_ > rhs.score_;
00104           }
00105     };
00106 
00107 private:
00109     GameTime M_time;
00111     ShotCont M_shots;
00112 
00113 public:
00117     ShootTable()
00118       { }
00119 
00125     const
00126     ShotCont & getShots( const PlayerAgent * agent )
00127       {
00128           search( agent );
00129           return M_shots;
00130       }
00131 
00132 private:
00133 
00139     void search( const PlayerAgent * agent );
00140 
00141     void calculateShotPoint( const WorldModel & wm,
00142                              const Vector2D & shot_point,
00143                              const PlayerObject * goalie );
00144     bool canScore( const WorldModel & wm,
00145                    Shot * shot );
00146     bool maybeGoalieCatch( const WorldModel & wm,
00147                            const PlayerObject * goalie,
00148                            Shot * shot );
00149 
00150 };
00151 
00152 }
00153 
00154 #endif

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