00001
00002
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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