types.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_RCG_TYPES_H
00033 #define RCSC_RCG_TYPES_H
00034 
00035 #include <rcsc/types.h>
00036 
00037 #include <boost/cstdint.hpp>
00038 
00039 #include <string>
00040 
00041 namespace rcsc {
00042 namespace rcg {
00043 
00044 
00046 typedef boost::int16_t Int16;
00048 typedef boost::uint16_t UInt16;
00050 typedef boost::int32_t Int32;
00052 typedef boost::int32_t UInt32;
00053 
00059 const int COLOR_NAME_MAX = 64;
00060 
00065 enum DispInfoMode {
00066     NO_INFO     = 0, 
00067     SHOW_MODE   = 1, 
00068     MSG_MODE    = 2, 
00069     DRAW_MODE   = 3, 
00070     BLANK_MODE  = 4, 
00071     PM_MODE     = 5, 
00072     TEAM_MODE   = 6, 
00073     PT_MODE     = 7, 
00074     PARAM_MODE  = 8, 
00075     PPARAM_MODE = 9  
00076 };
00077 
00082 enum MsgInfoMode {
00083     MSG_BOARD = 1,
00084     LOG_BOARD = 2
00085 };
00086 
00091 enum PlayerStatus {
00092     DISABLE         = 0x00000000,
00093     STAND           = 0x00000001,
00094     KICK            = 0x00000002,
00095     KICK_FAULT      = 0x00000004,
00096     GOALIE          = 0x00000008,
00097     CATCH           = 0x00000010,
00098     CATCH_FAULT     = 0x00000020,
00099     BALL_TO_PLAYER  = 0x00000040,
00100     PLAYER_TO_BALL  = 0x00000080,
00101     DISCARD         = 0x00000100,
00102     LOST            = 0x00000200,
00103     BALL_COLLIDE    = 0x00000400,
00104     PLAYER_COLLIDE  = 0x00000800,
00105     TACKLE          = 0x00001000,
00106     TACKLE_FAULT    = 0x00002000,
00107     BACK_PASS       = 0x00004000,
00108     FREE_KICK_FAULT = 0x00008000,
00109     POST_COLLIDE    = 0x00010000, // player collided with goal posts
00110 };
00111 
00112 
00113 /*-------------------------------------------------------------------*/
00114 // monitor protocol version 1
00115 // game log format versin 1 & version 2
00116 
00117 const double SHOWINFO_SCALE = 16.0; 
00118 const float SHOWINFO_SCALEF = 16.0f;
00119 const int REC_OLD_VERSION = 1; 
00120 const int REC_VERSION_2 = 2; 
00121 
00126 struct pos_t {
00127     Int16 enable; 
00128     Int16 side;   
00129     Int16 unum;   
00130     Int16 angle;  
00131     Int16 x;      
00132     Int16 y;      
00133 };
00134 
00139 struct team_t {
00140     char name[16]; 
00141     Int16 score;   
00142 };
00143 
00148 struct showinfo_t {
00149     char pmode;     
00150     team_t team[2]; 
00151     pos_t pos[MAX_PLAYER * 2 + 1]; 
00152     Int16 time; 
00153 };
00154 
00159 struct msginfo_t {
00160     Int16 board;  
00161     char message[2048]; 
00162 };
00163 
00168 struct pointinfo_t {
00169     Int16 x; 
00170     Int16 y; 
00171     char color[COLOR_NAME_MAX]; 
00172 };
00173 
00178 struct circleinfo_t {
00179     Int16 x; 
00180     Int16 y; 
00181     Int16 r; 
00182     char color[COLOR_NAME_MAX]; 
00183 };
00184 
00189 struct lineinfo_t {
00190     Int16 x1; 
00191     Int16 y1; 
00192     Int16 x2; 
00193     Int16 y2; 
00194     char color[COLOR_NAME_MAX]; 
00195 };
00196 
00201 struct drawinfo_t {
00202     Int16 mode; 
00203     union {
00204         pointinfo_t pinfo;
00205         circleinfo_t cinfo;
00206         lineinfo_t linfo;
00207     } object; 
00208 };
00209 
00214 struct dispinfo_t {
00215     Int16 mode; 
00216     union {
00217         showinfo_t show; 
00218         msginfo_t msg; 
00219         drawinfo_t draw; 
00220     } body; 
00221 };
00222 
00223 /*-------------------------------------------------------------------*/
00224 // monitor protocol version 2
00225 // game log format version 3
00226 
00228 const double SHOWINFO_SCALE2 = 65536.0;
00230 const float SHOWINFO_SCALE2F = 65536.0f;
00232 const int REC_VERSION_3 = 3;
00233 
00238 struct ball_t {
00239     Int32 x; 
00240     Int32 y; 
00241     Int32 deltax; 
00242     Int32 deltay; 
00243 };
00244 
00249 struct player_t {
00250     Int16 mode; 
00251     Int16 type; 
00252     Int32 x; 
00253     Int32 y; 
00254     Int32 deltax; 
00255     Int32 deltay; 
00256     Int32 body_angle; 
00257     Int32 head_angle; 
00258     Int32 view_width; 
00259     Int16 view_quality; 
00260     Int32 stamina; 
00261     Int32 effort; 
00262     Int32 recovery; 
00263     Int16 kick_count; 
00264     Int16 dash_count; 
00265     Int16 turn_count; 
00266     Int16 say_count; 
00267     Int16 turn_neck_count; 
00268     Int16 catch_count; 
00269     Int16 move_count; 
00270     Int16 change_view_count; 
00271 };
00272 
00277 struct showinfo_t2 {
00278     char pmode; 
00279     team_t team[2]; 
00280     ball_t ball; 
00281     player_t pos[MAX_PLAYER * 2]; 
00282     Int16 time; 
00283 };
00284 
00291 struct short_showinfo_t2 {
00292     ball_t ball; 
00293     player_t pos[MAX_PLAYER * 2]; 
00294     Int16 time; 
00295 };
00296 
00301 struct player_type_t {
00302     Int16 id; 
00303     Int32 player_speed_max; 
00304     Int32 stamina_inc_max; 
00305     Int32 player_decay; 
00306     Int32 inertia_moment; 
00307     Int32 dash_power_rate; 
00308     Int32 player_size; 
00309     Int32 kickable_margin; 
00310     Int32 kick_rand; 
00311     Int32 extra_stamina; 
00312     Int32 effort_max; 
00313     Int32 effort_min; 
00314 
00315     Int32 sparelong1; 
00316     Int32 sparelong2; 
00317     Int32 sparelong3; 
00318     Int32 sparelong4; 
00319     Int32 sparelong5; 
00320     Int32 sparelong6; 
00321     Int32 sparelong7; 
00322     Int32 sparelong8; 
00323     Int32 sparelong9; 
00324     Int32 sparelong10; 
00325 };
00326 
00331 struct server_params_t {
00332     Int32 goal_width; 
00333     Int32 inertia_moment; 
00334     Int32 player_size; 
00335     Int32 player_decay; 
00336     Int32 player_rand; 
00337     Int32 player_weight; 
00338     Int32 player_speed_max; 
00339     Int32 player_accel_max; 
00340     Int32 stamina_max; 
00341     Int32 stamina_inc; 
00342     Int32 recover_init; 
00343     Int32 recover_dec_thr; 
00344     Int32 recover_min; 
00345     Int32 recover_dec; 
00346     Int32 effort_init; 
00347     Int32 effort_dec_thr; 
00348     Int32 effort_min; 
00349     Int32 effort_dec; 
00350     Int32 effort_inc_thr; 
00351     Int32 effort_inc; 
00352     Int32 kick_rand;  
00353     Int16 team_actuator_noise; 
00354     Int32 player_rand_factor_l; 
00355     Int32 player_rand_factor_r; 
00356     Int32 kick_rand_factor_l; 
00357     Int32 kick_rand_factor_r; 
00358     Int32 ball_size; 
00359     Int32 ball_decay; 
00360     Int32 ball_rand; 
00361     Int32 ball_weight; 
00362     Int32 ball_speed_max; 
00363     Int32 ball_accel_max; 
00364     Int32 dash_power_rate; 
00365     Int32 kick_power_rate; 
00366     Int32 kickable_margin; 
00367     Int32 control_radius; 
00368     Int32 control_radius_width; 
00369     Int32 max_power; 
00370     Int32 min_power; 
00371     Int32 max_moment; 
00372     Int32 min_moment; 
00373     Int32 max_neck_moment; 
00374     Int32 min_neck_moment; 
00375     Int32 max_neck_angle; 
00376     Int32 min_neck_angle; 
00377     Int32 visible_angle; 
00378     Int32 visible_distance; 
00379     Int32 wind_dir; 
00380     Int32 wind_force; 
00381     Int32 wind_ang; 
00382     Int32 wind_rand; 
00383     Int32 kickable_area; 
00384     Int32 catch_area_l; 
00385     Int32 catch_area_w; 
00386     Int32 catch_probability; 
00387     Int16 goalie_max_moves; 
00388     Int32 corner_kick_margin; 
00389     Int32 offside_active_area; 
00390     Int16 wind_none; 
00391     Int16 use_wind_random; 
00392     Int16 coach_say_count_max; 
00393     Int16 coach_say_msg_size; 
00394     Int16 clang_win_size; 
00395     Int16 clang_define_win; 
00396     Int16 clang_meta_win; 
00397     Int16 clang_advice_win; 
00398     Int16 clang_info_win; 
00399     Int16 clang_mess_delay; 
00400     Int16 clang_mess_per_cycle; 
00401     Int16 half_time; 
00402     Int16 simulator_step; 
00403     Int16 send_step; 
00404     Int16 recv_step; 
00405     Int16 sense_body_step; 
00406     Int16 lcm_step; 
00407     Int16 player_say_msg_size; 
00408     Int16 player_hear_max; 
00409     Int16 player_hear_inc; 
00410     Int16 player_hear_decay; 
00411     Int16 catch_ban_cycle; 
00412     Int16 slow_down_factor; 
00413     Int16 use_offside; 
00414     Int16 kickoff_offside; 
00415     Int32 offside_kick_margin; 
00416     Int32 audio_cut_dist; 
00417     Int32 dist_quantize_step; 
00418     Int32 landmark_dist_quantize_step; 
00419     Int32 dir_quantize_step; 
00420     Int32 dist_quantize_step_l; 
00421     Int32 dist_quantize_step_r; 
00422     Int32 landmark_dist_quantize_step_l; 
00423     Int32 landmark_dist_quantize_step_r; 
00424     Int32 dir_quantize_step_l; 
00425     Int32 dir_quantize_step_r; 
00426     Int16 coach_mode; 
00427     Int16 coach_with_referee_mode; 
00428     Int16 use_old_coach_hear; 
00429     Int16 online_coach_look_step; 
00430     Int32 slowness_on_top_for_left_team;  
00431     Int32 slowness_on_top_for_right_team; 
00432 
00433     Int32 ka_length; 
00434     Int32 ka_width;  
00435 
00436     Int32 ball_stuck_area; 
00437 
00438     Int32 max_tackle_power; 
00439     Int32 max_back_tackle_power; 
00440 
00441     Int32 tackle_dist; 
00442     Int32 tackle_back_dist; 
00443     Int32 tackle_width; 
00444 
00445     Int16 start_goal_l; 
00446     Int16 start_goal_r; 
00447     Int16 fullstate_l; 
00448     Int16 fullstate_r; 
00449     Int16 drop_ball_time; 
00450     Int16 synch_mode; 
00451     Int16 synch_offset; 
00452     Int16 synch_micro_sleep; 
00453     Int16 point_to_ban; 
00454     Int16 point_to_duration; 
00455 
00456     /*
00457       Int16 pen_before_setup_wait;
00458       Int16 pen_setup_wait;
00459       Int16 pen_ready_wait;
00460       Int16 pen_taken_wait;
00461       Int16 pen_nr_kicks;
00462       Int16 pen_max_extra_kicks;
00463       Int32 pen_dist_x;
00464       Int16 pen_random_winner;
00465       Int32 pen_max_goalie_dist_x;
00466       Int16 pen_allow_mult_kicks;
00467     */
00468 };
00469 
00474 struct player_params_t {
00475     Int16 player_types; 
00476     Int16 substitute_max; 
00477     Int16 pt_max; 
00478     Int32 player_speed_max_delta_min; 
00479     Int32 player_speed_max_delta_max; 
00480     Int32 stamina_inc_max_delta_factor; 
00481     Int32 player_decay_delta_min; 
00482     Int32 player_decay_delta_max; 
00483     Int32 inertia_moment_delta_factor; 
00484     Int32 dash_power_rate_delta_min; 
00485     Int32 dash_power_rate_delta_max; 
00486     Int32 player_size_delta_factor; 
00487     Int32 kickable_margin_delta_min; 
00488     Int32 kickable_margin_delta_max; 
00489     Int32 kick_rand_delta_factor; 
00490     Int32 extra_stamina_delta_min; 
00491     Int32 extra_stamina_delta_max; 
00492     Int32 effort_max_delta_factor; 
00493     Int32 effort_min_delta_factor; 
00494     Int32 random_seed; 
00495     Int32 new_dash_power_rate_delta_min; 
00496     Int32 new_dash_power_rate_delta_max; 
00497     Int32 new_stamina_inc_max_delta_factor; 
00498 
00499     Int32 sparelong5; 
00500     Int32 sparelong6; 
00501     Int32 sparelong7; 
00502     Int32 sparelong8; 
00503     Int32 sparelong9; 
00504     Int32 sparelong10; 
00505 
00506     Int16 allow_mult_default_type; 
00507 
00508     Int16 spareshort2; 
00509     Int16 spareshort3; 
00510     Int16 spareshort4; 
00511     Int16 spareshort5; 
00512     Int16 spareshort6; 
00513     Int16 spareshort7; 
00514     Int16 spareshort8; 
00515     Int16 spareshort9; 
00516     Int16 spareshort10; 
00517 };
00518 
00525 struct dispinfo_t2 {
00526     Int16 mode; 
00527     union {
00528         showinfo_t2 show; 
00529         msginfo_t msg; 
00530         player_type_t ptinfo; 
00531         server_params_t sparams; 
00532         player_params_t pparams; 
00533     } body; 
00534 };
00535 
00536 //
00537 // Data structures for the text based monitor protocl
00538 //
00539 
00544 struct BallT {
00545     float x_; 
00546     float y_; 
00547     float vx_; 
00548     float vy_; 
00549 
00553     BallT()
00554         : x_( 0.0 )
00555         , y_( 0.0 )
00556         , vx_( SHOWINFO_SCALE2F )
00557         , vy_( SHOWINFO_SCALE2F )
00558       { }
00559 
00564     bool hasVelocity() const
00565       {
00566           return vx_ != SHOWINFO_SCALE2F
00567               && vy_ != SHOWINFO_SCALE2F;
00568       }
00569 };
00570 
00575 struct PlayerT {
00576     char side_; 
00577     Int16 unum_; 
00578     Int16 type_; 
00579 
00580     char view_quality_; 
00581 
00582     char focus_side_; 
00583     Int16 focus_unum_; 
00584 
00585     Int32 state_; 
00586 
00587     float x_; 
00588     float y_; 
00589     float vx_; 
00590     float vy_; 
00591     float body_; 
00592     float neck_; 
00593     float point_x_; 
00594     float point_y_; 
00595 
00596     float view_width_; 
00597 
00598     float stamina_; 
00599     float effort_; 
00600     float recovery_; 
00601 
00602     UInt16 kick_count_; 
00603     UInt16 dash_count_; 
00604     UInt16 turn_count_; 
00605     UInt16 catch_count_; 
00606     UInt16 move_count_; 
00607     UInt16 turn_neck_count_; 
00608     UInt16 change_view_count_; 
00609     UInt16 say_count_; 
00610     UInt16 tackle_count_; 
00611     UInt16 pointto_count_; 
00612     UInt16 attentionto_count_; 
00613 
00617     PlayerT()
00618         : side_( 'n' )
00619         , unum_( 0 )
00620         , type_( -1 )
00621         , view_quality_( 'h' )
00622         , focus_side_( 'n' )
00623         , focus_unum_( 0 )
00624         , state_( 0 )
00625         , x_( 0.0f )
00626         , y_( 0.0f )
00627         , vx_( SHOWINFO_SCALE2F )
00628         , vy_( SHOWINFO_SCALE2F )
00629         , body_( 0.0f )
00630         , neck_( SHOWINFO_SCALE2F )
00631         , point_x_( SHOWINFO_SCALE2F )
00632         , point_y_( SHOWINFO_SCALE2F )
00633         , view_width_( 0.0f )
00634         , stamina_( SHOWINFO_SCALE2F )
00635         , effort_( SHOWINFO_SCALE2F )
00636         , recovery_( SHOWINFO_SCALE2F )
00637         , kick_count_( 0 )
00638         , dash_count_( 0 )
00639         , turn_count_( 0 )
00640         , catch_count_( 0 )
00641         , move_count_( 0 )
00642         , turn_neck_count_( 0 )
00643         , change_view_count_( 0 )
00644         , say_count_( 0 )
00645         , tackle_count_( 0 )
00646         , pointto_count_( 0 )
00647         , attentionto_count_( 0 )
00648       { }
00649 
00654     SideID side() const
00655       {
00656           return ( side_ == 'l' ? LEFT
00657                    : side_ == 'r' ? RIGHT
00658                    : NEUTRAL );
00659       }
00660 
00665     bool highQuality() const
00666       {
00667           return ( view_quality_ == 'h' );
00668       }
00669 
00674     SideID focusSide() const
00675       {
00676           return ( side_ == 'l' ? LEFT
00677                    : side_ == 'r' ? RIGHT
00678                    : NEUTRAL );
00679       }
00680 
00685     bool hasVelocity() const
00686       {
00687           return vx_ != SHOWINFO_SCALE2F
00688               && vy_ != SHOWINFO_SCALE2F;
00689       }
00690 
00695     bool hasNeck() const
00696       {
00697           return neck_ != SHOWINFO_SCALE2F;
00698       }
00699 
00704     bool hasView() const
00705       {
00706           return view_width_ != SHOWINFO_SCALE2F;
00707       }
00708 
00713     bool hasStamina() const
00714       {
00715           return stamina_ != SHOWINFO_SCALE2F;
00716       }
00717 
00722     bool isAlive() const
00723       {
00724           return state_ != 0;
00725       }
00726 
00731     bool isKicking() const
00732       {
00733           return state_ & KICK;
00734       }
00735 
00740     bool isKickingFault() const
00741       {
00742           return state_ & KICK_FAULT;
00743       }
00744 
00749     bool isGoalie() const
00750       {
00751           return state_ & GOALIE;
00752       }
00753 
00758     bool isCatching() const
00759       {
00760           return state_ & CATCH;
00761       }
00762 
00767     bool isCatchingFault() const
00768       {
00769           return state_ & CATCH_FAULT;
00770       }
00771 
00776     bool isTackling() const
00777       {
00778           return state_ & TACKLE;
00779       }
00780 
00785     bool isTacklingFault() const
00786       {
00787           return state_ & TACKLE_FAULT;
00788       }
00789 
00794     bool isPointing() const
00795       {
00796           return point_x_ != SHOWINFO_SCALE2F
00797               && point_y_ != SHOWINFO_SCALE2F;
00798       }
00799 
00804     bool isFocusing() const
00805       {
00806           return side_ != 'n';
00807       }
00808 
00813     bool isCollidedBall() const
00814       {
00815           return state_ & BALL_COLLIDE;
00816       }
00817 
00822     bool isCollidedPlayer() const
00823       {
00824           return state_ & PLAYER_COLLIDE;
00825       }
00826 
00827 };
00828 
00833 struct TeamT {
00834     std::string name_; 
00835     UInt16 score_; 
00836     UInt16 pen_score_; 
00837     UInt16 pen_miss_; 
00838 
00842     TeamT()
00843         : score_( 0 )
00844         , pen_score_( 0 )
00845         , pen_miss_( 0 )
00846       { }
00847 
00855     TeamT( const char * name,
00856            const UInt16 score,
00857            const UInt16 pen_score,
00858            const UInt16 pen_miss )
00859         : name_( name )
00860         , score_( score )
00861         , pen_score_( pen_score )
00862         , pen_miss_( pen_miss )
00863       { }
00864 
00868     void clear()
00869       {
00870           name_.erase();
00871           score_ = 0;
00872           pen_score_ = 0;
00873           pen_miss_ = 0;
00874       }
00875 
00880     int penaltyTrial() const
00881       {
00882           return pen_score_ + pen_miss_;
00883       }
00884 
00890     bool equals( const TeamT & other ) const
00891       {
00892           return ( name_ == other.name_
00893                    && score_ == other.score_
00894                    && pen_score_ == other.pen_score_
00895                    && pen_miss_ == other.pen_miss_ );
00896       }
00897 
00898 };
00899 
00904 struct ShowInfoT {
00905     UInt32 time_;
00906     //    PlayMode pmode_;
00907     //    TeamT team_[2];
00908     BallT ball_;
00909     PlayerT player_[MAX_PLAYER * 2];
00910 };
00911 
00912 
00917 struct DispInfoT {
00918     PlayMode pmode_;
00919     TeamT team_[2];
00920     ShowInfoT show_;
00921 };
00922 
00923 
00925 const int REC_VERSION_4 = 4;
00926 
00928 const int DEFAULT_LOG_VERSION = REC_VERSION_4;
00929 
00930 } // end namespace
00931 } // end namespace
00932 
00933 #endif

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