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_COACH_GLOBAL_WORLD_MODEL_H
00033 #define RCSC_COACH_GLOBAL_WORLD_MODEL_H
00034
00035 #include <rcsc/coach/global_object.h>
00036 #include <rcsc/coach/player_type_analyzer.h>
00037 #include <rcsc/game_mode.h>
00038 #include <rcsc/game_time.h>
00039 #include <rcsc/types.h>
00040
00041 #include <boost/shared_ptr.hpp>
00042
00043 #include <iostream>
00044 #include <string>
00045
00046 namespace rcsc {
00047
00048 class AudioMemory;
00049 class GlobalVisualSensor;
00050
00055 class GlobalWorldModel {
00056 private:
00057
00059 boost::shared_ptr< AudioMemory > M_audio_memory;
00060
00061
00062
00063
00064
00066 GameTime M_time;
00068 GameTime M_see_time;
00069
00071 SideID M_our_side;
00072
00073 std::string M_team_name_left;
00074 std::string M_team_name_right;
00075
00077 GameMode M_game_mode;
00078
00079
00080
00081
00082
00084 GlobalBallObject M_ball;
00085
00087 std::list< GlobalPlayerObject > M_players;
00088
00090 std::vector< const GlobalPlayerObject * > M_players_left;
00091
00093 std::vector< const GlobalPlayerObject * > M_players_right;
00094
00095
00096
00097
00098
00100 PlayerTypeAnalyzer M_player_type_analyzer;
00101
00103 int M_change_count_left;
00105 int M_change_count_right;
00106
00108 int M_player_types_left[11];
00110 int M_player_types_right[11];
00111
00113 std::vector< int > M_player_type_used_count_left;
00115 std::vector< int > M_player_type_used_count_right;
00116
00117
00118
00119
00120
00122 long M_last_playon_start;
00123
00125 int M_freeform_allowed_count;
00126
00128 int M_freeform_send_count;
00129
00130
00132 GlobalWorldModel( const GlobalWorldModel & );
00134 GlobalWorldModel & operator=( const GlobalWorldModel & );
00135 public:
00139 GlobalWorldModel();
00140
00145 void init( const SideID side );
00146
00152 void setAudioMemory( boost::shared_ptr< AudioMemory > memory );
00153
00158 const
00159 AudioMemory & audioMemory() const
00160 {
00161 return *M_audio_memory;
00162 }
00163
00169 void initFreeformCount();
00170
00176 void setTeamName( const SideID side,
00177 const std::string & name );
00178
00186 void setPlayerType( const SideID side,
00187 const int unum,
00188 const int type );
00189
00195 void updatePlayMode( const GameMode & game_mode,
00196 const GameTime & current );
00197
00203 void updateAfterSeeGlobal( const GlobalVisualSensor & see_global,
00204 const GameTime & current );
00205
00209 void incFreeformSendCount()
00210 {
00211 ++M_freeform_send_count;
00212 }
00213
00218 SideID ourSide() const
00219 {
00220 return M_our_side;
00221 }
00222
00227 SideID theirSide() const
00228 {
00229 return ( M_our_side == LEFT ? RIGHT : LEFT );
00230 }
00231
00236 const
00237 std::string & teamNameLeft() const
00238 {
00239 return M_team_name_left;
00240 }
00241
00246 const
00247 std::string & teamNameRight() const
00248 {
00249 return M_team_name_right;
00250 }
00251
00256 const
00257 std::string & ourTeamName() const
00258 {
00259 return ( ourSide() == LEFT
00260 ? M_team_name_left
00261 : M_team_name_right );
00262 }
00263
00268 const
00269 std::string & theirTeamName() const
00270 {
00271 return ( ourSide() == LEFT
00272 ? M_team_name_right
00273 : M_team_name_left );
00274 }
00275
00280 const
00281 GameTime & time() const
00282 {
00283 return M_time;
00284 }
00285
00290 const
00291 GameTime & seeTime() const
00292 {
00293 return M_see_time;
00294 }
00295
00300 const
00301 GameMode & gameMode() const
00302 {
00303 return M_game_mode;
00304 }
00305
00310 const
00311 GlobalBallObject & ball() const
00312 {
00313 return M_ball;
00314 }
00315
00320 BallStatus getBallStatus() const;
00321
00327 const
00328 std::list< GlobalPlayerObject > & players() const
00329 {
00330 return M_players;
00331 }
00332
00337 const
00338 std::vector< const GlobalPlayerObject * > & playersLeft() const
00339 {
00340 return M_players_left;
00341 }
00342
00347 const
00348 std::vector< const GlobalPlayerObject * > & playersRight() const
00349 {
00350 return M_players_right;
00351 }
00352
00357 const
00358 std::vector< const GlobalPlayerObject * > & teammates() const
00359 {
00360 return ( ourSide() == LEFT
00361 ? playersLeft()
00362 : playersRight() );
00363 }
00364
00369 const
00370 std::vector< const GlobalPlayerObject * > & opponents() const
00371 {
00372 return ( ourSide() == LEFT
00373 ? playersRight()
00374 : playersLeft() );
00375 }
00376
00377
00378
00379
00380
00385 int playerTypeChangeCount( const SideID side ) const
00386 {
00387 return ( side == LEFT
00388 ? M_change_count_left
00389 : M_change_count_right );
00390 }
00391
00398 int heteroID( const SideID side,
00399 const int unum ) const;
00400
00405 const
00406 std::vector< int > & playerTypeUsedCount( const SideID side ) const
00407 {
00408 return ( side == LEFT
00409 ? M_player_type_used_count_left
00410 : M_player_type_used_count_right );
00411 }
00412
00413
00414
00415
00416
00421 const
00422 long & lastPlayonStart() const
00423 {
00424 return M_last_playon_start;
00425 }
00426
00431 int freeformAllowedCount() const
00432 {
00433 return M_freeform_allowed_count;
00434 }
00435
00440 int freeformSendCount() const
00441 {
00442 return M_freeform_send_count;
00443 }
00444
00449 bool canSendFreeform() const;
00450
00451
00456 bool existKickablePlayer() const;
00457
00463 const
00464 GlobalPlayerObject * getPlayerNearestTo( const Vector2D & point ) const;
00465
00471 std::ostream & print( std::ostream & os ) const;
00472
00473 };
00474
00475 }
00476
00477 #endif