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_PLAYER_INTERCEPT_TABLE_H
00033 #define RCSC_PLAYER_INTERCEPT_TABLE_H
00034
00035 #include <rcsc/geom/vector_2d.h>
00036 #include <vector>
00037
00038 namespace rcsc {
00039
00040 class PlayerObject;
00041 class WorldModel;
00042
00043
00044
00049 class InterceptInfo {
00050 public:
00051 enum Mode {
00052 NORMAL = 0,
00053 EXHAUST = 100,
00054 };
00055 private:
00056 Mode M_mode;
00057 int M_turn_cycle;
00058 int M_dash_cycle;
00059 double M_dash_power;
00060
00062 InterceptInfo();
00063 public:
00064
00068 InterceptInfo( const Mode mode,
00069 const int turn_cycle,
00070 const int dash_cycle,
00071 const double & dash_power )
00072 : M_mode( mode )
00073 , M_turn_cycle( turn_cycle )
00074 , M_dash_cycle( dash_cycle )
00075 , M_dash_power( dash_power )
00076 { }
00077
00082 Mode mode() const
00083 {
00084 return M_mode;
00085 }
00086
00091 int turnCycle() const
00092 {
00093 return M_turn_cycle;
00094 }
00095
00100 int dashCycle() const
00101 {
00102 return M_dash_cycle;
00103 }
00104
00105
00106
00107
00108
00109 int reachCycle() const
00110 {
00111 return turnCycle() + dashCycle();
00112 }
00113
00118 const
00119 double & dashPower() const
00120 {
00121 return M_dash_power;
00122 }
00123 };
00124
00125
00126
00131 class InterceptTable {
00132 private:
00133
00135 static const std::size_t MAX_CYCLE;
00136
00138 const WorldModel & M_world;
00139
00141 std::vector< Vector2D > M_ball_pos_cache;
00142
00143
00145 int M_self_reach_cycle;
00147 int M_self_exhaust_reach_cycle;
00149 int M_teammate_reach_cycle;
00151 int M_opponent_reach_cycle;
00152
00154 const PlayerObject * M_fastest_teammate;
00156 const PlayerObject * M_fastest_opponent;
00157
00159 std::vector< InterceptInfo > M_self_cache;
00160
00161
00163 InterceptTable();
00164
00165 InterceptTable( const InterceptTable & );
00166 InterceptTable & operator=( const InterceptTable & );
00167 public:
00171 explicit
00172 InterceptTable( const WorldModel & world );
00173
00177 ~InterceptTable();
00178
00182 void update();
00183
00189 void hearTeammate( const int unum,
00190 const int cycle );
00191
00197 void hearOpponent( const int unum,
00198 const int cycle );
00199
00204 int selfReachCycle() const
00205 {
00206 return M_self_reach_cycle;
00207 }
00208
00213 int selfExhaustReachCycle() const
00214 {
00215 return M_self_exhaust_reach_cycle;
00216 }
00217
00222 int teammateReachCycle() const
00223 {
00224 return M_teammate_reach_cycle;
00225 }
00226
00231 int opponentReachCycle() const
00232 {
00233 return M_opponent_reach_cycle;
00234 }
00235
00241 const
00242 PlayerObject * fastestTeammate() const
00243 {
00244 return M_fastest_teammate;
00245 }
00246
00252 const
00253 PlayerObject * fastestOpponent() const
00254 {
00255 return M_fastest_opponent;
00256 }
00257
00262 const
00263 std::vector< InterceptInfo > & selfCache() const
00264 {
00265 return M_self_cache;
00266 }
00267
00272 Vector2D selfInterceptPoint() const;
00273
00278 bool isSelfFastestPlayer() const;
00279
00284 bool isOurTeamBallPossessor() const;
00285
00286 private:
00290 void clear();
00291
00295 void createBallCache();
00296
00300 void predictSelf();
00301
00305 void predictTeammate();
00306
00310 void predictOpponent();
00311 };
00312
00313 }
00314
00315 #endif