soccertypes_8c-source.html
来自「仿真人工智能是指用人工的方法和技术」· HTML 代码 · 共 627 行 · 第 1/5 页
HTML
627 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>SoccerTypes.C Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body bgcolor="#ffffff"><!-- Generated by Doxygen 1.2.12 --><center><a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center><hr><h1>SoccerTypes.C</h1><a href="SoccerTypes_8C.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">/*</font>00002 <font class="comment">Copyright (c) 2000,2001, Jelle Kok, University of Amsterdam</font>00003 <font class="comment">All rights reserved.</font>00004 <font class="comment"></font>00005 <font class="comment">Redistribution and use in source and binary forms, with or without </font>00006 <font class="comment">modification, are permitted provided that the following conditions are met:</font>00007 <font class="comment"></font>00008 <font class="comment">1. Redistributions of source code must retain the above copyright notice, this </font>00009 <font class="comment">list of conditions and the following disclaimer. </font>00010 <font class="comment"></font>00011 <font class="comment">2. Redistributions in binary form must reproduce the above copyright notice, </font>00012 <font class="comment">this list of conditions and the following disclaimer in the documentation </font>00013 <font class="comment">and/or other materials provided with the distribution. </font>00014 <font class="comment"></font>00015 <font class="comment">3. Neither the name of the University of Amsterdam nor the names of its </font>00016 <font class="comment">contributors may be used to endorse or promote products derived from this </font>00017 <font class="comment">software without specific prior written permission. </font>00018 <font class="comment"></font>00019 <font class="comment">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" </font>00020 <font class="comment">AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE </font>00021 <font class="comment">IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE </font>00022 <font class="comment">DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE </font>00023 <font class="comment">FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL </font>00024 <font class="comment">DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR </font>00025 <font class="comment">SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER </font>00026 <font class="comment">CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, </font>00027 <font class="comment">OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE </font>00028 <font class="comment">OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</font>00029 <font class="comment">*/</font>00049 <font class="preprocessor">#include <iostream.h></font> <font class="comment">// needed for outputsteam in showcerr</font>00050 <font class="preprocessor">#include <stdio.h></font> <font class="comment">// needed for sprintf</font>00051 <font class="preprocessor">#ifdef Solaris</font>00052 <font class="preprocessor"></font><font class="preprocessor"> #include <strings.h></font> <font class="comment">// needed for strncmp</font>00053 <font class="preprocessor">#else</font>00054 <font class="preprocessor"></font><font class="preprocessor"> #include <string.h></font> <font class="comment">// needed for strncmp</font>00055 <font class="preprocessor">#endif</font>00056 <font class="preprocessor"></font>00057 <font class="preprocessor">#include "<a class="code" href="SoccerTypes_8h.html">SoccerTypes.h</a>"</font>00058 <font class="preprocessor">#include "<a class="code" href="Parse_8h.html">Parse.h</a>"</font>00059 00060 00061 <font class="comment">/******************************************************************************/</font>00062 <font class="comment">/********************** CLASS TIME ********************************************/</font>00063 <font class="comment">/******************************************************************************/</font>00064 <a name="l00069"></a><a class="code" href="classTime.html#a0">00069</a> <a class="code" href="classTime.html#a0">Time::Time</a>( <font class="keywordtype">int</font> iTime, <font class="keywordtype">int</font> iStopped )00070 {00071 <a class="code" href="classTime.html#o0">m_iTime</a> = iTime;00072 <a class="code" href="classTime.html#o1">m_iStopped</a> = iStopped;00073 }00074 <a name="l00081"></a><a class="code" href="classTime.html#a1">00081</a> <font class="keywordtype">bool</font> <a class="code" href="classTime.html#a1">Time::updateTime</a>( <font class="keywordtype">int</font> iTime )00082 {00083 <font class="keywordflow">if</font>( <a class="code" href="classTime.html#o0">m_iTime</a> == iTime )00084 <a class="code" href="classTime.html#o1">m_iStopped</a>++;00085 <font class="keywordflow">else</font>00086 {00087 <a class="code" href="classTime.html#o0">m_iTime</a> = iTime;00088 <a class="code" href="classTime.html#o1">m_iStopped</a> = 0;00089 }00090 <font class="keywordflow">return</font> <font class="keyword">true</font>;00091 }00092 <a name="l00097"></a><a class="code" href="classTime.html#a2">00097</a> <font class="keywordtype">bool</font> <a class="code" href="classTime.html#a2">Time::setTimeStopped</a>( <font class="keywordtype">int</font> iTime )00098 {00099 <a class="code" href="classTime.html#o1">m_iStopped</a> = iTime;00100 <font class="keywordflow">return</font> <font class="keyword">true</font>;00101 }00102 <a name="l00106"></a><a class="code" href="classTime.html#a3">00106</a> <font class="keywordtype">int</font> <a class="code" href="classTime.html#a3">Time::getTime</a>( )00107 {00108 <font class="keywordflow">return</font> <a class="code" href="classTime.html#o0">m_iTime</a>;00109 }00110 <a name="l00114"></a><a class="code" href="classTime.html#a4">00114</a> <font class="keywordtype">int</font> <a class="code" href="classTime.html#a4">Time::getTimeStopped</a>( )00115 {00116 <font class="keywordflow">return</font> <a class="code" href="classTime.html#o1">m_iStopped</a>;00117 }00118 <a name="l00125"></a><a class="code" href="classTime.html#a5">00125</a> <font class="keywordtype">int</font> <a class="code" href="classTime.html#a5">Time::getTimeDifference</a>( <a class="code" href="classTime.html">Time</a> t )00126 {00127 <font class="keywordflow">if</font>( <a class="code" href="classTime.html#a3">getTime</a>() < t.<a class="code" href="classTime.html#a3">getTime</a>() )00128 <font class="keywordflow">return</font> <a class="code" href="classTime.html#a3">getTime</a>() - t.<a class="code" href="classTime.html#a3">getTime</a>();00129 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( <a class="code" href="classTime.html#a3">getTime</a>() == t.<a class="code" href="classTime.html#a3">getTime</a>() )00130 <font class="keywordflow">return</font> <a class="code" href="classTime.html#a4">getTimeStopped</a>() - t.<a class="code" href="classTime.html#a4">getTimeStopped</a>();00131 <font class="keywordflow">else</font>00132 <font class="keywordflow">return</font> <a class="code" href="classTime.html#a3">getTime</a>() - t.<a class="code" href="classTime.html#a3">getTime</a>();00133 }00134 <a name="l00138"></a><a class="code" href="classTime.html#a6">00138</a> <font class="keywordtype">bool</font> <a class="code" href="classTime.html#a6">Time::isStopped</a>( )00139 {00140 <font class="keywordflow">return</font> <a class="code" href="classTime.html#o1">m_iStopped</a> != 0;00141 }00142 <a name="l00154"></a><a class="code" href="classTime.html#a7">00154</a> <a class="code" href="classTime.html">Time</a> <a class="code" href="classTime.html#a7">Time::getTimeAddedWith</a>( <font class="keywordtype">int</font> iCycles )00155 {00156 <font class="keywordtype">int</font> iTime = <a class="code" href="classTime.html#a3">getTime</a>();00157 <font class="keywordtype">int</font> iStopped = <a class="code" href="classTime.html#a4">getTimeStopped</a>();00158 00159 <font class="keywordflow">if</font>( iCycles > 0 ) <font class="comment">// add cycles</font>00160 {00161 <font class="keywordflow">if</font>( iStopped > 0 ) <font class="comment">// time stopped</font>00162 iStopped += iCycles; <font class="comment">// add it to stopped cycles</font>00163 <font class="keywordflow">else</font>00164 iTime += iCycles; <font class="comment">// otherwise add to normal time</font>00165 }00166 <font class="keywordflow">else</font> <font class="comment">// subtract cycles</font>00167 {00168 <font class="keywordflow">if</font>( iStopped > 0 && iStopped >= iCycles) <font class="comment">// time stopped and enough time</font>00169 iStopped += iCycles; <font class="comment">// subtract cycle (iCycles=neg)</font>00170 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( iStopped > 0 ) <font class="comment">// stopped but not enough time</font>00171 {00172 iStopped = 0; <font class="comment">// take as many as possible</font>00173 iCycles += iStopped;00174 iTime += iCycles; <font class="comment">// and take rest from m_iTime</font>00175 }00176 <font class="keywordflow">else</font> <font class="comment">// time not stopped</font>00177 iTime += iCycles; <font class="comment">// take all from m_iTime</font>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?