player_8c-source.html
来自「仿真人工智能是指用人工的方法和技术」· HTML 代码 · 共 545 行 · 第 1/5 页
HTML
545 行
00252 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( soc ); <font class="comment">// move to strategic pos</font>00253 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( <a class="code" href="classBasicPlayer.html#b13">turnNeckToObject</a>( <a class="code" href="SoccerTypes_8h.html#a240a24">OBJECT_BALL</a>, soc ) );00254 }00255 <font class="keywordflow">else</font> <font class="comment">// else watch ball</font>00256 {00257 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( soc = <a class="code" href="classBasicPlayer.html#b12">turnBodyToObject</a>( <a class="code" href="SoccerTypes_8h.html#a240a24">OBJECT_BALL</a> ) );00258 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( <a class="code" href="classBasicPlayer.html#b13">turnNeckToObject</a>( <a class="code" href="SoccerTypes_8h.html#a240a24">OBJECT_BALL</a>, soc ) );00259 }00260 }00261 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( fabs( <a class="code" href="classBasicPlayer.html#n1">WM</a>-><a class="code" href="classWorldModel.html#a56">getRelativeAngle</a>( <a class="code" href="SoccerTypes_8h.html#a240a24">OBJECT_BALL</a> ) ) > 1.0 ) <font class="comment">// watch ball</font>00262 {00263 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( soc = <a class="code" href="classBasicPlayer.html#b12">turnBodyToObject</a>( <a class="code" href="SoccerTypes_8h.html#a240a24">OBJECT_BALL</a> ) );00264 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( <a class="code" href="classBasicPlayer.html#b13">turnNeckToObject</a>( <a class="code" href="SoccerTypes_8h.html#a240a24">OBJECT_BALL</a>, soc ) );00265 }00266 <font class="keywordflow">else</font> <font class="comment">// nothing to do</font>00267 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( <a class="code" href="classSoccerCommand.html">SoccerCommand</a>(<a class="code" href="SoccerTypes_8h.html#a247a183">CMD_TURNNECK</a>,0.0) );00268 }00269 }00270 00271 <a name="l00278"></a><a class="code" href="classPlayer.html#a4">00278</a> <font class="keywordtype">void</font> <a class="code" href="classPlayer.html#a4">Player::deMeer5_goalie</a>( )00279 {00280 <font class="keywordtype">int</font> i;00281 <a class="code" href="classSoccerCommand.html">SoccerCommand</a> soc;00282 <a class="code" href="classVecPosition.html">VecPosition</a> posAgent = <a class="code" href="classBasicPlayer.html#n1">WM</a>-><a class="code" href="classWorldModel.html#a43">getAgentGlobalPosition</a>();00283 <a class="code" href="Geometry_8h.html#a2">AngDeg</a> angBody = <a class="code" href="classBasicPlayer.html#n1">WM</a>-><a class="code" href="classWorldModel.html#a38">getAgentGlobalBodyAngle</a>();00284 00285 <font class="comment">// define the top and bottom position of a rectangle in which keeper moves</font>00286 <font class="keyword">static</font> <font class="keyword">const</font> <a class="code" href="classVecPosition.html">VecPosition</a> posLeftTop( -<a class="code" href="SoccerTypes_8h.html#a13">PITCH_LENGTH</a>/2.0 +00287 0.7*<a class="code" href="SoccerTypes_8h.html#a16">PENALTY_AREA_LENGTH</a>, -<a class="code" href="SoccerTypes_8h.html#a17">PENALTY_AREA_WIDTH</a>/4.0 );00288 <font class="keyword">static</font> <font class="keyword">const</font> <a class="code" href="classVecPosition.html">VecPosition</a> posRightTop( -<a class="code" href="SoccerTypes_8h.html#a13">PITCH_LENGTH</a>/2.0 +00289 0.7*<a class="code" href="SoccerTypes_8h.html#a16">PENALTY_AREA_LENGTH</a>, +<a class="code" href="SoccerTypes_8h.html#a17">PENALTY_AREA_WIDTH</a>/4.0 );00290 00291 <font class="comment">// define the borders of this rectangle using the two points.</font>00292 <font class="keyword">static</font> <a class="code" href="classLine.html">Line</a> lineFront = <a class="code" href="classLine.html#d0">Line::makeLineFromTwoPoints</a>(posLeftTop, posRightTop);00293 <font class="keyword">static</font> <a class="code" href="classLine.html">Line</a> lineLeft = <a class="code" href="classLine.html#d0">Line::makeLineFromTwoPoints</a>(00294 <a class="code" href="classVecPosition.html">VecPosition</a>( -50.0, posLeftTop.<a class="code" href="classVecPosition.html#a28">getY</a>()), posLeftTop );00295 <font class="keyword">static</font> <a class="code" href="classLine.html">Line</a> lineRight = <a class="code" href="classLine.html#d0">Line::makeLineFromTwoPoints</a>(00296 <a class="code" href="classVecPosition.html">VecPosition</a>( -50.0, posRightTop.<a class="code" href="classVecPosition.html#a28">getY</a>()),posRightTop );00297 00298 00299 <font class="keywordflow">if</font>( <a class="code" href="classBasicPlayer.html#n1">WM</a>-><a class="code" href="classWorldModel.html#a85">isBeforeKickOff</a>( ) )00300 {00301 <font class="keywordflow">if</font>( <a class="code" href="classPlayer.html#o0">formations</a>-><a class="code" href="classFormations.html#a5">getFormation</a>() != <a class="code" href="SoccerTypes_8h.html#a249a201">FT_INITIAL</a> || <font class="comment">// not in kick_off formation</font>00302 posAgent.<a class="code" href="classVecPosition.html#a30">getDistanceTo</a>( <a class="code" href="classPlayer.html#a1">getStrategicPosition</a>() ) > 2.0 ) 00303 {00304 <a class="code" href="classPlayer.html#o0">formations</a>-><a class="code" href="classFormations.html#a4">setFormation</a>( <a class="code" href="SoccerTypes_8h.html#a249a201">FT_INITIAL</a> ); <font class="comment">// go to kick_off formation</font>00305 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( <a class="code" href="classBasicPlayer.html#b11">teleportToPos</a>( <a class="code" href="classPlayer.html#a1">getStrategicPosition</a>() ) );00306 }00307 <font class="keywordflow">else</font> <font class="comment">// else turn to center</font>00308 {00309 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( <a class="code" href="classBasicPlayer.html#b1">turnBodyToPoint</a>( <a class="code" href="classVecPosition.html">VecPosition</a>( 0, 0 ), 0 ) );00310 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( <a class="code" href="classBasicPlayer.html#b0">alignNeckWithBody</a>( ) );00311 }00312 <font class="keywordflow">return</font>;00313 }00314 00315 <font class="keywordflow">if</font>( <a class="code" href="classBasicPlayer.html#n1">WM</a>-><a class="code" href="classWorldModel.html#a61">getConfidence</a>( <a class="code" href="SoccerTypes_8h.html#a240a24">OBJECT_BALL</a> ) < <a class="code" href="classBasicPlayer.html#n3">PS</a>-><a class="code" href="classPlayerSettings.html#a5">getBallConfThr</a>() )00316 { <font class="comment">// confidence ball too low</font>00317 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( <a class="code" href="classBasicPlayer.html#b4">searchBall</a>() ); <font class="comment">// search ball</font>00318 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( <a class="code" href="classBasicPlayer.html#b0">alignNeckWithBody</a>( ) );00319 }00320 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( <a class="code" href="classBasicPlayer.html#n1">WM</a>-><a class="code" href="classWorldModel.html#a20">getPlayMode</a>() == <a class="code" href="SoccerTypes_8h.html#a242a136">PM_PLAY_ON</a> || <a class="code" href="classBasicPlayer.html#n1">WM</a>-><a class="code" href="classWorldModel.html#a74">isFreeKickThem</a>() ||00321 <a class="code" href="classBasicPlayer.html#n1">WM</a>-><a class="code" href="classWorldModel.html#a76">isCornerKickThem</a>() ) 00322 {00323 <font class="keywordflow">if</font>( <a class="code" href="classBasicPlayer.html#n1">WM</a>-><a class="code" href="classWorldModel.html#a129">isBallCatchable</a>() )00324 {00325 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( soc = <a class="code" href="classBasicPlayer.html#b9">catchBall</a>() );00326 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( <a class="code" href="classBasicPlayer.html#b13">turnNeckToObject</a>( <a class="code" href="SoccerTypes_8h.html#a240a24">OBJECT_BALL</a>, soc ) );00327 }00328 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( <a class="code" href="classBasicPlayer.html#n1">WM</a>-><a class="code" href="classWorldModel.html#a128">isBallKickable</a>() )00329 {00330 soc = <a class="code" href="classBasicPlayer.html#b17">kickTo</a>( <a class="code" href="classVecPosition.html">VecPosition</a>(0,posAgent.<a class="code" href="classVecPosition.html#a28">getY</a>()*2.0), 2.0 ); 00331 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( soc );00332 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( <a class="code" href="classBasicPlayer.html#b13">turnNeckToObject</a>( <a class="code" href="SoccerTypes_8h.html#a240a24">OBJECT_BALL</a>, soc ) );00333 }00334 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( <a class="code" href="classBasicPlayer.html#n1">WM</a>-><a class="code" href="classWorldModel.html#a133">isInOwnPenaltyArea</a>( <a class="code" href="classBasicPlayer.html#b29">getInterceptionPointBall</a>( &i, <font class="keyword">true</font> ) ) &&00335 <a class="code" href="classBasicPlayer.html#n1">WM</a>-><a class="code" href="classWorldModel.html#a122">getFastestInSetTo</a>( <a class="code" href="SoccerTypes_8h.html#a241a117">OBJECT_SET_PLAYERS</a>, <a class="code" href="SoccerTypes_8h.html#a240a24">OBJECT_BALL</a>, &i ) == 00336 <a class="code" href="classBasicPlayer.html#n1">WM</a>-><a class="code" href="classWorldModel.html#a34">getAgentObjectType</a>() )00337 {00338 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( soc = <a class="code" href="classBasicPlayer.html#b20">intercept</a>( <font class="keyword">true</font> ) );00339 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( <a class="code" href="classBasicPlayer.html#b13">turnNeckToObject</a>( <a class="code" href="SoccerTypes_8h.html#a240a24">OBJECT_BALL</a>, soc ) );00340 }00341 <font class="keywordflow">else</font>00342 {00343 <font class="comment">// make line between own goal and the ball</font>00344 <a class="code" href="classVecPosition.html">VecPosition</a> posMyGoal = ( <a class="code" href="classBasicPlayer.html#n1">WM</a>-><a class="code" href="classWorldModel.html#a16">getSide</a>() == <a class="code" href="SoccerTypes_8h.html#a246a177">SIDE_LEFT</a> )00345 ? <a class="code" href="classSoccerTypes.html#d17">SoccerTypes::getGlobalPositionFlag</a>(<a class="code" href="SoccerTypes_8h.html#a240a25">OBJECT_GOAL_L</a>, <a class="code" href="SoccerTypes_8h.html#a246a177">SIDE_LEFT</a> )00346 : <a class="code" href="classSoccerTypes.html#d17">SoccerTypes::getGlobalPositionFlag</a>(<a class="code" href="SoccerTypes_8h.html#a240a26">OBJECT_GOAL_R</a>, <a class="code" href="SoccerTypes_8h.html#a246a178">SIDE_RIGHT</a>);00347 <a class="code" href="classLine.html">Line</a> lineBall = <a class="code" href="classLine.html#d0">Line::makeLineFromTwoPoints</a>( <a class="code" href="classBasicPlayer.html#n1">WM</a>-><a class="code" href="classWorldModel.html#a47">getBallPos</a>(), posMyGoal);00348 00349 <font class="comment">// determine where your front line intersects with the line from ball</font>00350 <a class="code" href="classVecPosition.html">VecPosition</a> posIntersect = lineFront.<a class="code" href="classLine.html#a2">getIntersection</a>( lineBall );00351 00352 <font class="comment">// outside rectangle, use line at side to get intersection</font>00353 <font class="keywordflow">if</font> (posIntersect.<a class="code" href="classVecPosition.html#a40">isRightOf</a>( posRightTop ) )00354 posIntersect = lineRight.<a class="code" href="classLine.html#a2">getIntersection</a>( lineBall );00355 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (posIntersect.<a class="code" href="classVecPosition.html#a38">isLeftOf</a>( posLeftTop ) )00356 posIntersect = lineLeft.<a class="code" href="classLine.html#a2">getIntersection</a>( lineBall );00357 00358 <font class="keywordflow">if</font>( posIntersect.<a class="code" href="classVecPosition.html#a26">getX</a>() < -49.0 )00359 posIntersect.<a class="code" href="classVecPosition.html#a25">setX</a>( -49.0 );00360 00361 <font class="comment">// and move to this position</font>00362 <font class="keywordflow">if</font>( posIntersect.<a class="code" href="classVecPosition.html#a30">getDistanceTo</a>( <a class="code" href="classBasicPlayer.html#n1">WM</a>-><a class="code" href="classWorldModel.html#a43">getAgentGlobalPosition</a>() ) > 0.5 )00363 {00364 soc = <a class="code" href="classBasicPlayer.html#b14">moveToPos</a>( posIntersect, <a class="code" href="classBasicPlayer.html#n3">PS</a>-><a class="code" href="classPlayerSettings.html#a9">getPlayerWhenToTurnAngle</a>() );00365 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( soc );00366 <a class="code" href="classBasicPlayer.html#n0">ACT</a>-><a class="code" href="classActHandler.html#a1">putCommandInQueue</a>( <a class="code" href="classBasicPlayer.html#b13">turnNeckToObject</a>( <a class="code" href="SoccerTypes_8h.html#a240a24">OBJECT_BALL</a>, soc ) );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?