soccertypes_8c-source.html

来自「仿真人工智能是指用人工的方法和技术」· HTML 代码 · 共 627 行 · 第 1/5 页

HTML
627
字号
00415 <a name="l00423"></a><a class="code" href="SoccerTypes_8C.html#a1">00423</a> ostream&amp; <a class="code" href="SoccerTypes_8C.html#a1">operator &lt;&lt;</a>( ostream &amp;os, <a class="code" href="classTime.html">Time</a> t )00424 {00425   <font class="keywordflow">return</font> os &lt;&lt; <font class="stringliteral">"("</font> &lt;&lt; t.<a class="code" href="classTime.html#a3">getTime</a>() &lt;&lt; <font class="stringliteral">","</font> &lt;&lt; t.<a class="code" href="classTime.html#a4">getTimeStopped</a>() &lt;&lt; <font class="stringliteral">")"</font>;00426 }00427 00428 <font class="comment">/******************************************************************************/</font>00429 <font class="comment">/********************** CLASS SOCCERCOMMAND ***********************************/</font>00430 <font class="comment">/******************************************************************************/</font>00431 00432 <a name="l00442"></a><a class="code" href="classSoccerCommand.html#a0">00442</a> <a class="code" href="classSoccerCommand.html#a0">SoccerCommand::SoccerCommand</a>( <a class="code" href="SoccerTypes_8h.html#a247">CommandT</a> com, <font class="keywordtype">double</font> d1, <font class="keywordtype">double</font> d2, <font class="keywordtype">double</font> d3 )00443 {00444   <font class="comment">// first initialize variables</font>00445   <a class="code" href="classSoccerCommand.html#m1">commandType</a> = com;00446   <a class="code" href="classSoccerCommand.html#m3">dPower</a>      = <a class="code" href="SoccerTypes_8h.html#a19">UnknownDoubleValue</a>;00447   <a class="code" href="classSoccerCommand.html#m2">dAngle</a>      = <a class="code" href="SoccerTypes_8h.html#a19">UnknownDoubleValue</a>;00448   <a class="code" href="classSoccerCommand.html#m5">va</a>          = <a class="code" href="SoccerTypes_8h.html#a244a173">VA_ILLEGAL</a>;00449   <a class="code" href="classSoccerCommand.html#m4">vq</a>          = <a class="code" href="SoccerTypes_8h.html#a245a176">VQ_ILLEGAL</a>;00450   <a class="code" href="classSoccerCommand.html#m9">iTimes</a>      = 1;00451   strcpy( <a class="code" href="classSoccerCommand.html#m8">str</a>, <font class="stringliteral">"\0"</font> );00452   <font class="keywordflow">if</font>( com == <a class="code" href="SoccerTypes_8h.html#a247a184">CMD_CHANGEVIEW</a> )00453     <a class="code" href="classSoccerCommand.html#a2">makeCommand</a>( <a class="code" href="classSoccerCommand.html#m1">commandType</a>, (<a class="code" href="SoccerTypes_8h.html#a244">ViewAngleT</a>)d1, (<a class="code" href="SoccerTypes_8h.html#a245">ViewQualityT</a>)d2 );00454   <font class="keywordflow">else</font> <font class="keywordflow">if</font>( com != <a class="code" href="SoccerTypes_8h.html#a247a189">CMD_SAY</a> )00455     <a class="code" href="classSoccerCommand.html#a2">makeCommand</a>( <a class="code" href="classSoccerCommand.html#m1">commandType</a>, d1, d2, d3 );00456 }00457 <a name="l00462"></a><a class="code" href="classSoccerCommand.html#a1">00462</a> <a class="code" href="classSoccerCommand.html#a0">SoccerCommand::SoccerCommand</a>( <a class="code" href="SoccerTypes_8h.html#a247">CommandT</a> com, <font class="keywordtype">char</font> *msg )00463 {00464   <a class="code" href="classSoccerCommand.html#a2">makeCommand</a>( com, msg )  ;00465 }00466 <a name="l00483"></a><a class="code" href="classSoccerCommand.html#a2">00483</a> <font class="keywordtype">void</font> <a class="code" href="classSoccerCommand.html#a2">SoccerCommand::makeCommand</a>( <a class="code" href="SoccerTypes_8h.html#a247">CommandT</a> com, <font class="keywordtype">double</font> d1, <font class="keywordtype">double</font> d2, <font class="keywordtype">double</font> d3 )00484 {00485   <font class="comment">// set the variables that have a meaning for the specified command type</font>00486   <a class="code" href="classSoccerCommand.html#m1">commandType</a> = com;00487   <font class="keywordflow">if</font>( com == <a class="code" href="SoccerTypes_8h.html#a247a182">CMD_TURN</a> || com == <a class="code" href="SoccerTypes_8h.html#a247a183">CMD_TURNNECK</a> )00488     <a class="code" href="classSoccerCommand.html#m2">dAngle</a> = d1;00489   <font class="keywordflow">else</font> <font class="keywordflow">if</font>( com == <a class="code" href="SoccerTypes_8h.html#a247a181">CMD_DASH</a> )00490     <a class="code" href="classSoccerCommand.html#m3">dPower</a> = d1;00491   <font class="keywordflow">else</font> <font class="keywordflow">if</font>( com == <a class="code" href="SoccerTypes_8h.html#a247a186">CMD_KICK</a> )00492   {00493     <a class="code" href="classSoccerCommand.html#m3">dPower</a> = d1;00494     <a class="code" href="classSoccerCommand.html#m2">dAngle</a> = d2;00495   }00496   <font class="keywordflow">else</font> <font class="keywordflow">if</font>( com == <a class="code" href="SoccerTypes_8h.html#a247a187">CMD_MOVE</a> )00497   {00498     <a class="code" href="classSoccerCommand.html#m6">dX</a> = d1;00499     <a class="code" href="classSoccerCommand.html#m7">dY</a> = d2;00500     <font class="keywordflow">if</font>( d3 != <a class="code" href="SoccerTypes_8h.html#a19">UnknownDoubleValue</a> )00501       <a class="code" href="classSoccerCommand.html#m2">dAngle</a> = d3;00502     <font class="keywordflow">else</font>00503       <a class="code" href="classSoccerCommand.html#m2">dAngle</a> = 0;00504   }00505   <font class="keywordflow">else</font> <font class="keywordflow">if</font>( com == <a class="code" href="SoccerTypes_8h.html#a247a185">CMD_CATCH</a> )00506     <a class="code" href="classSoccerCommand.html#m2">dAngle</a> = d1;00507   <font class="keywordflow">else</font> <font class="keywordflow">if</font>( com == <a class="code" href="SoccerTypes_8h.html#a247a190">CMD_CHANGEPLAYER</a> )00508   {00509     <a class="code" href="classSoccerCommand.html#m6">dX</a> = d1;00510     <a class="code" href="classSoccerCommand.html#m7">dY</a> = d2;00511   }00512 }00513 <a name="l00518"></a><a class="code" href="classSoccerCommand.html#a3">00518</a> <font class="keywordtype">void</font> <a class="code" href="classSoccerCommand.html#a2">SoccerCommand::makeCommand</a>( <a class="code" href="SoccerTypes_8h.html#a247">CommandT</a> com, <a class="code" href="SoccerTypes_8h.html#a244">ViewAngleT</a> v, <a class="code" href="SoccerTypes_8h.html#a245">ViewQualityT</a> q )00519 {00520   <a class="code" href="classSoccerCommand.html#m1">commandType</a> = com;00521   <font class="keywordflow">if</font>( com == <a class="code" href="SoccerTypes_8h.html#a247a184">CMD_CHANGEVIEW</a> )00522   {00523     <a class="code" href="classSoccerCommand.html#m5">va</a> = (ViewAngleT)  v;00524     <a class="code" href="classSoccerCommand.html#m4">vq</a> = (ViewQualityT)q;00525   }00526 }00527 <a name="l00532"></a><a class="code" href="classSoccerCommand.html#a4">00532</a> <font class="keywordtype">void</font> <a class="code" href="classSoccerCommand.html#a2">SoccerCommand::makeCommand</a>( <a class="code" href="SoccerTypes_8h.html#a247">CommandT</a> com, <font class="keywordtype">char</font>* msg )00533 {00534   <a class="code" href="classSoccerCommand.html#m1">commandType</a> = com;00535   <font class="keywordflow">if</font>( com == <a class="code" href="SoccerTypes_8h.html#a247a189">CMD_SAY</a> )00536      strcpy( <a class="code" href="classSoccerCommand.html#m8">str</a>, msg );00537 }00538 <a name="l00541"></a><a class="code" href="classSoccerCommand.html#a6">00541</a> <font class="keywordtype">void</font> <a class="code" href="classSoccerCommand.html#a6">SoccerCommand::show</a>( ostream&amp; os )00542 {00543   os &lt;&lt; <font class="stringliteral">"time: "</font> &lt;&lt; <a class="code" href="classSoccerCommand.html#m0">time</a> &lt;&lt; <font class="stringliteral">" "</font>; <font class="comment">// can be illegal when not yet set in WM.</font>00544   <font class="keywordflow">switch</font>( commandType )00545   {00546     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a180">CMD_ILLEGAL</a>:00547       os &lt;&lt; <font class="stringliteral">"illegal\n"</font> ;00548       <font class="keywordflow">break</font>;00549     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a181">CMD_DASH</a>:00550       os &lt;&lt; <font class="stringliteral">"dash "</font> &lt;&lt; <a class="code" href="classSoccerCommand.html#m3">dPower</a> &lt;&lt; <font class="stringliteral">" times: "</font> &lt;&lt; <a class="code" href="classSoccerCommand.html#m9">iTimes</a> &lt;&lt; endl;00551       <font class="keywordflow">break</font>;00552     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a182">CMD_TURN</a>:00553     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a183">CMD_TURNNECK</a>:00554       <font class="keywordflow">if</font>( <a class="code" href="classSoccerCommand.html#m1">commandType</a> == <a class="code" href="SoccerTypes_8h.html#a247a182">CMD_TURN</a> )00555         os &lt;&lt; <font class="stringliteral">"turn "</font> &lt;&lt; <a class="code" href="classSoccerCommand.html#m2">dAngle</a> &lt;&lt; endl;00556       <font class="keywordflow">else</font>00557         os &lt;&lt; <font class="stringliteral">"turn_neck "</font> &lt;&lt; <font class="stringliteral">" "</font> &lt;&lt; <a class="code" href="classSoccerCommand.html#m2">dAngle</a> &lt;&lt; endl;00558       <font class="keywordflow">break</font>;00559      <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a184">CMD_CHANGEVIEW</a>:00560       os &lt;&lt; <font class="stringliteral">"change_view "</font> &lt;&lt;00561               <a class="code" href="classSoccerTypes.html#d24">SoccerTypes::getViewAngleStr</a>( <a class="code" href="classSoccerCommand.html#m5">va</a> ) &lt;&lt; <font class="stringliteral">" "</font> &lt;&lt;00562               <a class="code" href="classSoccerTypes.html#d27">SoccerTypes::getViewQualityStr</a>( <a class="code" href="classSoccerCommand.html#m4">vq</a> ) &lt;&lt; endl;00563       <font class="keywordflow">break</font>;00564     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a185">CMD_CATCH</a>:00565       os &lt;&lt; <font class="stringliteral">"catch "</font> &lt;&lt; <a class="code" href="classSoccerCommand.html#m2">dAngle</a> &lt;&lt; endl;00566       <font class="keywordflow">break</font>;00567     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a186">CMD_KICK</a>:00568       os &lt;&lt; <font class="stringliteral">"kick "</font> &lt;&lt; <a class="code" href="classSoccerCommand.html#m3">dPower</a> &lt;&lt; <font class="stringliteral">" "</font> &lt;&lt; <a class="code" href="classSoccerCommand.html#m2">dAngle</a> &lt;&lt; endl;00569       <font class="keywordflow">break</font>;00570     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a187">CMD_MOVE</a>:00571       os &lt;&lt; <font class="stringliteral">"move "</font> &lt;&lt; <a class="code" href="classSoccerCommand.html#m6">dX</a> &lt;&lt; <font class="stringliteral">" "</font> &lt;&lt; <a class="code" href="classSoccerCommand.html#m7">dY</a> &lt;&lt; <font class="stringliteral">" "</font> &lt;&lt; <a class="code" href="classSoccerCommand.html#m2">dAngle</a> &lt;&lt; endl;00572       <font class="keywordflow">break</font>;00573     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a188">CMD_SENSEBODY</a>:00574       os &lt;&lt; <font class="stringliteral">"sense_body"</font> &lt;&lt; endl;00575       <font class="keywordflow">break</font>;00576     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a189">CMD_SAY</a>:00577       os &lt;&lt; <font class="stringliteral">"say "</font> &lt;&lt; <a class="code" href="classSoccerCommand.html#m8">str</a> &lt;&lt; endl;00578       <font class="keywordflow">break</font>;00579     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a190">CMD_CHANGEPLAYER</a>:00580       os &lt;&lt; <font class="stringliteral">"change_player "</font> &lt;&lt; (int)<a class="code" href="classSoccerCommand.html#m6">dX</a> &lt;&lt; <font class="stringliteral">" "</font> &lt;&lt; (int)<a class="code" href="classSoccerCommand.html#m7">dY</a> &lt;&lt; endl;00581       <font class="keywordflow">break</font>;00582     <font class="keywordflow">default</font>:00583       os &lt;&lt; <font class="stringliteral">"unknown"</font> &lt;&lt; endl;00584       <font class="keywordflow">break</font>;00585   }00586 }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?