Home | Docs | Authors | Clients | Library Repository | RoboCup | Admin |
rccptest.cpp00001 // -*-c++-*- 00002 00003 /*************************************************************************** 00004 rccptest.cc 00005 RoboCup Client Parser testing program 00006 ------------------- 00007 begin : 01-JUL-2002 00008 copyright : (C) 2002 by Tom Howard 00009 email : tomhoward@users.sf.net 00010 ***************************************************************************/ 00011 00012 /*************************************************************************** 00013 * * 00014 * This program is free software; you can redistribute it and/or modify * 00015 * it under the terms of the GNU LGPL as published by the Free Software * 00016 * Foundation; either version 2 of the License, or (at your option) any * 00017 * later version. * 00018 * * 00019 ***************************************************************************/ 00020 00021 #ifdef HAVE_CONFIG_H 00022 #include "config.h" 00023 #endif 00024 00025 #ifdef HAVE_SSTREAM 00026 #include <sstream> 00027 #else 00028 #include <strstream> 00029 #endif 00030 00031 #include "rccparser.h" 00032 #include <stack> 00033 #include <iostream> 00034 #include <string> 00035 00036 #ifndef HAVE_LIBRCSSCLANGPARSER 00037 class CLangParser 00038 : public rcss::Parser 00039 { 00040 bool 00041 doParse( std::istream& ) 00042 { return true; } 00043 }; 00044 #else 00045 #include <rcssserver/clangparser.h> 00046 #include <rcssserver/clangmsgbuilder.h> 00047 #include <rcssserver/clangmsg.h> 00048 #endif 00049 00050 class TestParser 00051 : public rcc::Parser 00052 { 00053 public: 00054 TestParser( rcss::Parser& clang_parser ) 00055 : rcc::Parser( clang_parser ) 00056 {} 00057 00058 virtual 00059 ~TestParser() 00060 {} 00061 00062 std::string 00063 getString() 00064 { return ( M_stack.empty() ? "" : M_stack.top() ); } 00065 00066 void 00067 clear() 00068 { while( !M_stack.empty() ) M_stack.pop(); } 00069 00070 private: 00071 std::stack< std::string > M_stack; 00072 00073 std::string 00074 buildFlagName( bool close ) 00075 { return doBuildFlagName( close ); } 00076 00077 std::string 00078 buildGoalName( bool close ) 00079 { return doBuildGoalName( close ); } 00080 00081 void 00082 buildPlayerName( std::ostream& strm, bool close, bool long_goalie ) 00083 { doBuildPlayerName( strm, close, long_goalie ); } 00084 00085 bool 00086 isFieldObj( const std::string& str ) const 00087 { 00088 if( str.size() < 3 || str[ 0 ] != '(' || str[ 1 ] != '(' ) 00089 { 00090 return false; 00091 } 00092 switch( str[ 2 ] ) 00093 { 00094 case 'p': 00095 case 'P': 00096 case 'b': 00097 case 'B': 00098 case 'g': 00099 case 'G': 00100 case 'l': 00101 case 'f': 00102 case 'F': 00103 return true; 00104 default: 00105 return false; 00106 } 00107 } 00108 00109 bool 00110 isLocation( const std::string& str ) const 00111 { 00112 if( str.size() == 2 ) 00113 { 00114 #ifdef HAVE_SSTREAM 00115 std::istringstream strm( str ); 00116 #else 00117 std::istrstream strm( str ); 00118 #endif 00119 int offset = -1; 00120 strm >> offset; 00121 if( offset != -1 ) 00122 return true; 00123 else 00124 return false; 00125 } 00126 00127 if( str.size() != 1 ) 00128 return false; 00129 00130 00131 switch( str[ 0 ] ) 00132 { 00133 case 'l': 00134 case 'r': 00135 case 't': 00136 case 'b': 00137 case 'p': 00138 case 'c': 00139 case 'g': 00140 case '0': 00141 case '5': 00142 return true; 00143 default: 00144 return false; 00145 } 00146 } 00147 00148 virtual 00149 void 00150 doMsgParsed() 00151 { 00152 } 00153 00154 virtual 00155 void 00156 doParsedCLang( const std::string& msg ) 00157 { 00158 #ifndef HAVE_LIBRCSSCLANGPARSER 00159 M_stack.push( msg ); 00160 #endif 00161 } 00162 00163 virtual 00164 void 00165 doBuildFullState( int time ) 00166 { 00167 std::ostringstream strm; 00168 std::stack< std::string > players; 00169 while( !M_stack.empty() 00170 && M_stack.top().size() > 3 00171 && M_stack.top()[ 2 ] == 'p' ) 00172 { 00173 players.push( M_stack.top() ); 00174 M_stack.pop(); 00175 } 00176 std::string ball; 00177 if( !M_stack.empty() ) 00178 { ball = M_stack.top(); M_stack.pop(); } 00179 std::string score; 00180 if( !M_stack.empty() ) 00181 { score = M_stack.top(); M_stack.pop(); } 00182 std::string arm; 00183 if( !M_stack.empty() ) 00184 { arm = M_stack.top(); M_stack.pop(); } 00185 std::string counts; 00186 if( !M_stack.empty() ) 00187 { counts = M_stack.top(); M_stack.pop(); } 00188 std::string vmode; 00189 if( !M_stack.empty() ) 00190 { vmode = M_stack.top(); M_stack.pop(); } 00191 std::string pmode; 00192 if( !M_stack.empty() ) 00193 { pmode = M_stack.top(); M_stack.pop(); } 00194 00195 strm << "(fullstate " << time 00196 << " (pmode " << pmode << ")" 00197 << " (vmode " << vmode << ")" 00198 << " " << counts 00199 << " " << arm 00200 << " " << score 00201 << " " << ball; 00202 while( !players.empty() ) 00203 { 00204 strm << " " << players.top(); 00205 players.pop(); 00206 } 00207 strm << ")"; 00208 M_stack.push( strm.str() ); 00209 } 00210 00211 virtual 00212 void 00213 doBuildCounts( int kick, int dash, int turn, int katch, 00214 int move, int turn_neck, int change_view, int say ) 00215 { 00216 std::ostringstream strm; 00217 strm << "(count" 00218 << " " << kick 00219 << " " << dash 00220 << " " << turn 00221 << " " << katch 00222 << " " << move 00223 << " " << turn_neck 00224 << " " << change_view 00225 << " " << say 00226 << ")"; 00227 M_stack.push( strm.str() ); 00228 00229 } 00230 00231 virtual 00232 void 00233 doBuildCatchBallLeftPlayMode() 00234 { 00235 M_stack.push( "goalie_catch_ball_l" ); 00236 } 00237 00238 virtual 00239 void 00240 doBuildCatchBallRightPlayMode() 00241 { 00242 M_stack.push( "goalie_catch_ball_r" ); 00243 } 00244 00245 virtual 00246 void 00247 doBuildBeforeKickOffPlayMode() 00248 { 00249 M_stack.push( "before_kick_off" ); 00250 } 00251 00252 virtual 00253 void 00254 doBuildTimeOverPlayMode() 00255 { 00256 M_stack.push( "time_over" ); 00257 } 00258 00259 virtual 00260 void 00261 doBuildPlayOnPlayMode() 00262 { 00263 M_stack.push( "play_on" ); 00264 } 00265 00266 virtual 00267 void 00268 doBuildKickOffLeftPlayMode() 00269 { 00270 M_stack.push( "kick_off_l" ); 00271 } 00272 00273 virtual 00274 void 00275 doBuildKickOffRightPlayMode() 00276 { 00277 M_stack.push( "kick_off_r" ); 00278 } 00279 00280 virtual 00281 void 00282 doBuildKickInLeftPlayMode() 00283 { 00284 M_stack.push( "kick_in_l" ); 00285 } 00286 00287 virtual 00288 void 00289 doBuildKickInRightPlayMode() 00290 { 00291 M_stack.push( "kick_in_r" ); 00292 } 00293 00294 virtual 00295 void 00296 doBuildFreeKickLeftPlayMode() 00297 { 00298 M_stack.push( "free_kick_l" ); 00299 } 00300 00301 virtual 00302 void 00303 doBuildFreeKickRightPlayMode() 00304 { 00305 M_stack.push( "free_kick_r" ); 00306 } 00307 00308 virtual 00309 void 00310 doBuildCornerKickLeftPlayMode() 00311 { 00312 M_stack.push( "corner_kick_l" ); 00313 } 00314 00315 virtual 00316 void 00317 doBuildCornerKickRightPlayMode() 00318 { 00319 M_stack.push( "corner_kick_r" ); 00320 } 00321 00322 virtual 00323 void 00324 doBuildGoalKickLeftPlayMode() 00325 { 00326 M_stack.push( "goal_kick_l" ); 00327 } 00328 00329 virtual 00330 void 00331 doBuildGoalKickRightPlayMode() 00332 { 00333 M_stack.push( "goal_kick_r" ); 00334 } 00335 00336 virtual 00337 void 00338 doBuildAfterGoalLeftPlayMode() 00339 { 00340 M_stack.push( "goal_l" ); 00341 } 00342 00343 virtual 00344 void 00345 doBuildAfterGoalRightPlayMode() 00346 { 00347 M_stack.push( "goal_r" ); 00348 } 00349 00350 virtual 00351 void 00352 doBuildDropBallPlayMode() 00353 { 00354 M_stack.push( "drop_ball" ); 00355 } 00356 00357 virtual 00358 void 00359 doBuildOffSideLeftPlayMode() 00360 { 00361 M_stack.push( "offside_l" ); 00362 } 00363 00364 virtual 00365 void 00366 doBuildOffsideRightPlayMode() 00367 { 00368 M_stack.push( "offside_r" ); 00369 } 00370 00371 virtual 00372 void 00373 doBuildPenaltyKickLeftPlayMode() 00374 { 00375 M_stack.push( "penalty_kick_l" ); 00376 } 00377 00378 virtual 00379 void 00380 doBuildPenaltyKickRightPlayMode() 00381 { 00382 M_stack.push( "penalty_kick_r" ); 00383 } 00384 00385 virtual 00386 void 00387 doBuildFirstHalfOverPlayMode() 00388 { 00389 M_stack.push( "first_half_over" ); 00390 } 00391 00392 virtual 00393 void 00394 doBuildPausePlayMode() 00395 { 00396 M_stack.push( "pause" ); 00397 } 00398 00399 virtual 00400 void 00401 doBuildHumanPlayMode() 00402 { 00403 M_stack.push( "human_judge" ); 00404 } 00405 00406 virtual 00407 void 00408 doBuildFoulLeftPlayMode() 00409 { 00410 M_stack.push( "foul_l" ); 00411 } 00412 00413 virtual 00414 void 00415 doBuildFoulRightPlayMode() 00416 { 00417 M_stack.push( "foul_r" ); 00418 } 00419 00420 virtual 00421 void 00422 doBuildFoulChargeLeftPlayMode() 00423 { 00424 M_stack.push( "foul_charge_l" ); 00425 } 00426 00427 virtual 00428 void 00429 doBuildFoulChargeRightPlayMode() 00430 { 00431 M_stack.push( "foul_charge_r" ); 00432 } 00433 00434 virtual 00435 void 00436 doBuildFoulPushLeftPlayMode() 00437 { 00438 M_stack.push( "foul_push_l" ); 00439 } 00440 00441 virtual 00442 void 00443 doBuildFoulPushRightPlayMode() 00444 { 00445 M_stack.push( "foul_push_r" ); 00446 } 00447 00448 virtual 00449 void 00450 doBuildFoulMultipleAttackerLeftPlayMode() 00451 { 00452 M_stack.push( "foul_multiple_attack_l" ); 00453 } 00454 00455 virtual 00456 void 00457 doBuildFoulMultipleAttackerRightPlayMode() 00458 { 00459 M_stack.push( "foul_multiple_attack_r" ); 00460 } 00461 00462 virtual 00463 void 00464 doBuildFoulBallOutLeftPlayMode() 00465 { 00466 M_stack.push( "foul_ballout_l" ); 00467 } 00468 00469 virtual 00470 void 00471 doBuildFoulBallOutRightPlayMode() 00472 { 00473 M_stack.push( "foul_ballout_r" ); 00474 } 00475 00476 virtual 00477 void 00478 doBuildBackPassLeftPlayMode() 00479 { 00480 M_stack.push( "back_pass_l" ); 00481 } 00482 00483 virtual 00484 void 00485 doBuildBackPassRightPlayMode() 00486 { 00487 M_stack.push( "back_pass_r" ); 00488 } 00489 00490 virtual 00491 void 00492 doBuildFreeKickFaultLeftPlayMode() 00493 { 00494 M_stack.push( "free_kick_fault_l" ); 00495 } 00496 00497 virtual 00498 void 00499 doBuildFreeKickFaultRightPlayMode() 00500 { 00501 M_stack.push( "free_kick_fault_r" ); 00502 } 00503 00504 virtual 00505 void 00506 doBuildScore( int our, int opp ) 00507 { 00508 std::ostringstream strm; 00509 strm << "(score " << our << " " << opp << ")"; 00510 M_stack.push( strm.str() ); 00511 00512 } 00513 00514 virtual 00515 void 00516 doBuildBall( double x, double y, 00517 double delta_x, double delta_y ) 00518 { 00519 std::ostringstream strm; 00520 strm << "((b) " << x << " " << y 00521 << " " << delta_x << " " << delta_y 00522 << ")"; 00523 M_stack.push( strm.str() ); 00524 00525 } 00526 00527 virtual 00528 void 00529 doBuildPlayer( int unum, 00530 double x, double y, 00531 double delta_x, double delta_y, 00532 double orientation, double head_orientation, 00533 int stamina, double effort, double recovery ) 00534 { 00535 } 00536 00537 virtual 00538 void 00539 doBuildPlayer( int unum, int type, 00540 double pos_x, double pos_y, 00541 double vel_x, double vel_y, 00542 double body_dir, double head_dir, 00543 double stamina, double effort, 00544 double recovery ) 00545 { 00546 std::ostringstream strm; 00547 std::string side; 00548 if( !M_stack.empty() ) 00549 { side = M_stack.top(); M_stack.pop(); } 00550 strm << "((p " << side << " " << unum << " " << type << ")" 00551 << " " << pos_x << " " << pos_y 00552 << " " << vel_x << " " << vel_y 00553 << " " << body_dir << " " << head_dir 00554 << " (stamina " << stamina 00555 << " " << effort 00556 << " " << recovery 00557 << "))"; 00558 M_stack.push( strm.str() ); 00559 00560 } 00561 00562 virtual 00563 void 00564 doBuildGoalie( int unum, 00565 double pos_x, double pos_y, 00566 double vel_x, double vel_y, 00567 double body_dir, double head_dir, 00568 double stamina, double effort, 00569 double recovery ) 00570 { 00571 std::ostringstream strm; 00572 std::string side; 00573 if( !M_stack.empty() ) 00574 { side = M_stack.top(); M_stack.pop(); } 00575 strm << "((p " << side << " " << unum << " g)" 00576 << " " << pos_x << " " << pos_y 00577 << " " << vel_x << " " << vel_y 00578 << " " << body_dir << " " << head_dir 00579 << " (stamina " << stamina 00580 << " " << effort 00581 << " " << recovery 00582 << "))"; 00583 M_stack.push( strm.str() ); 00584 00585 } 00586 00587 virtual 00588 void 00589 doBuildLeftSide() 00590 { 00591 M_stack.push( "l" ); 00592 } 00593 00594 virtual 00595 void 00596 doBuildRightSide() 00597 { 00598 M_stack.push( "r" ); 00599 } 00600 00601 virtual 00602 void 00603 doBuildOppSide() 00604 { 00605 M_stack.push( "opp" ); 00606 } 00607 00608 virtual 00609 void 00610 doBuildOurSide() 00611 { 00612 M_stack.push( "our" ); 00613 } 00614 00615 virtual 00616 void 00617 doBuildNeutralSide() 00618 { 00619 M_stack.push( "n" ); 00620 } 00621 00622 virtual 00623 void 00624 doBuildSenseBody( int time, 00625 double stamina, 00626 double effort, 00627 double speed_mag, 00628 double speed_head, 00629 double head_angle, 00630 int kick_count, 00631 int dash_count, 00632 int turn_count, 00633 int say_count, 00634 int turn_neck_count, 00635 int catch_count, 00636 int move_count, 00637 int chg_view_count ) 00638 { 00639 std::ostringstream strm; 00640 std::string tackle; 00641 std::string focus; 00642 std::string arm; 00643 std::string view_mode; 00644 if( !M_stack.empty() ) 00645 { 00646 tackle = M_stack.top(); M_stack.pop(); 00647 if( tackle.substr( 0, 7 ) != "(tackle" ) 00648 { 00649 view_mode = tackle; 00650 tackle = ""; 00651 } 00652 else 00653 { 00654 if( !M_stack.empty() ) 00655 { focus = M_stack.top(); M_stack.pop(); } 00656 if( !M_stack.empty() ) 00657 { arm = M_stack.top(); M_stack.pop(); } 00658 if( !M_stack.empty() ) 00659 { view_mode = M_stack.top(); M_stack.pop(); } 00660 } 00661 } 00662 00663 strm << "(sense_body" 00664 << " " << time 00665 << " (view_mode " << view_mode << ")" 00666 << " (stamina " << stamina << " " << effort << ")" 00667 << " (speed " << speed_mag << " " << speed_head << ")" 00668 << " (head_angle " << head_angle << ")" 00669 << " (kick " << kick_count << ")" 00670 << " (dash " << dash_count << ")" 00671 << " (turn " << turn_count << ")" 00672 << " (say " << say_count << ")" 00673 << " (turn_neck " << turn_neck_count << ")" 00674 << " (catch " << catch_count << ")" 00675 << " (move " << move_count << ")" 00676 << " (change_view " << chg_view_count << ")"; 00677 if( !arm.empty() ) 00678 strm << " " << arm; 00679 if( !focus.empty() ) 00680 strm << " " << focus; 00681 if( !tackle.empty() ) 00682 strm << " " << tackle; 00683 strm << ")"; 00684 M_stack.push( strm.str() ); 00685 00686 } 00687 00688 virtual 00689 void 00690 doBuildArmState( int movable_in, 00691 int expires_in, 00692 double target_x, 00693 double target_y, 00694 int count ) 00695 { 00696 std::ostringstream strm; 00697 strm << "(arm " 00698 << " (movable " << movable_in << ")" 00699 << " (expires " << expires_in << ")" 00700 << " (target " << target_x << " " << target_y << ")" 00701 << " (count " << count << ")" 00702 << ")"; 00703 M_stack.push( strm.str() ); 00704 00705 } 00706 00707 virtual 00708 void 00709 doBuildFocusState( int count ) 00710 { 00711 std::ostringstream strm; 00712 strm << "(focus" 00713 << " (target none)" 00714 << " (count " << count << ")" 00715 << ")"; 00716 M_stack.push( strm.str() ); 00717 00718 } 00719 00720 virtual 00721 void 00722 doBuildFocusState( int unum, int count ) 00723 { 00724 std::ostringstream strm; 00725 std::string side; 00726 if( !M_stack.empty() ) 00727 { side = M_stack.top(); M_stack.pop(); } 00728 strm << "(focus " 00729 << " (target " << side << " " << unum << ")" 00730 << " (count " << count << ")" 00731 << ")"; 00732 M_stack.push( strm.str() ); 00733 00734 } 00735 00736 virtual 00737 void 00738 doBuildTackleState( int expires_in, int count ) 00739 { 00740 std::ostringstream strm; 00741 strm << "(tackle" 00742 << " (expires " << expires_in << ")" 00743 << " (count " << count << ")" 00744 << ")"; 00745 M_stack.push( strm.str() ); 00746 00747 } 00748 00749 virtual 00750 void 00751 doBuildViewMode() 00752 { 00753 std::ostringstream strm; 00754 std::string qual, width; 00755 if( !M_stack.empty() ) 00756 { width = M_stack.top(); M_stack.pop(); } 00757 if( !M_stack.empty() ) 00758 { qual = M_stack.top(); M_stack.pop(); } 00759 strm << qual << " " << width; 00760 M_stack.push( strm.str() ); 00761 00762 } 00763 00764 virtual 00765 void 00766 doBuildViewQualityHigh() 00767 { 00768 M_stack.push( "high" ); 00769 } 00770 00771 virtual 00772 void 00773 doBuildViewQualityLow() 00774 { 00775 M_stack.push( "low" ); 00776 } 00777 00778 virtual 00779 void 00780 doBuildViewWidthNarrow() 00781 { 00782 M_stack.push( "narrow" ); 00783 } 00784 00785 virtual 00786 void 00787 doBuildViewWidthNormal() 00788 { 00789 M_stack.push( "normal" ); 00790 } 00791 00792 virtual 00793 void 00794 doBuildViewWidthWide() 00795 { 00796 M_stack.push( "wide" ); 00797 } 00798 00799 virtual 00800 void 00801 doBuildServerParam ( double gwidth, 00802 double inertia_moment, 00803 double psize, 00804 double pdecay, 00805 double prand, 00806 double pweight, 00807 double pspeed_max, 00808 double paccel_max, 00809 double stamina_max, 00810 double stamina_inc, 00811 double recover_init, 00812 double recover_dthr, 00813 double recover_min, 00814 double recover_dec, 00815 double effort_init, 00816 double effort_dthr, 00817 double effort_min, 00818 double effort_dec, 00819 double effort_ithr, 00820 double effort_inc, 00821 double kick_rand, 00822 int team_actuator_noise, 00823 double prand_factor_l, 00824 double prand_factor_r, 00825 double kick_rand_factor_l, 00826 double kick_rand_factor_r, 00827 double bsize, 00828 double bdecay, 00829 double brand, 00830 double bweight, 00831 double bspeed_max, 00832 double baccel_max, 00833 double dprate, 00834 double kprate, 00835 double kmargin, 00836 double ctlradius, 00837 double ctlradius_width, 00838 double maxp, 00839 double minp, 00840 double maxm, 00841 double minm, 00842 double maxnm, 00843 double minnm, 00844 double maxn, 00845 double minn, 00846 double visangle, 00847 double visdist, 00848 double windir, 00849 double winforce, 00850 double winang, 00851 double winrand, 00852 double kickable_area, 00853 double catch_area_l, 00854 double catch_area_w, 00855 double catch_prob, 00856 int goalie_max_moves, 00857 double ckmargin, 00858 double offside_area, 00859 int win_no, 00860 int win_random, 00861 int say_cnt_max, 00862 int SayCoachMsgSize, 00863 int clang_win_size, 00864 int clang_define_win, 00865 int clang_meta_win, 00866 int clang_advice_win, 00867 int clang_info_win, 00868 int clang_mess_delay, 00869 int clang_mess_per_cycle, 00870 int half_time, 00871 int sim_st, 00872 int send_st, 00873 int recv_st, 00874 int sb_step, 00875 int lcm_st, 00876 int SayMsgSize, 00877 int hear_max, 00878 int hear_inc, 00879 int hear_decay, 00880 int cban_cycle, 00881 int slow_down_factor, 00882 int useoffside, 00883 int kickoffoffside, 00884 double offside_kick_margin, 00885 double audio_dist, 00886 double dist_qstep, 00887 double land_qstep, 00888 double dir_qstep, 00889 double dist_qstep_l, 00890 double dist_qstep_r, 00891 double land_qstep_l, 00892 double land_qstep_r, 00893 double dir_qstep_l, 00894 double dir_qstep_r, 00895 int CoachMode, 00896 int CwRMode, 00897 int old_hear, 00898 int sv_st, 00899 int start_goal_l, 00900 int start_goal_r, 00901 int fullstate_l, 00902 int fullstate_r, 00903 int drop_time ) 00904 { 00905 std::ostringstream strm; 00906 strm << "(server_param" 00907 << " " << gwidth 00908 << " " << inertia_moment 00909 << " " << psize 00910 << " " << pdecay 00911 << " " << prand 00912 << " " << pweight 00913 << " " << pspeed_max 00914 << " " << paccel_max 00915 << " " << stamina_max 00916 << " " << stamina_inc 00917 << " " << recover_init 00918 << " " << recover_dthr 00919 << " " << recover_min 00920 << " " << recover_dec 00921 << " " << effort_init 00922 << " " << effort_dthr 00923 << " " << effort_min 00924 << " " << effort_dec 00925 << " " << effort_ithr 00926 << " " << effort_inc 00927 << " " << kick_rand 00928 << " " << team_actuator_noise 00929 << " " << prand_factor_l 00930 << " " << prand_factor_r 00931 << " " << kick_rand_factor_l 00932 << " " << kick_rand_factor_r 00933 << " " << bsize 00934 << " " << bdecay 00935 << " " << brand 00936 << " " << bweight 00937 << " " << bspeed_max 00938 << " " << baccel_max 00939 << " " << dprate 00940 << " " << kprate 00941 << " " << kmargin 00942 << " " << ctlradius 00943 << " " << ctlradius_width 00944 << " " << maxp 00945 << " " << minp 00946 << " " << maxm 00947 << " " << minm 00948 << " " << maxnm 00949 << " " << minnm 00950 << " " << maxn 00951 << " " << minn 00952 << " " << visangle 00953 << " " << visdist 00954 << " " << windir 00955 << " " << winforce 00956 << " " << winang 00957 << " " << winrand 00958 << " " << kickable_area 00959 << " " << catch_area_l 00960 << " " << catch_area_w 00961 << " " << catch_prob 00962 << " " << goalie_max_moves 00963 << " " << ckmargin 00964 << " " << offside_area 00965 << " " << win_no 00966 << " " << win_random 00967 << " " << say_cnt_max 00968 << " " << SayCoachMsgSize 00969 << " " << clang_win_size 00970 << " " << clang_define_win 00971 << " " << clang_meta_win 00972 << " " << clang_advice_win 00973 << " " << clang_info_win 00974 << " " << clang_mess_delay 00975 << " " << clang_mess_per_cycle 00976 << " " << half_time 00977 << " " << sim_st 00978 << " " << send_st 00979 << " " << recv_st 00980 << " " << sb_step 00981 << " " << lcm_st 00982 << " " << SayMsgSize 00983 << " " << hear_max 00984 << " " << hear_inc 00985 << " " << hear_decay 00986 << " " << cban_cycle 00987 << " " << slow_down_factor 00988 << " " << useoffside 00989 << " " << kickoffoffside 00990 << " " << offside_kick_margin 00991 << " " << audio_dist 00992 << " " << dist_qstep 00993 << " " << land_qstep 00994 << " " << dir_qstep 00995 << " " << dist_qstep_l 00996 << " " << dist_qstep_r 00997 << " " << land_qstep_l 00998 << " " << land_qstep_r 00999 << " " << dir_qstep_l 01000 << " " << dir_qstep_r 01001 << " " << CoachMode 01002 << " " << CwRMode 01003 << " " << old_hear 01004 << " " << sv_st 01005 << " " << start_goal_l 01006 << " " << start_goal_r 01007 << " " << fullstate_l 01008 << " " << fullstate_r 01009 << " " << drop_time 01010 << ")"; 01011 M_stack.push( strm.str() ); 01012 01013 } 01014 01015 virtual 01016 void 01017 doBuildServerParam() 01018 { 01019 std::ostringstream strm; 01020 strm << "(server_param"; 01021 std::stack< std::string > params; 01022 while( !M_stack.empty() ) 01023 { 01024 params.push( M_stack.top() ); 01025 M_stack.pop(); 01026 } 01027 01028 while( !params.empty() ) 01029 { 01030 strm << " " << params.top(); 01031 params.pop(); 01032 } 01033 strm << ")"; 01034 M_stack.push( strm.str() ); 01035 01036 } 01037 01038 virtual 01039 void 01040 doBuildParam( const std::string& name, 01041 int value ) 01042 { 01043 std::ostringstream strm; 01044 strm << "(" << name << " " << value << ")"; 01045 M_stack.push( strm.str() ); 01046 01047 } 01048 01049 virtual 01050 void 01051 doBuildParam( const std::string& name, 01052 double value ) 01053 { 01054 std::ostringstream strm; 01055 strm << "(" << name << " " << value << ")"; 01056 M_stack.push( strm.str() ); 01057 01058 } 01059 01060 virtual 01061 void 01062 doBuildParam( const std::string& name, 01063 const std::string& value ) 01064 { 01065 std::ostringstream strm; 01066 strm << "(" << name << " \"" << value << "\")"; 01067 M_stack.push( strm.str() ); 01068 01069 } 01070 01071 virtual 01072 void 01073 doBuildPlayerParam( int player_types, 01074 int subs_max, 01075 int pt_max, 01076 double player_speed_max_delta_min, 01077 double player_speed_max_delta_max, 01078 double stamina_inc_max_delta_factor, 01079 double player_decay_delta_min, 01080 double player_decay_delta_max, 01081 double inertia_moment_delta_factor, 01082 double dash_power_rate_delta_min, 01083 double dash_power_rate_delta_max, 01084 double player_size_delta_factor, 01085 double kickable_margin_delta_min, 01086 double kickable_margin_delta_max, 01087 double kick_rand_delta_factor, 01088 double extra_stamina_delta_min, 01089 double extra_stamina_delta_max, 01090 double effort_max_delta_factor, 01091 double effort_min_delta_factor ) 01092 { 01093 std::ostringstream strm; 01094 strm << "(player_param" 01095 << " " << player_types 01096 << " " << subs_max 01097 << " " << pt_max 01098 << " " << player_speed_max_delta_min 01099 << " " << player_speed_max_delta_max 01100 << " " << stamina_inc_max_delta_factor 01101 << " " << player_decay_delta_min 01102 << " " << player_decay_delta_max 01103 << " " << inertia_moment_delta_factor 01104 << " " << dash_power_rate_delta_min 01105 << " " << dash_power_rate_delta_max 01106 << " " << player_size_delta_factor 01107 << " " << kickable_margin_delta_min 01108 << " " << kickable_margin_delta_max 01109 << " " << kick_rand_delta_factor 01110 << " " << extra_stamina_delta_min 01111 << " " << extra_stamina_delta_max 01112 << " " << effort_max_delta_factor 01113 << " " << effort_min_delta_factor 01114 << ")"; 01115 M_stack.push( strm.str() ); 01116 01117 } 01118 01119 virtual 01120 void 01121 doBuildPlayerParam() 01122 { 01123 std::ostringstream strm; 01124 strm << "(player_param"; 01125 std::stack< std::string > params; 01126 while( !M_stack.empty() ) 01127 { 01128 params.push( M_stack.top() ); 01129 M_stack.pop(); 01130 } 01131 01132 while( !params.empty() ) 01133 { 01134 strm << " " << params.top(); 01135 params.pop(); 01136 } 01137 strm << ")"; 01138 M_stack.push( strm.str() ); 01139 01140 } 01141 01142 virtual 01143 void 01144 doBuildPlayerType ( int id, 01145 double player_speed_max, 01146 double stamina_inc_max, 01147 double player_decay, 01148 double inertia_moment, 01149 double dash_power_rate, 01150 double player_size, 01151 double kickable_margin, 01152 double kick_rand, 01153 double extra_stamina, 01154 double effort_max, 01155 double effort_min ) 01156 { 01157 std::ostringstream strm; 01158 strm << "(player_type" 01159 << " " << id 01160 << " " << player_speed_max 01161 << " " << stamina_inc_max 01162 << " " << player_decay 01163 << " " << inertia_moment 01164 << " " << dash_power_rate 01165 << " " << player_size 01166 << " " << kickable_margin 01167 << " " << kick_rand 01168 << " " << extra_stamina 01169 << " " << effort_max 01170 << " " << effort_min 01171 << ")"; 01172 M_stack.push( strm.str() ); 01173 01174 } 01175 01176 virtual 01177 void 01178 doBuildPlayerType() 01179 { 01180 std::ostringstream strm; 01181 strm << "(player_type"; 01182 std::stack< std::string > params; 01183 while( !M_stack.empty() ) 01184 { 01185 params.push( M_stack.top() ); 01186 M_stack.pop(); 01187 } 01188 01189 while( !params.empty() ) 01190 { 01191 strm << " " << params.top(); 01192 params.pop(); 01193 } 01194 strm << ")"; 01195 M_stack.push( strm.str() ); 01196 01197 } 01198 01199 virtual 01200 void 01201 doBuildVisual( int time ) 01202 { 01203 std::ostringstream strm; 01204 strm << "(see " << time; 01205 std::stack< std::string > objects; 01206 while( !M_stack.empty() 01207 && isFieldObj( M_stack.top() ) ) 01208 { 01209 objects.push( M_stack.top() ); 01210 M_stack.pop(); 01211 } 01212 01213 while( !objects.empty() ) 01214 { 01215 strm << " " << objects.top(); 01216 objects.pop(); 01217 } 01218 strm << ")"; 01219 M_stack.push( strm.str() ); 01220 01221 } 01222 01223 virtual 01224 void 01225 doBuildGlobalVisual( int time ) 01226 { 01227 std::ostringstream strm; 01228 strm << "(see_global " << time; 01229 std::stack< std::string > objects; 01230 while( !M_stack.empty() 01231 && isFieldObj( M_stack.top() ) ) 01232 { 01233 objects.push( M_stack.top() ); 01234 M_stack.pop(); 01235 } 01236 01237 while( !objects.empty() ) 01238 { 01239 strm << " " << objects.top(); 01240 objects.pop(); 01241 } 01242 strm << ")"; 01243 M_stack.push( strm.str() ); 01244 01245 } 01246 01247 virtual 01248 void 01249 doBuildLine( double dist, double dir ) 01250 { 01251 std::ostringstream strm; 01252 strm << "((l "; 01253 if( !M_stack.empty() ) 01254 { 01255 strm << M_stack.top(); 01256 M_stack.pop(); 01257 } 01258 strm << ") " << dist << " " << dir 01259 << ")"; 01260 M_stack.push( strm.str() ); 01261 01262 } 01263 01264 virtual 01265 void 01266 doBuildLine( double dir ) 01267 { 01268 std::ostringstream strm; 01269 strm << "((l "; 01270 if( !M_stack.empty() ) 01271 { 01272 strm << M_stack.top(); 01273 M_stack.pop(); 01274 } 01275 strm << ") " << dir 01276 << ")"; 01277 M_stack.push( strm.str() ); 01278 01279 } 01280 01281 virtual 01282 void 01283 doBuildTopLocation() 01284 { 01285 M_stack.push( "t" ); 01286 } 01287 01288 virtual 01289 void 01290 doBuildBottomLocation() 01291 { 01292 M_stack.push( "b" ); 01293 } 01294 01295 virtual 01296 void 01297 doBuildLeftLocation() 01298 { 01299 M_stack.push( "l" ); 01300 } 01301 01302 virtual 01303 void 01304 doBuildRightLocation() 01305 { 01306 M_stack.push( "r" ); 01307 } 01308 01309 virtual 01310 void 01311 doBuildCenterLocation() 01312 { 01313 M_stack.push( "c" ); 01314 } 01315 01316 virtual 01317 void 01318 doBuildPenaltyLocation() 01319 { 01320 M_stack.push( "p" ); 01321 } 01322 01323 virtual 01324 void 01325 doBuildGoalLocation() 01326 { 01327 M_stack.push( "g" ); 01328 } 01329 01330 virtual 01331 void 01332 doBuildFlagOffset( int offset ) 01333 { 01334 std::ostringstream strm; 01335 strm << offset; 01336 M_stack.push( strm.str() ); 01337 01338 } 01339 01340 virtual 01341 std::string 01342 doBuildFlagName( bool close ) 01343 { 01344 if( close ) 01345 return "(F)"; 01346 else 01347 { 01348 std::string rval = "(f"; 01349 std::stack< std::string > locs; 01350 while( !M_stack.empty() && isLocation( M_stack.top() ) ) 01351 { 01352 locs.push( M_stack.top() ); 01353 M_stack.pop(); 01354 } 01355 while( !locs.empty() ) 01356 { 01357 rval += " " + locs.top(); 01358 locs.pop(); 01359 } 01360 rval += ")"; 01361 return rval; 01362 } 01363 } 01364 01365 virtual 01366 std::string 01367 doBuildGoalName( bool close ) 01368 { 01369 if( close ) 01370 return "(G)"; 01371 else 01372 { 01373 std::string rval = "(g"; 01374 std::stack< std::string > locs; 01375 while( !M_stack.empty() && isLocation( M_stack.top() ) ) 01376 { 01377 locs.push( M_stack.top() ); 01378 M_stack.pop(); 01379 } 01380 while( !locs.empty() ) 01381 { 01382 rval += " " + locs.top(); 01383 locs.pop(); 01384 } 01385 rval += ")"; 01386 return rval; 01387 } 01388 } 01389 01390 virtual 01391 void 01392 doBuildFlag( bool close, 01393 double dist, double dir, 01394 double dist_chg, double dir_chg ) 01395 { 01396 std::ostringstream strm; 01397 strm << "(" << buildFlagName( close ) 01398 << " " << dist << " " << dir 01399 << " " << dist_chg << " " << dir_chg 01400 << ")"; 01401 M_stack.push( strm.str() ); 01402 01403 } 01404 01405 virtual 01406 void 01407 doBuildFlag( bool close, double dist, double dir ) 01408 { 01409 std::ostringstream strm; 01410 strm << "(" << buildFlagName( close ) 01411 << " " << dist << " " << dir 01412 << ")"; 01413 M_stack.push( strm.str() ); 01414 01415 } 01416 01417 virtual 01418 void 01419 doBuildFlag( bool close, double dir ) 01420 { 01421 std::ostringstream strm; 01422 strm << "(" << buildFlagName( close ) 01423 << " " << dir 01424 << ")"; 01425 M_stack.push( strm.str() ); 01426 01427 } 01428 01429 virtual 01430 void 01431 doBuildGoal( bool close, 01432 double dist, double dir, 01433 double dist_chg, double dir_chg ) 01434 { 01435 std::ostringstream strm; 01436 strm << "(" << buildGoalName( close ) 01437 << " " << dist << " " << dir 01438 << " " << dist_chg << " " << dir_chg 01439 << ")"; 01440 M_stack.push( strm.str() ); 01441 01442 } 01443 01444 virtual 01445 void 01446 doBuildGoal( bool close, double dist, double dir ) 01447 { 01448 std::ostringstream strm; 01449 strm << "(" << buildGoalName( close ) 01450 << " " << dist << " " << dir 01451 << ")"; 01452 M_stack.push( strm.str() ); 01453 01454 } 01455 01456 virtual 01457 void 01458 doBuildGoal( bool close, double dir ) 01459 { 01460 std::ostringstream strm; 01461 strm << "(" << buildGoalName( close ) 01462 << " " << dir 01463 << ")"; 01464 M_stack.push( strm.str() ); 01465 01466 } 01467 01468 virtual 01469 void 01470 doBuildGlobalGoal( double x, double y ) 01471 { 01472 std::ostringstream strm; 01473 strm << "(" << buildGoalName( false ) 01474 << " " << x << " " << y 01475 << ")"; 01476 M_stack.push( strm.str() ); 01477 01478 } 01479 01480 virtual 01481 void 01482 doBuildBall( bool close, 01483 double dist, double dir, 01484 double dist_chg, double dir_chg ) 01485 { 01486 std::ostringstream strm; 01487 if( close ) 01488 strm << "((B) "; 01489 else 01490 strm << "((b) "; 01491 strm << dist << " " << dir 01492 << " " << dist_chg << " " << dir_chg 01493 << ")"; 01494 M_stack.push( strm.str() ); 01495 01496 } 01497 01498 virtual 01499 void 01500 doBuildBall( bool close, double dist, double dir ) 01501 { 01502 std::ostringstream strm; 01503 if( close ) 01504 strm << "((B) "; 01505 else 01506 strm << "((b) "; 01507 strm << dist << " " << dir 01508 << ")"; 01509 M_stack.push( strm.str() ); 01510 01511 } 01512 01513 virtual 01514 void 01515 doBuildBall( bool close, double dir ) 01516 { 01517 std::ostringstream strm; 01518 if( close ) 01519 strm << "((B) "; 01520 else 01521 strm << "((b) "; 01522 strm << dir 01523 << ")"; 01524 M_stack.push( strm.str() ); 01525 01526 } 01527 01528 virtual 01529 void 01530 doBuildGlobalBall( double x, double y, 01531 double delta_x, double delta_y ) 01532 { 01533 std::ostringstream strm; 01534 strm << "((b) " << x << " " << y 01535 << " " << delta_x << " " << delta_y 01536 << ")"; 01537 M_stack.push( strm.str() ); 01538 01539 } 01540 01541 virtual 01542 void 01543 doBuildPlayerName( std::ostream& strm, bool close, bool ) 01544 { 01545 if( close ) 01546 strm << "(P)"; 01547 else 01548 { 01549 std::string team_name; 01550 int unum = -1; 01551 bool goalie = false; 01552 if( !M_stack.empty() && M_stack.top() == "g" ) 01553 { 01554 goalie = true; 01555 M_stack.pop(); 01556 } 01557 if( !M_stack.empty() ) 01558 { 01559 std::istringstream in( M_stack.top() ); 01560 in >> unum; 01561 if( unum != -1 ) 01562 M_stack.pop(); 01563 } 01564 if( !M_stack.empty() 01565 && !M_stack.top().empty() 01566 && M_stack.top()[ 0 ] == '"' ) 01567 { 01568 team_name = M_stack.top(); 01569 M_stack.pop(); 01570 } 01571 strm << "(p"; 01572 if( !team_name.empty() ) 01573 strm << " " << team_name; 01574 if( unum != -1 ) 01575 strm << " " << unum; 01576 if( goalie ) 01577 { 01578 strm << " goalie"; 01579 } 01580 strm << ")"; 01581 } 01582 } 01583 01584 virtual 01585 void 01586 doBuildPlayer( bool close, 01587 double dist, double dir, 01588 double dist_chg, double dir_chg, 01589 double orientation, double head_orientation ) 01590 { 01591 std::ostringstream strm; 01592 strm << "("; 01593 buildPlayerName( strm, close, true ); 01594 strm << " " << dist << " " << dir 01595 << " " << dist_chg << " " << dir_chg 01596 << " " << orientation << " " << head_orientation 01597 << ")"; 01598 M_stack.push( strm.str() ); 01599 01600 } 01601 01602 virtual 01603 void 01604 doBuildPlayer( bool close, 01605 double dist, double dir, 01606 double dist_chg, double dir_chg ) 01607 { 01608 std::ostringstream strm; 01609 strm << "("; 01610 buildPlayerName( strm, close, false ); 01611 strm << " " << dist << " " << dir 01612 << " " << dist_chg << " " << dir_chg 01613 << ")"; 01614 M_stack.push( strm.str() ); 01615 01616 } 01617 01618 virtual 01619 void 01620 doBuildPlayer( bool close, double dist, double dir ) 01621 { 01622 std::ostringstream strm; 01623 strm << "("; 01624 buildPlayerName( strm, close, false ); 01625 strm << " " << dist << " " << dir 01626 << ")"; 01627 M_stack.push( strm.str() ); 01628 01629 } 01630 01631 virtual 01632 void 01633 doBuildPlayer( bool close, double dir ) 01634 { 01635 std::ostringstream strm; 01636 strm << "("; 01637 buildPlayerName( strm, close, false ); 01638 strm << " " << dir 01639 << ")"; 01640 M_stack.push( strm.str() ); 01641 01642 } 01643 01644 virtual 01645 void 01646 doBuildGlobalPlayer( double x, double y, 01647 double delta_x, double delta_y, 01648 double orientation, double head_orientation ) 01649 { 01650 std::ostringstream strm; 01651 strm << "("; 01652 buildPlayerName( strm, false, true ); 01653 strm << " " << x << " " << y 01654 << " " << delta_x << " " << delta_y 01655 << " " << orientation << " " << head_orientation 01656 << ")"; 01657 M_stack.push( strm.str() ); 01658 01659 } 01660 01661 virtual 01662 void 01663 doBuildTeamName( const std::string& name ) 01664 { 01665 std::ostringstream strm; 01666 strm << "\"" << name << "\""; 01667 M_stack.push( strm.str() ); 01668 01669 } 01670 01671 virtual 01672 void 01673 doBuildUNum( int unum ) 01674 { 01675 std::ostringstream strm; 01676 strm << unum; 01677 M_stack.push( strm.str() ); 01678 01679 } 01680 01681 virtual 01682 void 01683 doBuildGoalie() 01684 { 01685 M_stack.push( "g" ); 01686 } 01687 01688 virtual 01689 void 01690 doBuildScore( int time, int our, int opp ) 01691 { 01692 std::ostringstream strm; 01693 strm << "(score " << time 01694 << " " << our << " " << opp << ")"; 01695 M_stack.push( strm.str() ); 01696 01697 } 01698 01699 virtual 01700 void 01701 doBuildInit( int unum ) 01702 { 01703 std::ostringstream strm; 01704 std::string play_mode; 01705 std::string side; 01706 if( !M_stack.empty() ) 01707 { 01708 play_mode = M_stack.top(); 01709 M_stack.pop(); 01710 } 01711 if( !M_stack.empty() ) 01712 { 01713 side = M_stack.top(); 01714 M_stack.pop(); 01715 } 01716 strm << "(init " << side << " " << unum << " " 01717 << play_mode << ")"; 01718 M_stack.push( strm.str() ); 01719 01720 } 01721 01722 virtual 01723 void 01724 doBuildInit() 01725 { 01726 std::ostringstream strm; 01727 std::string play_mode; 01728 std::string side; 01729 if( !M_stack.empty() ) 01730 { 01731 play_mode = M_stack.top(); 01732 M_stack.pop(); 01733 } 01734 if( !M_stack.empty() ) 01735 { 01736 side = M_stack.top(); 01737 M_stack.pop(); 01738 } 01739 strm << "(reconnect " << side << " " 01740 << play_mode << ")"; 01741 M_stack.push( strm.str() ); 01742 01743 } 01744 01745 virtual 01746 void 01747 doBuildCoachInit() 01748 { 01749 std::ostringstream strm; 01750 std::string side; 01751 if( !M_stack.empty() ) 01752 { 01753 side = M_stack.top(); 01754 M_stack.pop(); 01755 } 01756 strm << "(init " << side << " " 01757 << "ok)"; 01758 M_stack.push( strm.str() ); 01759 01760 } 01761 01762 virtual 01763 void 01764 doBuildCoachAudio( int time, const std::string& msg ) 01765 { 01766 std::ostringstream strm; 01767 std::string name; 01768 if( !M_stack.empty() ) 01769 { 01770 if( M_stack.top() == "l" ) 01771 name = "online_coach_left"; 01772 else if( M_stack.top() == "r" ) 01773 name = "online_coach_right"; 01774 else 01775 name = "coach"; 01776 } 01777 strm << "(hear " << time << " " << name 01778 << " \"" << msg << "\")"; 01779 M_stack.push( strm.str() ); 01780 01781 } 01782 01783 virtual 01784 void 01785 doBuildRefAudio( int time ) 01786 { 01787 std::ostringstream strm; 01788 std::string play_mode; 01789 if( !M_stack.empty() ) 01790 { 01791 play_mode = M_stack.top(); 01792 M_stack.pop(); 01793 } 01794 strm << "(hear " << time << " referee " 01795 << play_mode << ")"; 01796 M_stack.push( strm.str() ); 01797 01798 } 01799 01800 virtual 01801 void 01802 doBuildGoalRefAudio( int time, int score ) 01803 { 01804 std::ostringstream strm; 01805 std::string side; 01806 if( !M_stack.empty() ) 01807 { 01808 side = M_stack.top(); 01809 M_stack.pop(); 01810 } 01811 strm << "(hear " << time << " referee goal_" 01812 << side << "_" << score << ")"; 01813 M_stack.push( strm.str() ); 01814 01815 } 01816 01817 virtual 01818 void 01819 doBuildUnknownRefAudio( int time, const std::string& message ) 01820 { 01821 std::ostringstream strm; 01822 strm << "(hear " << time << " referee " 01823 << message << ")"; 01824 M_stack.push( strm.str() ); 01825 01826 } 01827 01828 virtual 01829 void 01830 doBuildPlayerAudio( int time, double dir, const std::string& msg ) 01831 { 01832 std::ostringstream strm; 01833 std::string side; 01834 if( !M_stack.empty() 01835 && M_stack.top().size() > 0 01836 && M_stack.top()[ 0 ] == 'o') 01837 { side = M_stack.top(); M_stack.pop(); } 01838 strm << "(hear " << time << " " << dir; 01839 if( !side.empty() ) 01840 strm << " " << side; 01841 strm << " \"" << msg << "\")"; 01842 M_stack.push( strm.str() ); 01843 01844 } 01845 01846 virtual 01847 void 01848 doBuildPlayerAudio( int time, const std::string& msg ) 01849 { 01850 std::ostringstream strm; 01851 strm << "(hear " << time << " "; 01852 buildPlayerName( strm, false, false ); 01853 strm << " \"" << msg << "\")"; 01854 M_stack.push( strm.str() ); 01855 01856 } 01857 01858 virtual 01859 void 01860 doBuildPlayerAudio( int time, double dir, int unum, 01861 const std::string& msg ) 01862 { 01863 std::ostringstream strm; 01864 std::string side; 01865 if( !M_stack.empty() 01866 && M_stack.top().size() > 0 01867 && M_stack.top()[ 0 ] == 'o') 01868 { side = M_stack.top(); M_stack.pop(); } 01869 strm << "(hear " << time << " " << dir 01870 << " " << side << " " << unum 01871 << " \"" << msg << "\")"; 01872 M_stack.push( strm.str() ); 01873 01874 } 01875 01876 virtual 01877 void 01878 doBuildSelfAudio( int time, const std::string& msg ) 01879 { 01880 std::ostringstream strm; 01881 strm << "(hear " << time << " self \"" << msg << "\")"; 01882 M_stack.push( strm.str() ); 01883 01884 } 01885 01886 virtual 01887 void 01888 doBuildSubstitution( int unum, int type ) 01889 { 01890 std::ostringstream strm; 01891 strm << "(change_player_type " << unum << " " << type << ")"; 01892 M_stack.push( strm.str() ); 01893 01894 } 01895 01896 virtual 01897 void 01898 doBuildSubstitution( int unum ) 01899 { 01900 std::ostringstream strm; 01901 strm << "(change_player_type " << unum << ")"; 01902 M_stack.push( strm.str() ); 01903 01904 } 01905 01906 virtual 01907 void 01908 doBuildCantReconnect() 01909 { 01910 } 01911 01912 virtual 01913 void 01914 doBuildInitError() 01915 { 01916 } 01917 01918 virtual 01919 void 01920 doBuildNoMoreTeamOrPlayerOrGoalieError() 01921 { 01922 } 01923 01924 virtual 01925 void 01926 doBuildNoSuchTeamOrAlreadyHaveCoachError() 01927 { 01928 } 01929 01930 virtual 01931 void 01932 doBuildTooManyMovesError() 01933 { 01934 } 01935 01936 virtual 01937 void 01938 doBuildUnknownCommandError() 01939 { 01940 } 01941 01942 virtual 01943 void 01944 doBuildIllegalCommandError() 01945 { 01946 M_stack.push( "(error illegal_command_form)" ); 01947 } 01948 01949 virtual 01950 void 01951 doBuildSayMessageTooLongError() 01952 { 01953 } 01954 01955 virtual 01956 void 01957 doBuildIllegalModeError() 01958 { 01959 } 01960 01961 virtual 01962 void 01963 doBuildIllegalObjectFormError() 01964 { 01965 } 01966 01967 virtual 01968 void 01969 doBuildSaidTooManyFreeformMessagesError() 01970 { 01971 } 01972 01973 virtual 01974 void 01975 doBuildCannotSayFreeformWhilePlayonError() 01976 { 01977 } 01978 01979 virtual 01980 void 01981 doBuildSaidTooManyMetaMessagesError() 01982 { 01983 } 01984 01985 virtual 01986 void 01987 doBuildSaidTooManyAdviceMessagesError() 01988 { 01989 } 01990 01991 virtual 01992 void 01993 doBuildSaidTooManyInfoMessagesError() 01994 { 01995 } 01996 01997 virtual 01998 void 01999 doBuildSaidTooManyDefineMessagesError() 02000 { 02001 } 02002 02003 virtual 02004 void 02005 doBuildCouldNotParseSayError() 02006 { 02007 } 02008 02009 virtual 02010 void 02011 doBuildSaidTooManyMessagesError() 02012 { 02013 } 02014 02015 virtual 02016 void 02017 doBuildUnknownError( const std::string& error ) 02018 { 02019 } 02020 02021 virtual 02022 void 02023 doBuildNoTeamFoundWarning() 02024 { 02025 } 02026 02027 virtual 02028 void 02029 doBuildNoSuchPlayerWarning() 02030 { 02031 } 02032 02033 virtual 02034 void 02035 doBuildCannotSubWhilePlayOnWarning() 02036 { 02037 } 02038 02039 virtual 02040 void 02041 doBuildNoSubsLeftWarning() 02042 { 02043 } 02044 02045 virtual 02046 void 02047 doBuildMaxOfThatPlayerTypeOnFieldWarning() 02048 { 02049 } 02050 02051 virtual 02052 void 02053 doBuildCannotChangeGoalieWarning() 02054 { 02055 } 02056 02057 virtual 02058 void 02059 doBuildUnknownWarning( const std::string& warning ) 02060 { 02061 } 02062 02063 02064 virtual 02065 void 02066 doBuildClangVerOK( int min, int max ) 02067 { 02068 } 02069 02070 virtual 02071 void 02072 doBuildEyeOK( bool on ) 02073 { 02074 std::ostringstream strm; 02075 strm << "(ok eye " << ( on ? "on" : "off" ) << ")"; 02076 M_stack.push( strm.str() ); 02077 02078 } 02079 02080 virtual 02081 void 02082 doBuildChangePlayerTypeOK( int unum, int type ) 02083 { 02084 std::ostringstream strm; 02085 strm << "(ok change_player_type " 02086 << unum << " " << type 02087 << ")"; 02088 M_stack.push( strm.str() ); 02089 02090 } 02091 02092 virtual 02093 void 02094 doBuildUnknownOK( const std::string& msg ) 02095 { 02096 } 02097 }; 02098 02099 std::pair< int, int > 02100 diff( const std::string& a, const std::string& b ) 02101 { 02102 std::pair< int, int > rval( -1, -1 ); 02103 02104 if( a == b ) 02105 return rval; 02106 02107 if( !a.empty() && !b.empty() 02108 && a[ 0 ] == b [ 0 ] ) 02109 { 02110 rval = diff( a.substr( 1 ), b.substr( 1 ) ); 02111 if( rval.first != -1 ) 02112 ++( rval.first ); 02113 if( rval.second != -1 ) 02114 ++( rval.second ); 02115 return rval; 02116 } 02117 else if( a.size() > 1 && !b.empty() 02118 && a[ 0 ] == '-' && a[ 1 ] == '0' && b[ 0 ] == '0' ) 02119 { 02120 rval = diff( a.substr( 1 ), b ); 02121 if( rval.first != -1 ) 02122 ++( rval.first ); 02123 return rval; 02124 } 02125 else if( b.size() > 1 && !a.empty() 02126 && b[ 0 ] == '-' && b[ 1 ] == '0' && a[ 0 ] == '0' ) 02127 { 02128 rval = diff( a, b.substr( 1 ) ); 02129 if( rval.second != -1 ) 02130 ++( rval.second ); 02131 return rval; 02132 } 02133 else if( !a.empty() && a[ 0 ] == ' ' ) 02134 { 02135 rval = diff( a.substr( 1 ), b ); 02136 if( rval.first != -1 ) 02137 ++( rval.first ); 02138 return rval; 02139 } 02140 else if( !b.empty() && b[ 0 ] == ' ' ) 02141 { 02142 rval = diff( a, b.substr( 1 ) ); 02143 if( rval.second != -1 ) 02144 ++( rval.second ); 02145 return rval; 02146 } 02147 else if( a.size() > 2 && a[ 0 ] == '.' && a[ 1 ] == '0' 02148 && ( a[ 2 ] == ' ' || a[ 2 ] == ')' ) ) 02149 { 02150 rval = diff( a.substr( 2 ), b ); 02151 if( rval.first != -1 ) 02152 rval.first += 2; 02153 return rval; 02154 } 02155 else if( b.size() > 2 && b[ 0 ] == '.' && b[ 1 ] == '0' 02156 && ( b[ 2 ] == ' ' || b[ 2 ] == ')' ) ) 02157 { 02158 rval = diff( a, b.substr( 2 ) ); 02159 if( rval.second != -1 ) 02160 rval.second += 2; 02161 return rval; 02162 } 02163 else 02164 { 02165 rval.first = rval.second = 0; 02166 return rval; 02167 } 02168 } 02169 02170 02171 int main() 02172 { 02173 int rval = 0; 02174 #ifndef HAVE_LIBRCSSCLANGPARSER 02175 CLangParser clang_parser; 02176 #else 02177 rcss::clang::MsgBuilder builder; 02178 rcss::clang::Parser clang_parser( builder ); 02179 #endif 02180 TestParser parser( clang_parser ); 02181 02182 while( std::cin.good() ) 02183 { 02184 std::string line; 02185 std::getline( std::cin, line ); 02186 if( line.empty() ) 02187 continue; 02188 02189 std::istringstream strm( line ); 02190 if( parser.parse( strm ) ) 02191 { 02192 std::string parsed_data; 02193 #ifdef HAVE_LIBRCSSCLANGPARSER 02194 if( !parser.getString().empty() || builder.getMsg() == NULL ) 02195 #endif 02196 parsed_data = parser.getString(); 02197 #ifdef HAVE_LIBRCSSCLANGPARSER 02198 else 02199 { 02200 std::ostringstream clang_strm; 02201 rcss::clang::Msg& msg = *( builder.getMsg() ); 02202 clang_strm << "(hear " << msg.getTimeSend(); 02203 if( msg.getSide() == 1 ) 02204 clang_strm << " online_coach_left "; 02205 else 02206 clang_strm << " online_coach_right "; 02207 clang_strm << msg.getTimeRecv() << " " << msg << ")"; 02208 parsed_data = clang_strm.str(); 02209 } 02210 #endif 02211 std::pair< int, int > diff_pos = diff( line, parsed_data ); 02212 if( diff_pos.first != -1 && diff_pos.second != -1 ) 02213 { 02214 std::cerr << "Input and parsed output differ\n"; 02215 std::cerr << "Input >" << line << "<\n"; 02216 std::cerr << "Output>" << parsed_data << "<\n"; 02217 std::cerr << "Input differs at >" 02218 << line.substr( diff_pos.first ) << "<\n"; 02219 std::cerr << "From output at >" 02220 << parsed_data.substr( diff_pos.second ) << "<\n"; 02221 rval = -1; 02222 } 02223 parser.clear(); 02224 } 02225 else 02226 { 02227 std::cerr << "Error: Could not parse >" << line << "<\n"; 02228 rval = -1; 02229 } 02230 } 02231 02232 return rval; 02233 } |
©2001-2003 Tom Howard. All Rights Reserved.
Suggestions? Email the Webmaster!