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_TRAINER_COMMAND_H
00033 #define RCSC_TRAINER_COMMAND_H
00034
00035 #include <rcsc/geom/vector_2d.h>
00036 #include <rcsc/types.h>
00037
00038 #include <string>
00039 #include <iostream>
00040
00041 namespace rcsc {
00042
00047 class TrainerCommand {
00048 public:
00052 enum Type {
00053 INIT,
00054
00055 CHECK_BALL,
00056 LOOK,
00057 TEAM_NAMES,
00058
00059 EAR,
00060 EYE,
00061
00062 START,
00063 CHANGE_MODE,
00064 MOVE,
00065 RECOVER,
00066 CHANGE_PLAYER_TYPE,
00067 SAY,
00068
00069 COMPRESSION,
00070 DONE,
00071
00072 ILLEGAL
00073 };
00074
00075 protected:
00079 TrainerCommand()
00080 { }
00081
00082 public:
00086 virtual
00087 ~TrainerCommand()
00088 { }
00089
00094 virtual
00095 Type type() const = 0;
00096
00102 virtual
00103 std::ostream & toStr( std::ostream & to ) const = 0;
00104
00109 virtual
00110 std::string name() const = 0;
00111 };
00112
00114
00126 class TrainerInitCommand
00127 : public TrainerCommand {
00128 private:
00129 double M_version;
00130
00131 public:
00135 explicit
00136 TrainerInitCommand( const double & version )
00137 : M_version( version )
00138 { }
00139
00144 Type type() const
00145 {
00146 return INIT;
00147 }
00148
00154 std::ostream & toStr( std::ostream & to ) const;
00155
00160 std::string name() const
00161 {
00162 return std::string( "init" );
00163 }
00164 };
00165
00167
00180 class TrainerCheckBallCommand
00181 : public TrainerCommand {
00182 private:
00183
00184 public:
00188 TrainerCheckBallCommand()
00189 { }
00190
00195 Type type() const
00196 {
00197 return CHECK_BALL;
00198 }
00199
00205 std::ostream & toStr( std::ostream & to ) const;
00206
00211 std::string name() const
00212 {
00213 return std::string( "check_ball" );
00214 }
00215 };
00216
00218
00229 class TrainerLookCommand
00230 : public TrainerCommand {
00231 private:
00232
00233 public:
00237 TrainerLookCommand()
00238 { }
00239
00244 Type type() const
00245 {
00246 return LOOK;
00247 }
00248
00254 std::ostream & toStr( std::ostream & to ) const;
00255
00260 std::string name() const
00261 {
00262 return std::string( "look" );
00263 }
00264 };
00265
00267
00278 class TrainerTeamNamesCommand
00279 : public TrainerCommand {
00280 private:
00281
00282 public:
00286 TrainerTeamNamesCommand()
00287 { }
00288
00293 Type type() const
00294 {
00295 return TEAM_NAMES;
00296 }
00297
00303 std::ostream & toStr( std::ostream & to ) const;
00304
00309 std::string name() const
00310 {
00311 return std::string( "team_names" );
00312 }
00313 };
00314
00316
00328 class TrainerEarCommand
00329 : public TrainerCommand {
00330 private:
00331 bool M_on;
00332 public:
00337 explicit
00338 TrainerEarCommand( const bool on )
00339 : M_on( on )
00340 { }
00341
00346 Type type() const
00347 {
00348 return EAR;
00349 }
00350
00356 std::ostream & toStr( std::ostream & to ) const;
00357
00362 std::string name() const
00363 {
00364 return std::string( "ear" );
00365 }
00366 };
00367
00369
00381 class TrainerEyeCommand
00382 : public TrainerCommand {
00383 private:
00384 bool M_on;
00385 public:
00390 explicit
00391 TrainerEyeCommand( const bool on )
00392 : M_on( on )
00393 { }
00394
00399 Type type() const
00400 {
00401 return EYE;
00402 }
00403
00409 std::ostream & toStr( std::ostream & to ) const;
00410
00415 std::string name() const
00416 {
00417 return std::string( "eye" );
00418 }
00419 };
00420
00422
00435 class TrainerKickOffCommand
00436 : public TrainerCommand {
00437 private:
00438
00439 public:
00443 TrainerKickOffCommand()
00444 { }
00445
00450 Type type() const
00451 {
00452 return START;
00453 }
00454
00460 std::ostream & toStr( std::ostream & to ) const;
00461
00466 std::string name() const
00467 {
00468 return std::string( "start" );
00469 }
00470 };
00471
00473
00485 class TrainerChangeModeCommand
00486 : public TrainerCommand {
00487 private:
00488 PlayMode M_playmode;
00489
00490 public:
00495 explicit
00496 TrainerChangeModeCommand( const PlayMode mode )
00497 : M_playmode( mode )
00498 { }
00499
00504 Type type() const
00505 {
00506 return CHANGE_MODE;
00507 }
00508
00514 std::ostream & toStr( std::ostream & to ) const;
00515
00520 std::string name() const
00521 {
00522 return std::string( "change_mode" );
00523 }
00524 };
00525
00527
00539 class TrainerMoveBallCommand
00540 : public TrainerCommand {
00541 private:
00542 Vector2D M_pos;
00543 Vector2D M_vel;
00544
00545 public:
00551 TrainerMoveBallCommand( const double & x,
00552 const double & y );
00553
00558 explicit
00559 TrainerMoveBallCommand( const Vector2D & pos );
00560
00568 TrainerMoveBallCommand( const double & x,
00569 const double & y,
00570 const double & vx,
00571 const double & vy );
00572
00578 TrainerMoveBallCommand( const Vector2D & pos,
00579 const Vector2D & vel );
00580
00585 Type type() const
00586 {
00587 return MOVE;
00588 }
00589
00595 std::ostream & toStr( std::ostream & to ) const;
00596
00601 std::string name() const
00602 {
00603 return std::string( "move" );
00604 }
00605 };
00606
00608
00620 class TrainerMovePlayerCommand
00621 : public TrainerCommand {
00622 private:
00623 std::string M_team_name;
00624 int M_unum;
00625 Vector2D M_pos;
00626 double M_angle;
00627 Vector2D M_vel;
00628
00633 bool check() const;
00634
00635 public:
00643 TrainerMovePlayerCommand( const std::string & team_name,
00644 const int unum,
00645 const double & x,
00646 const double & y );
00647
00654 TrainerMovePlayerCommand( const std::string & team_name,
00655 const int unum,
00656 const Vector2D & pos );
00657
00666 TrainerMovePlayerCommand( const std::string & team_name,
00667 const int unum,
00668 const double & x,
00669 const double & y,
00670 const AngleDeg & angle );
00671
00679 TrainerMovePlayerCommand( const std::string & team_name,
00680 const int unum,
00681 const Vector2D & pos,
00682 const AngleDeg & angle );
00683
00694 TrainerMovePlayerCommand( const std::string & team_name,
00695 const int unum,
00696 const double & x,
00697 const double & y,
00698 const AngleDeg & angle,
00699 const double & vx,
00700 const double & vy );
00701
00711 TrainerMovePlayerCommand( const std::string & team_name,
00712 const int unum,
00713 const Vector2D & pos,
00714 const AngleDeg & angle,
00715 const double & vx,
00716 const double & vy );
00717
00726 TrainerMovePlayerCommand( const std::string & team_name,
00727 const int unum,
00728 const Vector2D & pos,
00729 const AngleDeg & angle,
00730 const Vector2D & vel );
00731
00736 Type type() const
00737 {
00738 return MOVE;
00739 }
00740
00746 std::ostream & toStr( std::ostream & to ) const;
00747
00752 std::string name() const
00753 {
00754 return std::string("move");
00755 }
00756 };
00757
00759
00770 class TrainerRecoverCommand
00771 : public TrainerCommand {
00772 private:
00773
00774 public:
00778 TrainerRecoverCommand()
00779 { }
00780
00785 Type type() const
00786 {
00787 return RECOVER;
00788 }
00789
00795 std::ostream & toStr( std::ostream & to ) const;
00796
00801 std::string name() const
00802 {
00803 return std::string( "recover" );
00804 }
00805 };
00806
00808
00822 class TrainerChangePlayerTypeCommand
00823 : public TrainerCommand {
00824 private:
00825 std::string M_team_name;
00826 int M_unum;
00827 int M_type;
00828 public:
00835 TrainerChangePlayerTypeCommand( const std::string & team_name,
00836 const int unum,
00837 const int type );
00838
00843 Type type() const
00844 {
00845 return CHANGE_PLAYER_TYPE;
00846 }
00847
00853 std::ostream & toStr( std::ostream & to ) const;
00854
00859 std::string name() const
00860 {
00861 return std::string( "change_player_type" );
00862 }
00863 };
00864
00866
00877 class TrainerSayCommand
00878 : public TrainerCommand {
00879 private:
00880 std::string M_message;
00881 public:
00886 explicit
00887 TrainerSayCommand( const std::string & msg )
00888 : M_message( msg )
00889 { }
00890
00895 Type type() const
00896 {
00897 return SAY;
00898 }
00899
00905 std::ostream & toStr( std::ostream & to ) const;
00906
00911 std::string name() const
00912 {
00913 return std::string( "say" );
00914 }
00915 };
00916
00918
00930 class TrainerCompressionCommand
00931 : public TrainerCommand {
00932 private:
00933 int M_level;
00934
00935 public:
00939 explicit
00940 TrainerCompressionCommand( const int level )
00941 : M_level( level )
00942 { }
00943
00948 Type type() const
00949 {
00950 return COMPRESSION;
00951 }
00952
00958 std::ostream & toStr( std::ostream & to ) const;
00959
00964 std::string name() const
00965 {
00966 return std::string( "compression" );
00967 }
00968 };
00969
00971
00980 class TrainerDoneCommand
00981 : public TrainerCommand {
00982 private:
00983
00984 public:
00988 TrainerDoneCommand()
00989 { }
00990
00995 Type type() const
00996 {
00997 return DONE;
00998 }
00999
01005 std::ostream & toStr( std::ostream & to ) const;
01006
01011 std::string name() const
01012 {
01013 return std::string( "done" );
01014 }
01015 };
01016
01017 }
01018
01019 #endif
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449