test/gs/bigtest.html

changeset 80
0f1c55d2a90a
parent 66
1b12cf799fee
equal deleted inserted replaced
79:07a3743ce6ac 80:0f1c55d2a90a
129 <a class="c2html-lineno" name="l76" href="#l76"> 76 </a> 129 <a class="c2html-lineno" name="l76" href="#l76"> 76 </a>
130 <a class="c2html-lineno" name="l77" href="#l77"> 77 </a> <span class="c2html-comment">/* at least 8 characters should be available, wipe them out */</span> 130 <a class="c2html-lineno" name="l77" href="#l77"> 77 </a> <span class="c2html-comment">/* at least 8 characters should be available, wipe them out */</span>
131 <a class="c2html-lineno" name="l78" href="#l78"> 78 </a> memset(string, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">8</span>); 131 <a class="c2html-lineno" name="l78" href="#l78"> 78 </a> memset(string, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">8</span>);
132 <a class="c2html-lineno" name="l79" href="#l79"> 79 </a> 132 <a class="c2html-lineno" name="l79" href="#l79"> 79 </a>
133 <a class="c2html-lineno" name="l80" href="#l80"> 80 </a> <span class="c2html-comment">/* special formats for castling */</span> 133 <a class="c2html-lineno" name="l80" href="#l80"> 80 </a> <span class="c2html-comment">/* special formats for castling */</span>
134 <a class="c2html-lineno" name="l81" href="#l81"> 81 </a> <span class="c2html-keyword">if</span> ((move-&gt;piece&<span class="c2html-macroconst">PIECE_MASK</span>) == <span class="c2html-macroconst">KING</span> && 134 <a class="c2html-lineno" name="l81" href="#l81"> 81 </a> <span class="c2html-keyword">if</span> ((move-&gt;piece&amp;<span class="c2html-macroconst">PIECE_MASK</span>) == <span class="c2html-macroconst">KING</span> &amp;&amp;
135 <a class="c2html-lineno" name="l82" href="#l82"> 82 </a> abs(move-&gt;tofile-move-&gt;fromfile) == <span class="c2html-macroconst">2</span>) { 135 <a class="c2html-lineno" name="l82" href="#l82"> 82 </a> abs(move-&gt;tofile-move-&gt;fromfile) == <span class="c2html-macroconst">2</span>) {
136 <a class="c2html-lineno" name="l83" href="#l83"> 83 </a> <span class="c2html-keyword">if</span> (move-&gt;tofile==fileidx(<span class="c2html-string">'c'</span>)) { 136 <a class="c2html-lineno" name="l83" href="#l83"> 83 </a> <span class="c2html-keyword">if</span> (move-&gt;tofile==fileidx(<span class="c2html-string">'c'</span>)) {
137 <a class="c2html-lineno" name="l84" href="#l84"> 84 </a> memcpy(string, <span class="c2html-string">"O-O-O"</span>, <span class="c2html-macroconst">5</span>); 137 <a class="c2html-lineno" name="l84" href="#l84"> 84 </a> memcpy(string, <span class="c2html-string">"O-O-O"</span>, <span class="c2html-macroconst">5</span>);
138 <a class="c2html-lineno" name="l85" href="#l85"> 85 </a> } <span class="c2html-keyword">else</span> { 138 <a class="c2html-lineno" name="l85" href="#l85"> 85 </a> } <span class="c2html-keyword">else</span> {
139 <a class="c2html-lineno" name="l86" href="#l86"> 86 </a> memcpy(string, <span class="c2html-string">"O-O"</span>, <span class="c2html-macroconst">3</span>); 139 <a class="c2html-lineno" name="l86" href="#l86"> 86 </a> memcpy(string, <span class="c2html-string">"O-O"</span>, <span class="c2html-macroconst">3</span>);
143 <a class="c2html-lineno" name="l90" href="#l90"> 90 </a> <span class="c2html-comment">/* start by notating the piece character */</span> 143 <a class="c2html-lineno" name="l90" href="#l90"> 90 </a> <span class="c2html-comment">/* start by notating the piece character */</span>
144 <a class="c2html-lineno" name="l91" href="#l91"> 91 </a> string[<span class="c2html-macroconst">0</span>] = getpiecechr(move-&gt;piece); 144 <a class="c2html-lineno" name="l91" href="#l91"> 91 </a> string[<span class="c2html-macroconst">0</span>] = getpiecechr(move-&gt;piece);
145 <a class="c2html-lineno" name="l92" href="#l92"> 92 </a> <span class="c2html-keyword">int</span> idx = string[<span class="c2html-macroconst">0</span>] ? <span class="c2html-macroconst">1</span> : <span class="c2html-macroconst">0</span>; 145 <a class="c2html-lineno" name="l92" href="#l92"> 92 </a> <span class="c2html-keyword">int</span> idx = string[<span class="c2html-macroconst">0</span>] ? <span class="c2html-macroconst">1</span> : <span class="c2html-macroconst">0</span>;
146 <a class="c2html-lineno" name="l93" href="#l93"> 93 </a> 146 <a class="c2html-lineno" name="l93" href="#l93"> 93 </a>
147 <a class="c2html-lineno" name="l94" href="#l94"> 94 </a> <span class="c2html-comment">/* find out how many source information we do need */</span> 147 <a class="c2html-lineno" name="l94" href="#l94"> 94 </a> <span class="c2html-comment">/* find out how many source information we do need */</span>
148 <a class="c2html-lineno" name="l95" href="#l95"> 95 </a> <span class="c2html-type">uint8_t</span> piece = move-&gt;piece & <span class="c2html-macroconst">PIECE_MASK</span>; 148 <a class="c2html-lineno" name="l95" href="#l95"> 95 </a> <span class="c2html-type">uint8_t</span> piece = move-&gt;piece &amp; <span class="c2html-macroconst">PIECE_MASK</span>;
149 <a class="c2html-lineno" name="l96" href="#l96"> 96 </a> <span class="c2html-keyword">if</span> (piece == <span class="c2html-macroconst">PAWN</span>) { 149 <a class="c2html-lineno" name="l96" href="#l96"> 96 </a> <span class="c2html-keyword">if</span> (piece == <span class="c2html-macroconst">PAWN</span>) {
150 <a class="c2html-lineno" name="l97" href="#l97"> 97 </a> <span class="c2html-keyword">if</span> (move-&gt;capture) { 150 <a class="c2html-lineno" name="l97" href="#l97"> 97 </a> <span class="c2html-keyword">if</span> (move-&gt;capture) {
151 <a class="c2html-lineno" name="l98" href="#l98"> 98 </a> string[idx++] = filechr(move-&gt;fromfile); 151 <a class="c2html-lineno" name="l98" href="#l98"> 98 </a> string[idx++] = filechr(move-&gt;fromfile);
152 <a class="c2html-lineno" name="l99" href="#l99"> 99 </a> } 152 <a class="c2html-lineno" name="l99" href="#l99"> 99 </a> }
153 <a class="c2html-lineno" name="l100" href="#l100">100 </a> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span> (piece != <span class="c2html-macroconst">KING</span>) { 153 <a class="c2html-lineno" name="l100" href="#l100">100 </a> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span> (piece != <span class="c2html-macroconst">KING</span>) {
154 <a class="c2html-lineno" name="l101" href="#l101">101 </a> Move threats[<span class="c2html-macroconst">16</span>]; 154 <a class="c2html-lineno" name="l101" href="#l101">101 </a> Move threats[<span class="c2html-macroconst">16</span>];
155 <a class="c2html-lineno" name="l102" href="#l102">102 </a> <span class="c2html-type">uint8_t</span> threatcount; 155 <a class="c2html-lineno" name="l102" href="#l102">102 </a> <span class="c2html-type">uint8_t</span> threatcount;
156 <a class="c2html-lineno" name="l103" href="#l103">103 </a> get_real_threats(gamestate, move-&gt;torow, move-&gt;tofile, 156 <a class="c2html-lineno" name="l103" href="#l103">103 </a> get_real_threats(gamestate, move-&gt;torow, move-&gt;tofile,
157 <a class="c2html-lineno" name="l104" href="#l104">104 </a> move-&gt;piece&<span class="c2html-macroconst">COLOR_MASK</span>, threats, &threatcount); 157 <a class="c2html-lineno" name="l104" href="#l104">104 </a> move-&gt;piece&amp;<span class="c2html-macroconst">COLOR_MASK</span>, threats, &amp;threatcount);
158 <a class="c2html-lineno" name="l105" href="#l105">105 </a> <span class="c2html-keyword">if</span> (threatcount &gt; <span class="c2html-macroconst">1</span>) { 158 <a class="c2html-lineno" name="l105" href="#l105">105 </a> <span class="c2html-keyword">if</span> (threatcount &gt; <span class="c2html-macroconst">1</span>) {
159 <a class="c2html-lineno" name="l106" href="#l106">106 </a> <span class="c2html-keyword">int</span> ambrows = <span class="c2html-macroconst">0</span>, ambfiles = <span class="c2html-macroconst">0</span>; 159 <a class="c2html-lineno" name="l106" href="#l106">106 </a> <span class="c2html-keyword">int</span> ambrows = <span class="c2html-macroconst">0</span>, ambfiles = <span class="c2html-macroconst">0</span>;
160 <a class="c2html-lineno" name="l107" href="#l107">107 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> i = <span class="c2html-macroconst">0</span> ; i &lt; threatcount ; i++) { 160 <a class="c2html-lineno" name="l107" href="#l107">107 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> i = <span class="c2html-macroconst">0</span> ; i &lt; threatcount ; i++) {
161 <a class="c2html-lineno" name="l108" href="#l108">108 </a> <span class="c2html-keyword">if</span> (threats[i].fromrow == move-&gt;fromrow) { 161 <a class="c2html-lineno" name="l108" href="#l108">108 </a> <span class="c2html-keyword">if</span> (threats[i].fromrow == move-&gt;fromrow) {
162 <a class="c2html-lineno" name="l109" href="#l109">109 </a> ambrows++; 162 <a class="c2html-lineno" name="l109" href="#l109">109 </a> ambrows++;
202 <a class="c2html-lineno" name="l149" href="#l149">149 </a> MoveList *elem = malloc(<span class="c2html-keyword">sizeof</span>(MoveList)); 202 <a class="c2html-lineno" name="l149" href="#l149">149 </a> MoveList *elem = malloc(<span class="c2html-keyword">sizeof</span>(MoveList));
203 <a class="c2html-lineno" name="l150" href="#l150">150 </a> elem-&gt;next = <span class="c2html-macroconst">NULL</span>; 203 <a class="c2html-lineno" name="l150" href="#l150">150 </a> elem-&gt;next = <span class="c2html-macroconst">NULL</span>;
204 <a class="c2html-lineno" name="l151" href="#l151">151 </a> elem-&gt;move = *move; 204 <a class="c2html-lineno" name="l151" href="#l151">151 </a> elem-&gt;move = *move;
205 <a class="c2html-lineno" name="l152" href="#l152">152 </a> 205 <a class="c2html-lineno" name="l152" href="#l152">152 </a>
206 <a class="c2html-lineno" name="l153" href="#l153">153 </a> <span class="c2html-keyword">struct</span> timeval curtimestamp; 206 <a class="c2html-lineno" name="l153" href="#l153">153 </a> <span class="c2html-keyword">struct</span> timeval curtimestamp;
207 <a class="c2html-lineno" name="l154" href="#l154">154 </a> gettimeofday(&curtimestamp, <span class="c2html-macroconst">NULL</span>); 207 <a class="c2html-lineno" name="l154" href="#l154">154 </a> gettimeofday(&amp;curtimestamp, <span class="c2html-macroconst">NULL</span>);
208 <a class="c2html-lineno" name="l155" href="#l155">155 </a> elem-&gt;move.timestamp.tv_sec = curtimestamp.tv_sec; 208 <a class="c2html-lineno" name="l155" href="#l155">155 </a> elem-&gt;move.timestamp.tv_sec = curtimestamp.tv_sec;
209 <a class="c2html-lineno" name="l156" href="#l156">156 </a> elem-&gt;move.timestamp.tv_usec = curtimestamp.tv_usec; 209 <a class="c2html-lineno" name="l156" href="#l156">156 </a> elem-&gt;move.timestamp.tv_usec = curtimestamp.tv_usec;
210 <a class="c2html-lineno" name="l157" href="#l157">157 </a> 210 <a class="c2html-lineno" name="l157" href="#l157">157 </a>
211 <a class="c2html-lineno" name="l158" href="#l158">158 </a> <span class="c2html-keyword">if</span> (gamestate-&gt;lastmove) { 211 <a class="c2html-lineno" name="l158" href="#l158">158 </a> <span class="c2html-keyword">if</span> (gamestate-&gt;lastmove) {
212 <a class="c2html-lineno" name="l159" href="#l159">159 </a> <span class="c2html-keyword">struct</span> movetimeval *lasttstamp = &(gamestate-&gt;lastmove-&gt;move.timestamp); 212 <a class="c2html-lineno" name="l159" href="#l159">159 </a> <span class="c2html-keyword">struct</span> movetimeval *lasttstamp = &amp;(gamestate-&gt;lastmove-&gt;move.timestamp);
213 <a class="c2html-lineno" name="l160" href="#l160">160 </a> <span class="c2html-type">uint64_t</span> sec = curtimestamp.tv_sec - lasttstamp-&gt;tv_sec; 213 <a class="c2html-lineno" name="l160" href="#l160">160 </a> <span class="c2html-type">uint64_t</span> sec = curtimestamp.tv_sec - lasttstamp-&gt;tv_sec;
214 <a class="c2html-lineno" name="l161" href="#l161">161 </a> <span class="c2html-type">suseconds_t</span> micros; 214 <a class="c2html-lineno" name="l161" href="#l161">161 </a> <span class="c2html-type">suseconds_t</span> micros;
215 <a class="c2html-lineno" name="l162" href="#l162">162 </a> <span class="c2html-keyword">if</span> (curtimestamp.tv_usec &lt; lasttstamp-&gt;tv_usec) { 215 <a class="c2html-lineno" name="l162" href="#l162">162 </a> <span class="c2html-keyword">if</span> (curtimestamp.tv_usec &lt; lasttstamp-&gt;tv_usec) {
216 <a class="c2html-lineno" name="l163" href="#l163">163 </a> micros = 1e6L-(lasttstamp-&gt;tv_usec - curtimestamp.tv_usec); 216 <a class="c2html-lineno" name="l163" href="#l163">163 </a> micros = 1e6L-(lasttstamp-&gt;tv_usec - curtimestamp.tv_usec);
217 <a class="c2html-lineno" name="l164" href="#l164">164 </a> sec--; 217 <a class="c2html-lineno" name="l164" href="#l164">164 </a> sec--;
230 <a class="c2html-lineno" name="l177" href="#l177">177 </a> gamestate-&gt;movelist = gamestate-&gt;lastmove = elem; 230 <a class="c2html-lineno" name="l177" href="#l177">177 </a> gamestate-&gt;movelist = gamestate-&gt;lastmove = elem;
231 <a class="c2html-lineno" name="l178" href="#l178">178 </a> } 231 <a class="c2html-lineno" name="l178" href="#l178">178 </a> }
232 <a class="c2html-lineno" name="l179" href="#l179">179 </a>} 232 <a class="c2html-lineno" name="l179" href="#l179">179 </a>}
233 <a class="c2html-lineno" name="l180" href="#l180">180 </a> 233 <a class="c2html-lineno" name="l180" href="#l180">180 </a>
234 <a class="c2html-lineno" name="l181" href="#l181">181 </a><span class="c2html-keyword">char</span> getpiecechr(<span class="c2html-type">uint8_t</span> piece) { 234 <a class="c2html-lineno" name="l181" href="#l181">181 </a><span class="c2html-keyword">char</span> getpiecechr(<span class="c2html-type">uint8_t</span> piece) {
235 <a class="c2html-lineno" name="l182" href="#l182">182 </a> <span class="c2html-keyword">switch</span> (piece & <span class="c2html-macroconst">PIECE_MASK</span>) { 235 <a class="c2html-lineno" name="l182" href="#l182">182 </a> <span class="c2html-keyword">switch</span> (piece &amp; <span class="c2html-macroconst">PIECE_MASK</span>) {
236 <a class="c2html-lineno" name="l183" href="#l183">183 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">ROOK</span>: <span class="c2html-keyword">return</span> <span class="c2html-string">'R'</span>; 236 <a class="c2html-lineno" name="l183" href="#l183">183 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">ROOK</span>: <span class="c2html-keyword">return</span> <span class="c2html-string">'R'</span>;
237 <a class="c2html-lineno" name="l184" href="#l184">184 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">KNIGHT</span>: <span class="c2html-keyword">return</span> <span class="c2html-string">'N'</span>; 237 <a class="c2html-lineno" name="l184" href="#l184">184 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">KNIGHT</span>: <span class="c2html-keyword">return</span> <span class="c2html-string">'N'</span>;
238 <a class="c2html-lineno" name="l185" href="#l185">185 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">BISHOP</span>: <span class="c2html-keyword">return</span> <span class="c2html-string">'B'</span>; 238 <a class="c2html-lineno" name="l185" href="#l185">185 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">BISHOP</span>: <span class="c2html-keyword">return</span> <span class="c2html-string">'B'</span>;
239 <a class="c2html-lineno" name="l186" href="#l186">186 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">QUEEN</span>: <span class="c2html-keyword">return</span> <span class="c2html-string">'Q'</span>; 239 <a class="c2html-lineno" name="l186" href="#l186">186 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">QUEEN</span>: <span class="c2html-keyword">return</span> <span class="c2html-string">'Q'</span>;
240 <a class="c2html-lineno" name="l187" href="#l187">187 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">KING</span>: <span class="c2html-keyword">return</span> <span class="c2html-string">'K'</span>; 240 <a class="c2html-lineno" name="l187" href="#l187">187 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">KING</span>: <span class="c2html-keyword">return</span> <span class="c2html-string">'K'</span>;
252 <a class="c2html-lineno" name="l199" href="#l199">199 </a> <span class="c2html-keyword">default</span>: <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>; 252 <a class="c2html-lineno" name="l199" href="#l199">199 </a> <span class="c2html-keyword">default</span>: <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>;
253 <a class="c2html-lineno" name="l200" href="#l200">200 </a> } 253 <a class="c2html-lineno" name="l200" href="#l200">200 </a> }
254 <a class="c2html-lineno" name="l201" href="#l201">201 </a>} 254 <a class="c2html-lineno" name="l201" href="#l201">201 </a>}
255 <a class="c2html-lineno" name="l202" href="#l202">202 </a> 255 <a class="c2html-lineno" name="l202" href="#l202">202 </a>
256 <a class="c2html-lineno" name="l203" href="#l203">203 </a><span class="c2html-keyword">static</span> <span class="c2html-keyword">void</span> apply_move_impl(GameState *gamestate, Move *move, _Bool simulate) { 256 <a class="c2html-lineno" name="l203" href="#l203">203 </a><span class="c2html-keyword">static</span> <span class="c2html-keyword">void</span> apply_move_impl(GameState *gamestate, Move *move, _Bool simulate) {
257 <a class="c2html-lineno" name="l204" href="#l204">204 </a> <span class="c2html-type">uint8_t</span> piece = move-&gt;piece & <span class="c2html-macroconst">PIECE_MASK</span>; 257 <a class="c2html-lineno" name="l204" href="#l204">204 </a> <span class="c2html-type">uint8_t</span> piece = move-&gt;piece &amp; <span class="c2html-macroconst">PIECE_MASK</span>;
258 <a class="c2html-lineno" name="l205" href="#l205">205 </a> <span class="c2html-type">uint8_t</span> color = move-&gt;piece & <span class="c2html-macroconst">COLOR_MASK</span>; 258 <a class="c2html-lineno" name="l205" href="#l205">205 </a> <span class="c2html-type">uint8_t</span> color = move-&gt;piece &amp; <span class="c2html-macroconst">COLOR_MASK</span>;
259 <a class="c2html-lineno" name="l206" href="#l206">206 </a> 259 <a class="c2html-lineno" name="l206" href="#l206">206 </a>
260 <a class="c2html-lineno" name="l207" href="#l207">207 </a> <span class="c2html-comment">/* en passant capture */</span> 260 <a class="c2html-lineno" name="l207" href="#l207">207 </a> <span class="c2html-comment">/* en passant capture */</span>
261 <a class="c2html-lineno" name="l208" href="#l208">208 </a> <span class="c2html-keyword">if</span> (move-&gt;capture && piece == <span class="c2html-macroconst">PAWN</span> && 261 <a class="c2html-lineno" name="l208" href="#l208">208 </a> <span class="c2html-keyword">if</span> (move-&gt;capture &amp;&amp; piece == <span class="c2html-macroconst">PAWN</span> &amp;&amp;
262 <a class="c2html-lineno" name="l209" href="#l209">209 </a> mdst(gamestate-&gt;board, move) == <span class="c2html-macroconst">0</span>) { 262 <a class="c2html-lineno" name="l209" href="#l209">209 </a> mdst(gamestate-&gt;board, move) == <span class="c2html-macroconst">0</span>) {
263 <a class="c2html-lineno" name="l210" href="#l210">210 </a> gamestate-&gt;board[move-&gt;fromrow][move-&gt;tofile] = <span class="c2html-macroconst">0</span>; 263 <a class="c2html-lineno" name="l210" href="#l210">210 </a> gamestate-&gt;board[move-&gt;fromrow][move-&gt;tofile] = <span class="c2html-macroconst">0</span>;
264 <a class="c2html-lineno" name="l211" href="#l211">211 </a> } 264 <a class="c2html-lineno" name="l211" href="#l211">211 </a> }
265 <a class="c2html-lineno" name="l212" href="#l212">212 </a> 265 <a class="c2html-lineno" name="l212" href="#l212">212 </a>
266 <a class="c2html-lineno" name="l213" href="#l213">213 </a> <span class="c2html-comment">/* remove old en passant threats */</span> 266 <a class="c2html-lineno" name="l213" href="#l213">213 </a> <span class="c2html-comment">/* remove old en passant threats */</span>
267 <a class="c2html-lineno" name="l214" href="#l214">214 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> file = <span class="c2html-macroconst">0</span> ; file &lt; <span class="c2html-macroconst">8</span> ; file++) { 267 <a class="c2html-lineno" name="l214" href="#l214">214 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> file = <span class="c2html-macroconst">0</span> ; file &lt; <span class="c2html-macroconst">8</span> ; file++) {
268 <a class="c2html-lineno" name="l215" href="#l215">215 </a> gamestate-&gt;board[<span class="c2html-macroconst">3</span>][file] &= ~<span class="c2html-macroconst">ENPASSANT_THREAT</span>; 268 <a class="c2html-lineno" name="l215" href="#l215">215 </a> gamestate-&gt;board[<span class="c2html-macroconst">3</span>][file] &amp;= ~<span class="c2html-macroconst">ENPASSANT_THREAT</span>;
269 <a class="c2html-lineno" name="l216" href="#l216">216 </a> gamestate-&gt;board[<span class="c2html-macroconst">4</span>][file] &= ~<span class="c2html-macroconst">ENPASSANT_THREAT</span>; 269 <a class="c2html-lineno" name="l216" href="#l216">216 </a> gamestate-&gt;board[<span class="c2html-macroconst">4</span>][file] &amp;= ~<span class="c2html-macroconst">ENPASSANT_THREAT</span>;
270 <a class="c2html-lineno" name="l217" href="#l217">217 </a> } 270 <a class="c2html-lineno" name="l217" href="#l217">217 </a> }
271 <a class="c2html-lineno" name="l218" href="#l218">218 </a> 271 <a class="c2html-lineno" name="l218" href="#l218">218 </a>
272 <a class="c2html-lineno" name="l219" href="#l219">219 </a> <span class="c2html-comment">/* add new en passant threat */</span> 272 <a class="c2html-lineno" name="l219" href="#l219">219 </a> <span class="c2html-comment">/* add new en passant threat */</span>
273 <a class="c2html-lineno" name="l220" href="#l220">220 </a> <span class="c2html-keyword">if</span> (piece == <span class="c2html-macroconst">PAWN</span> && ( 273 <a class="c2html-lineno" name="l220" href="#l220">220 </a> <span class="c2html-keyword">if</span> (piece == <span class="c2html-macroconst">PAWN</span> &amp;&amp; (
274 <a class="c2html-lineno" name="l221" href="#l221">221 </a> (move-&gt;fromrow == <span class="c2html-macroconst">1</span> && move-&gt;torow == <span class="c2html-macroconst">3</span>) || 274 <a class="c2html-lineno" name="l221" href="#l221">221 </a> (move-&gt;fromrow == <span class="c2html-macroconst">1</span> &amp;&amp; move-&gt;torow == <span class="c2html-macroconst">3</span>) ||
275 <a class="c2html-lineno" name="l222" href="#l222">222 </a> (move-&gt;fromrow == <span class="c2html-macroconst">6</span> && move-&gt;torow == <span class="c2html-macroconst">4</span>))) { 275 <a class="c2html-lineno" name="l222" href="#l222">222 </a> (move-&gt;fromrow == <span class="c2html-macroconst">6</span> &amp;&amp; move-&gt;torow == <span class="c2html-macroconst">4</span>))) {
276 <a class="c2html-lineno" name="l223" href="#l223">223 </a> move-&gt;piece |= <span class="c2html-macroconst">ENPASSANT_THREAT</span>; 276 <a class="c2html-lineno" name="l223" href="#l223">223 </a> move-&gt;piece |= <span class="c2html-macroconst">ENPASSANT_THREAT</span>;
277 <a class="c2html-lineno" name="l224" href="#l224">224 </a> } 277 <a class="c2html-lineno" name="l224" href="#l224">224 </a> }
278 <a class="c2html-lineno" name="l225" href="#l225">225 </a> 278 <a class="c2html-lineno" name="l225" href="#l225">225 </a>
279 <a class="c2html-lineno" name="l226" href="#l226">226 </a> <span class="c2html-comment">/* move (and maybe capture or promote) */</span> 279 <a class="c2html-lineno" name="l226" href="#l226">226 </a> <span class="c2html-comment">/* move (and maybe capture or promote) */</span>
280 <a class="c2html-lineno" name="l227" href="#l227">227 </a> msrc(gamestate-&gt;board, move) = <span class="c2html-macroconst">0</span>; 280 <a class="c2html-lineno" name="l227" href="#l227">227 </a> msrc(gamestate-&gt;board, move) = <span class="c2html-macroconst">0</span>;
283 <a class="c2html-lineno" name="l230" href="#l230">230 </a> } <span class="c2html-keyword">else</span> { 283 <a class="c2html-lineno" name="l230" href="#l230">230 </a> } <span class="c2html-keyword">else</span> {
284 <a class="c2html-lineno" name="l231" href="#l231">231 </a> mdst(gamestate-&gt;board, move) = move-&gt;piece; 284 <a class="c2html-lineno" name="l231" href="#l231">231 </a> mdst(gamestate-&gt;board, move) = move-&gt;piece;
285 <a class="c2html-lineno" name="l232" href="#l232">232 </a> } 285 <a class="c2html-lineno" name="l232" href="#l232">232 </a> }
286 <a class="c2html-lineno" name="l233" href="#l233">233 </a> 286 <a class="c2html-lineno" name="l233" href="#l233">233 </a>
287 <a class="c2html-lineno" name="l234" href="#l234">234 </a> <span class="c2html-comment">/* castling */</span> 287 <a class="c2html-lineno" name="l234" href="#l234">234 </a> <span class="c2html-comment">/* castling */</span>
288 <a class="c2html-lineno" name="l235" href="#l235">235 </a> <span class="c2html-keyword">if</span> (piece == <span class="c2html-macroconst">KING</span> && move-&gt;fromfile == fileidx(<span class="c2html-string">'e'</span>)) { 288 <a class="c2html-lineno" name="l235" href="#l235">235 </a> <span class="c2html-keyword">if</span> (piece == <span class="c2html-macroconst">KING</span> &amp;&amp; move-&gt;fromfile == fileidx(<span class="c2html-string">'e'</span>)) {
289 <a class="c2html-lineno" name="l236" href="#l236">236 </a> 289 <a class="c2html-lineno" name="l236" href="#l236">236 </a>
290 <a class="c2html-lineno" name="l237" href="#l237">237 </a> <span class="c2html-keyword">if</span> (move-&gt;tofile == fileidx(<span class="c2html-string">'g'</span>)) { 290 <a class="c2html-lineno" name="l237" href="#l237">237 </a> <span class="c2html-keyword">if</span> (move-&gt;tofile == fileidx(<span class="c2html-string">'g'</span>)) {
291 <a class="c2html-lineno" name="l238" href="#l238">238 </a> gamestate-&gt;board[move-&gt;torow][fileidx(<span class="c2html-string">'h'</span>)] = <span class="c2html-macroconst">0</span>; 291 <a class="c2html-lineno" name="l238" href="#l238">238 </a> gamestate-&gt;board[move-&gt;torow][fileidx(<span class="c2html-string">'h'</span>)] = <span class="c2html-macroconst">0</span>;
292 <a class="c2html-lineno" name="l239" href="#l239">239 </a> gamestate-&gt;board[move-&gt;torow][fileidx(<span class="c2html-string">'f'</span>)] = color|<span class="c2html-macroconst">ROOK</span>; 292 <a class="c2html-lineno" name="l239" href="#l239">239 </a> gamestate-&gt;board[move-&gt;torow][fileidx(<span class="c2html-string">'f'</span>)] = color|<span class="c2html-macroconst">ROOK</span>;
293 <a class="c2html-lineno" name="l240" href="#l240">240 </a> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span> (move-&gt;tofile == fileidx(<span class="c2html-string">'c'</span>)) { 293 <a class="c2html-lineno" name="l240" href="#l240">240 </a> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span> (move-&gt;tofile == fileidx(<span class="c2html-string">'c'</span>)) {
314 <a class="c2html-lineno" name="l261" href="#l261">261 </a> <span class="c2html-keyword">if</span> (!chkidx(move)) { 314 <a class="c2html-lineno" name="l261" href="#l261">261 </a> <span class="c2html-keyword">if</span> (!chkidx(move)) {
315 <a class="c2html-lineno" name="l262" href="#l262">262 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_POSITION</span>; 315 <a class="c2html-lineno" name="l262" href="#l262">262 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_POSITION</span>;
316 <a class="c2html-lineno" name="l263" href="#l263">263 </a> } 316 <a class="c2html-lineno" name="l263" href="#l263">263 </a> }
317 <a class="c2html-lineno" name="l264" href="#l264">264 </a> 317 <a class="c2html-lineno" name="l264" href="#l264">264 </a>
318 <a class="c2html-lineno" name="l265" href="#l265">265 </a> <span class="c2html-comment">/* must move */</span> 318 <a class="c2html-lineno" name="l265" href="#l265">265 </a> <span class="c2html-comment">/* must move */</span>
319 <a class="c2html-lineno" name="l266" href="#l266">266 </a> <span class="c2html-keyword">if</span> (move-&gt;fromfile == move-&gt;tofile && move-&gt;fromrow == move-&gt;torow) { 319 <a class="c2html-lineno" name="l266" href="#l266">266 </a> <span class="c2html-keyword">if</span> (move-&gt;fromfile == move-&gt;tofile &amp;&amp; move-&gt;fromrow == move-&gt;torow) {
320 <a class="c2html-lineno" name="l267" href="#l267">267 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_MOVE_SYNTAX</span>; 320 <a class="c2html-lineno" name="l267" href="#l267">267 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_MOVE_SYNTAX</span>;
321 <a class="c2html-lineno" name="l268" href="#l268">268 </a> } 321 <a class="c2html-lineno" name="l268" href="#l268">268 </a> }
322 <a class="c2html-lineno" name="l269" href="#l269">269 </a> 322 <a class="c2html-lineno" name="l269" href="#l269">269 </a>
323 <a class="c2html-lineno" name="l270" href="#l270">270 </a> <span class="c2html-comment">/* does piece exist */</span> 323 <a class="c2html-lineno" name="l270" href="#l270">270 </a> <span class="c2html-comment">/* does piece exist */</span>
324 <a class="c2html-lineno" name="l271" href="#l271">271 </a> <span class="c2html-keyword">if</span> ((msrc(gamestate-&gt;board, move)&(<span class="c2html-macroconst">PIECE_MASK</span>|<span class="c2html-macroconst">COLOR_MASK</span>)) 324 <a class="c2html-lineno" name="l271" href="#l271">271 </a> <span class="c2html-keyword">if</span> ((msrc(gamestate-&gt;board, move)&amp;(<span class="c2html-macroconst">PIECE_MASK</span>|<span class="c2html-macroconst">COLOR_MASK</span>))
325 <a class="c2html-lineno" name="l272" href="#l272">272 </a> != (move-&gt;piece&(<span class="c2html-macroconst">PIECE_MASK</span>|<span class="c2html-macroconst">COLOR_MASK</span>))) { 325 <a class="c2html-lineno" name="l272" href="#l272">272 </a> != (move-&gt;piece&amp;(<span class="c2html-macroconst">PIECE_MASK</span>|<span class="c2html-macroconst">COLOR_MASK</span>))) {
326 <a class="c2html-lineno" name="l273" href="#l273">273 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_POSITION</span>; 326 <a class="c2html-lineno" name="l273" href="#l273">273 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_POSITION</span>;
327 <a class="c2html-lineno" name="l274" href="#l274">274 </a> } 327 <a class="c2html-lineno" name="l274" href="#l274">274 </a> }
328 <a class="c2html-lineno" name="l275" href="#l275">275 </a> 328 <a class="c2html-lineno" name="l275" href="#l275">275 </a>
329 <a class="c2html-lineno" name="l276" href="#l276">276 </a> <span class="c2html-comment">/* can't capture own pieces */</span> 329 <a class="c2html-lineno" name="l276" href="#l276">276 </a> <span class="c2html-comment">/* can't capture own pieces */</span>
330 <a class="c2html-lineno" name="l277" href="#l277">277 </a> <span class="c2html-keyword">if</span> ((mdst(gamestate-&gt;board, move) & <span class="c2html-macroconst">COLOR_MASK</span>) 330 <a class="c2html-lineno" name="l277" href="#l277">277 </a> <span class="c2html-keyword">if</span> ((mdst(gamestate-&gt;board, move) &amp; <span class="c2html-macroconst">COLOR_MASK</span>)
331 <a class="c2html-lineno" name="l278" href="#l278">278 </a> == (move-&gt;piece & <span class="c2html-macroconst">COLOR_MASK</span>)) { 331 <a class="c2html-lineno" name="l278" href="#l278">278 </a> == (move-&gt;piece &amp; <span class="c2html-macroconst">COLOR_MASK</span>)) {
332 <a class="c2html-lineno" name="l279" href="#l279">279 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">RULES_VIOLATED</span>; 332 <a class="c2html-lineno" name="l279" href="#l279">279 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">RULES_VIOLATED</span>;
333 <a class="c2html-lineno" name="l280" href="#l280">280 </a> } 333 <a class="c2html-lineno" name="l280" href="#l280">280 </a> }
334 <a class="c2html-lineno" name="l281" href="#l281">281 </a> 334 <a class="c2html-lineno" name="l281" href="#l281">281 </a>
335 <a class="c2html-lineno" name="l282" href="#l282">282 </a> <span class="c2html-comment">/* must capture, if and only if destination is occupied */</span> 335 <a class="c2html-lineno" name="l282" href="#l282">282 </a> <span class="c2html-comment">/* must capture, if and only if destination is occupied */</span>
336 <a class="c2html-lineno" name="l283" href="#l283">283 </a> <span class="c2html-keyword">if</span> ((mdst(gamestate-&gt;board, move) == <span class="c2html-macroconst">0</span> && move-&gt;capture) || 336 <a class="c2html-lineno" name="l283" href="#l283">283 </a> <span class="c2html-keyword">if</span> ((mdst(gamestate-&gt;board, move) == <span class="c2html-macroconst">0</span> &amp;&amp; move-&gt;capture) ||
337 <a class="c2html-lineno" name="l284" href="#l284">284 </a> (mdst(gamestate-&gt;board, move) != <span class="c2html-macroconst">0</span> && !move-&gt;capture)) { 337 <a class="c2html-lineno" name="l284" href="#l284">284 </a> (mdst(gamestate-&gt;board, move) != <span class="c2html-macroconst">0</span> &amp;&amp; !move-&gt;capture)) {
338 <a class="c2html-lineno" name="l285" href="#l285">285 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_MOVE_SYNTAX</span>; 338 <a class="c2html-lineno" name="l285" href="#l285">285 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_MOVE_SYNTAX</span>;
339 <a class="c2html-lineno" name="l286" href="#l286">286 </a> } 339 <a class="c2html-lineno" name="l286" href="#l286">286 </a> }
340 <a class="c2html-lineno" name="l287" href="#l287">287 </a> 340 <a class="c2html-lineno" name="l287" href="#l287">287 </a>
341 <a class="c2html-lineno" name="l288" href="#l288">288 </a> <span class="c2html-comment">/* validate individual rules */</span> 341 <a class="c2html-lineno" name="l288" href="#l288">288 </a> <span class="c2html-comment">/* validate individual rules */</span>
342 <a class="c2html-lineno" name="l289" href="#l289">289 </a> _Bool chkrules; 342 <a class="c2html-lineno" name="l289" href="#l289">289 </a> _Bool chkrules;
343 <a class="c2html-lineno" name="l290" href="#l290">290 </a> <span class="c2html-keyword">switch</span> (move-&gt;piece & <span class="c2html-macroconst">PIECE_MASK</span>) { 343 <a class="c2html-lineno" name="l290" href="#l290">290 </a> <span class="c2html-keyword">switch</span> (move-&gt;piece &amp; <span class="c2html-macroconst">PIECE_MASK</span>) {
344 <a class="c2html-lineno" name="l291" href="#l291">291 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">PAWN</span>: 344 <a class="c2html-lineno" name="l291" href="#l291">291 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">PAWN</span>:
345 <a class="c2html-lineno" name="l292" href="#l292">292 </a> chkrules = pawn_chkrules(gamestate, move) && 345 <a class="c2html-lineno" name="l292" href="#l292">292 </a> chkrules = pawn_chkrules(gamestate, move) &amp;&amp;
346 <a class="c2html-lineno" name="l293" href="#l293">293 </a> !pawn_isblocked(gamestate, move); 346 <a class="c2html-lineno" name="l293" href="#l293">293 </a> !pawn_isblocked(gamestate, move);
347 <a class="c2html-lineno" name="l294" href="#l294">294 </a> <span class="c2html-keyword">break</span>; 347 <a class="c2html-lineno" name="l294" href="#l294">294 </a> <span class="c2html-keyword">break</span>;
348 <a class="c2html-lineno" name="l295" href="#l295">295 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">ROOK</span>: 348 <a class="c2html-lineno" name="l295" href="#l295">295 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">ROOK</span>:
349 <a class="c2html-lineno" name="l296" href="#l296">296 </a> chkrules = rook_chkrules(move) && 349 <a class="c2html-lineno" name="l296" href="#l296">296 </a> chkrules = rook_chkrules(move) &amp;&amp;
350 <a class="c2html-lineno" name="l297" href="#l297">297 </a> !rook_isblocked(gamestate, move); 350 <a class="c2html-lineno" name="l297" href="#l297">297 </a> !rook_isblocked(gamestate, move);
351 <a class="c2html-lineno" name="l298" href="#l298">298 </a> <span class="c2html-keyword">break</span>; 351 <a class="c2html-lineno" name="l298" href="#l298">298 </a> <span class="c2html-keyword">break</span>;
352 <a class="c2html-lineno" name="l299" href="#l299">299 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">KNIGHT</span>: 352 <a class="c2html-lineno" name="l299" href="#l299">299 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">KNIGHT</span>:
353 <a class="c2html-lineno" name="l300" href="#l300">300 </a> chkrules = knight_chkrules(move); <span class="c2html-comment">/* knight is never blocked */</span> 353 <a class="c2html-lineno" name="l300" href="#l300">300 </a> chkrules = knight_chkrules(move); <span class="c2html-comment">/* knight is never blocked */</span>
354 <a class="c2html-lineno" name="l301" href="#l301">301 </a> <span class="c2html-keyword">break</span>; 354 <a class="c2html-lineno" name="l301" href="#l301">301 </a> <span class="c2html-keyword">break</span>;
355 <a class="c2html-lineno" name="l302" href="#l302">302 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">BISHOP</span>: 355 <a class="c2html-lineno" name="l302" href="#l302">302 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">BISHOP</span>:
356 <a class="c2html-lineno" name="l303" href="#l303">303 </a> chkrules = bishop_chkrules(move) && 356 <a class="c2html-lineno" name="l303" href="#l303">303 </a> chkrules = bishop_chkrules(move) &amp;&amp;
357 <a class="c2html-lineno" name="l304" href="#l304">304 </a> !bishop_isblocked(gamestate, move); 357 <a class="c2html-lineno" name="l304" href="#l304">304 </a> !bishop_isblocked(gamestate, move);
358 <a class="c2html-lineno" name="l305" href="#l305">305 </a> <span class="c2html-keyword">break</span>; 358 <a class="c2html-lineno" name="l305" href="#l305">305 </a> <span class="c2html-keyword">break</span>;
359 <a class="c2html-lineno" name="l306" href="#l306">306 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">QUEEN</span>: 359 <a class="c2html-lineno" name="l306" href="#l306">306 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">QUEEN</span>:
360 <a class="c2html-lineno" name="l307" href="#l307">307 </a> chkrules = queen_chkrules(move) && 360 <a class="c2html-lineno" name="l307" href="#l307">307 </a> chkrules = queen_chkrules(move) &amp;&amp;
361 <a class="c2html-lineno" name="l308" href="#l308">308 </a> !queen_isblocked(gamestate, move); 361 <a class="c2html-lineno" name="l308" href="#l308">308 </a> !queen_isblocked(gamestate, move);
362 <a class="c2html-lineno" name="l309" href="#l309">309 </a> <span class="c2html-keyword">break</span>; 362 <a class="c2html-lineno" name="l309" href="#l309">309 </a> <span class="c2html-keyword">break</span>;
363 <a class="c2html-lineno" name="l310" href="#l310">310 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">KING</span>: 363 <a class="c2html-lineno" name="l310" href="#l310">310 </a> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">KING</span>:
364 <a class="c2html-lineno" name="l311" href="#l311">311 </a> chkrules = king_chkrules(gamestate, move) && 364 <a class="c2html-lineno" name="l311" href="#l311">311 </a> chkrules = king_chkrules(gamestate, move) &amp;&amp;
365 <a class="c2html-lineno" name="l312" href="#l312">312 </a> !king_isblocked(gamestate, move); 365 <a class="c2html-lineno" name="l312" href="#l312">312 </a> !king_isblocked(gamestate, move);
366 <a class="c2html-lineno" name="l313" href="#l313">313 </a> <span class="c2html-keyword">break</span>; 366 <a class="c2html-lineno" name="l313" href="#l313">313 </a> <span class="c2html-keyword">break</span>;
367 <a class="c2html-lineno" name="l314" href="#l314">314 </a> <span class="c2html-keyword">default</span>: 367 <a class="c2html-lineno" name="l314" href="#l314">314 </a> <span class="c2html-keyword">default</span>:
368 <a class="c2html-lineno" name="l315" href="#l315">315 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_MOVE_SYNTAX</span>; 368 <a class="c2html-lineno" name="l315" href="#l315">315 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_MOVE_SYNTAX</span>;
369 <a class="c2html-lineno" name="l316" href="#l316">316 </a> } 369 <a class="c2html-lineno" name="l316" href="#l316">316 </a> }
379 <a class="c2html-lineno" name="l326" href="#l326">326 </a> <span class="c2html-keyword">if</span> (result != <span class="c2html-macroconst">VALID_MOVE_SEMANTICS</span>) { 379 <a class="c2html-lineno" name="l326" href="#l326">326 </a> <span class="c2html-keyword">if</span> (result != <span class="c2html-macroconst">VALID_MOVE_SEMANTICS</span>) {
380 <a class="c2html-lineno" name="l327" href="#l327">327 </a> <span class="c2html-keyword">return</span> result; 380 <a class="c2html-lineno" name="l327" href="#l327">327 </a> <span class="c2html-keyword">return</span> result;
381 <a class="c2html-lineno" name="l328" href="#l328">328 </a> } 381 <a class="c2html-lineno" name="l328" href="#l328">328 </a> }
382 <a class="c2html-lineno" name="l329" href="#l329">329 </a> 382 <a class="c2html-lineno" name="l329" href="#l329">329 </a>
383 <a class="c2html-lineno" name="l330" href="#l330">330 </a> <span class="c2html-comment">/* find kings for check validation */</span> 383 <a class="c2html-lineno" name="l330" href="#l330">330 </a> <span class="c2html-comment">/* find kings for check validation */</span>
384 <a class="c2html-lineno" name="l331" href="#l331">331 </a> <span class="c2html-type">uint8_t</span> piececolor = (move-&gt;piece & <span class="c2html-macroconst">COLOR_MASK</span>); 384 <a class="c2html-lineno" name="l331" href="#l331">331 </a> <span class="c2html-type">uint8_t</span> piececolor = (move-&gt;piece &amp; <span class="c2html-macroconst">COLOR_MASK</span>);
385 <a class="c2html-lineno" name="l332" href="#l332">332 </a> 385 <a class="c2html-lineno" name="l332" href="#l332">332 </a>
386 <a class="c2html-lineno" name="l333" href="#l333">333 </a> <span class="c2html-type">uint8_t</span> mykingfile = <span class="c2html-macroconst">0</span>, mykingrow = <span class="c2html-macroconst">0</span>, opkingfile = <span class="c2html-macroconst">0</span>, opkingrow = <span class="c2html-macroconst">0</span>; 386 <a class="c2html-lineno" name="l333" href="#l333">333 </a> <span class="c2html-type">uint8_t</span> mykingfile = <span class="c2html-macroconst">0</span>, mykingrow = <span class="c2html-macroconst">0</span>, opkingfile = <span class="c2html-macroconst">0</span>, opkingrow = <span class="c2html-macroconst">0</span>;
387 <a class="c2html-lineno" name="l334" href="#l334">334 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> row = <span class="c2html-macroconst">0</span> ; row &lt; <span class="c2html-macroconst">8</span> ; row++) { 387 <a class="c2html-lineno" name="l334" href="#l334">334 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> row = <span class="c2html-macroconst">0</span> ; row &lt; <span class="c2html-macroconst">8</span> ; row++) {
388 <a class="c2html-lineno" name="l335" href="#l335">335 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> file = <span class="c2html-macroconst">0</span> ; file &lt; <span class="c2html-macroconst">8</span> ; file++) { 388 <a class="c2html-lineno" name="l335" href="#l335">335 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> file = <span class="c2html-macroconst">0</span> ; file &lt; <span class="c2html-macroconst">8</span> ; file++) {
389 <a class="c2html-lineno" name="l336" href="#l336">336 </a> <span class="c2html-keyword">if</span> (gamestate-&gt;board[row][file] == 389 <a class="c2html-lineno" name="l336" href="#l336">336 </a> <span class="c2html-keyword">if</span> (gamestate-&gt;board[row][file] ==
399 <a class="c2html-lineno" name="l346" href="#l346">346 </a> } 399 <a class="c2html-lineno" name="l346" href="#l346">346 </a> }
400 <a class="c2html-lineno" name="l347" href="#l347">347 </a> 400 <a class="c2html-lineno" name="l347" href="#l347">347 </a>
401 <a class="c2html-lineno" name="l348" href="#l348">348 </a> <span class="c2html-comment">/* simulate move for check validation */</span> 401 <a class="c2html-lineno" name="l348" href="#l348">348 </a> <span class="c2html-comment">/* simulate move for check validation */</span>
402 <a class="c2html-lineno" name="l349" href="#l349">349 </a> GameState simulation = gamestate_copy_sim(gamestate); 402 <a class="c2html-lineno" name="l349" href="#l349">349 </a> GameState simulation = gamestate_copy_sim(gamestate);
403 <a class="c2html-lineno" name="l350" href="#l350">350 </a> Move simmove = *move; 403 <a class="c2html-lineno" name="l350" href="#l350">350 </a> Move simmove = *move;
404 <a class="c2html-lineno" name="l351" href="#l351">351 </a> apply_move_impl(&simulation, &simmove, <span class="c2html-macroconst">1</span>); 404 <a class="c2html-lineno" name="l351" href="#l351">351 </a> apply_move_impl(&amp;simulation, &amp;simmove, <span class="c2html-macroconst">1</span>);
405 <a class="c2html-lineno" name="l352" href="#l352">352 </a> 405 <a class="c2html-lineno" name="l352" href="#l352">352 </a>
406 <a class="c2html-lineno" name="l353" href="#l353">353 </a> <span class="c2html-comment">/* don't move into or stay in check position */</span> 406 <a class="c2html-lineno" name="l353" href="#l353">353 </a> <span class="c2html-comment">/* don't move into or stay in check position */</span>
407 <a class="c2html-lineno" name="l354" href="#l354">354 </a> <span class="c2html-keyword">if</span> (is_covered(&simulation, mykingrow, mykingfile, 407 <a class="c2html-lineno" name="l354" href="#l354">354 </a> <span class="c2html-keyword">if</span> (is_covered(&amp;simulation, mykingrow, mykingfile,
408 <a class="c2html-lineno" name="l355" href="#l355">355 </a> opponent_color(piececolor))) { 408 <a class="c2html-lineno" name="l355" href="#l355">355 </a> opponent_color(piececolor))) {
409 <a class="c2html-lineno" name="l356" href="#l356">356 </a> 409 <a class="c2html-lineno" name="l356" href="#l356">356 </a>
410 <a class="c2html-lineno" name="l357" href="#l357">357 </a> gamestate_cleanup(&simulation); 410 <a class="c2html-lineno" name="l357" href="#l357">357 </a> gamestate_cleanup(&amp;simulation);
411 <a class="c2html-lineno" name="l358" href="#l358">358 </a> <span class="c2html-keyword">if</span> ((move-&gt;piece & <span class="c2html-macroconst">PIECE_MASK</span>) == <span class="c2html-macroconst">KING</span>) { 411 <a class="c2html-lineno" name="l358" href="#l358">358 </a> <span class="c2html-keyword">if</span> ((move-&gt;piece &amp; <span class="c2html-macroconst">PIECE_MASK</span>) == <span class="c2html-macroconst">KING</span>) {
412 <a class="c2html-lineno" name="l359" href="#l359">359 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">KING_MOVES_INTO_CHECK</span>; 412 <a class="c2html-lineno" name="l359" href="#l359">359 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">KING_MOVES_INTO_CHECK</span>;
413 <a class="c2html-lineno" name="l360" href="#l360">360 </a> } <span class="c2html-keyword">else</span> { 413 <a class="c2html-lineno" name="l360" href="#l360">360 </a> } <span class="c2html-keyword">else</span> {
414 <a class="c2html-lineno" name="l361" href="#l361">361 </a> <span class="c2html-comment">/* last move is always not null in this case */</span> 414 <a class="c2html-lineno" name="l361" href="#l361">361 </a> <span class="c2html-comment">/* last move is always not null in this case */</span>
415 <a class="c2html-lineno" name="l362" href="#l362">362 </a> <span class="c2html-keyword">return</span> gamestate-&gt;lastmove-&gt;move.check ? 415 <a class="c2html-lineno" name="l362" href="#l362">362 </a> <span class="c2html-keyword">return</span> gamestate-&gt;lastmove-&gt;move.check ?
416 <a class="c2html-lineno" name="l363" href="#l363">363 </a> <span class="c2html-macroconst">KING_IN_CHECK</span> : <span class="c2html-macroconst">PIECE_PINNED</span>; 416 <a class="c2html-lineno" name="l363" href="#l363">363 </a> <span class="c2html-macroconst">KING_IN_CHECK</span> : <span class="c2html-macroconst">PIECE_PINNED</span>;
418 <a class="c2html-lineno" name="l365" href="#l365">365 </a> } 418 <a class="c2html-lineno" name="l365" href="#l365">365 </a> }
419 <a class="c2html-lineno" name="l366" href="#l366">366 </a> 419 <a class="c2html-lineno" name="l366" href="#l366">366 </a>
420 <a class="c2html-lineno" name="l367" href="#l367">367 </a> <span class="c2html-comment">/* correct check and checkmate flags (move is still valid) */</span> 420 <a class="c2html-lineno" name="l367" href="#l367">367 </a> <span class="c2html-comment">/* correct check and checkmate flags (move is still valid) */</span>
421 <a class="c2html-lineno" name="l368" href="#l368">368 </a> Move threats[<span class="c2html-macroconst">16</span>]; 421 <a class="c2html-lineno" name="l368" href="#l368">368 </a> Move threats[<span class="c2html-macroconst">16</span>];
422 <a class="c2html-lineno" name="l369" href="#l369">369 </a> <span class="c2html-type">uint8_t</span> threatcount; 422 <a class="c2html-lineno" name="l369" href="#l369">369 </a> <span class="c2html-type">uint8_t</span> threatcount;
423 <a class="c2html-lineno" name="l370" href="#l370">370 </a> move-&gt;check = get_threats(&simulation, opkingrow, opkingfile, 423 <a class="c2html-lineno" name="l370" href="#l370">370 </a> move-&gt;check = get_threats(&amp;simulation, opkingrow, opkingfile,
424 <a class="c2html-lineno" name="l371" href="#l371">371 </a> piececolor, threats, &threatcount); 424 <a class="c2html-lineno" name="l371" href="#l371">371 </a> piececolor, threats, &amp;threatcount);
425 <a class="c2html-lineno" name="l372" href="#l372">372 </a> 425 <a class="c2html-lineno" name="l372" href="#l372">372 </a>
426 <a class="c2html-lineno" name="l373" href="#l373">373 </a> <span class="c2html-keyword">if</span> (move-&gt;check) { 426 <a class="c2html-lineno" name="l373" href="#l373">373 </a> <span class="c2html-keyword">if</span> (move-&gt;check) {
427 <a class="c2html-lineno" name="l374" href="#l374">374 </a> <span class="c2html-comment">/* determine possible escape fields */</span> 427 <a class="c2html-lineno" name="l374" href="#l374">374 </a> <span class="c2html-comment">/* determine possible escape fields */</span>
428 <a class="c2html-lineno" name="l375" href="#l375">375 </a> _Bool canescape = <span class="c2html-macroconst">0</span>; 428 <a class="c2html-lineno" name="l375" href="#l375">375 </a> _Bool canescape = <span class="c2html-macroconst">0</span>;
429 <a class="c2html-lineno" name="l376" href="#l376">376 </a> <span class="c2html-keyword">for</span> (<span class="c2html-keyword">int</span> dr = -<span class="c2html-macroconst">1</span> ; dr &lt;= <span class="c2html-macroconst">1</span> && !canescape ; dr++) { 429 <a class="c2html-lineno" name="l376" href="#l376">376 </a> <span class="c2html-keyword">for</span> (<span class="c2html-keyword">int</span> dr = -<span class="c2html-macroconst">1</span> ; dr &lt;= <span class="c2html-macroconst">1</span> &amp;&amp; !canescape ; dr++) {
430 <a class="c2html-lineno" name="l377" href="#l377">377 </a> <span class="c2html-keyword">for</span> (<span class="c2html-keyword">int</span> df = -<span class="c2html-macroconst">1</span> ; df &lt;= <span class="c2html-macroconst">1</span> && !canescape ; df++) { 430 <a class="c2html-lineno" name="l377" href="#l377">377 </a> <span class="c2html-keyword">for</span> (<span class="c2html-keyword">int</span> df = -<span class="c2html-macroconst">1</span> ; df &lt;= <span class="c2html-macroconst">1</span> &amp;&amp; !canescape ; df++) {
431 <a class="c2html-lineno" name="l378" href="#l378">378 </a> <span class="c2html-keyword">if</span> (!(dr == <span class="c2html-macroconst">0</span> && df == <span class="c2html-macroconst">0</span>) && 431 <a class="c2html-lineno" name="l378" href="#l378">378 </a> <span class="c2html-keyword">if</span> (!(dr == <span class="c2html-macroconst">0</span> &amp;&amp; df == <span class="c2html-macroconst">0</span>) &amp;&amp;
432 <a class="c2html-lineno" name="l379" href="#l379">379 </a> isidx(opkingrow + dr) && isidx(opkingfile + df)) { 432 <a class="c2html-lineno" name="l379" href="#l379">379 </a> isidx(opkingrow + dr) &amp;&amp; isidx(opkingfile + df)) {
433 <a class="c2html-lineno" name="l380" href="#l380">380 </a> 433 <a class="c2html-lineno" name="l380" href="#l380">380 </a>
434 <a class="c2html-lineno" name="l381" href="#l381">381 </a> <span class="c2html-comment">/* escape field neither blocked nor covered */</span> 434 <a class="c2html-lineno" name="l381" href="#l381">381 </a> <span class="c2html-comment">/* escape field neither blocked nor covered */</span>
435 <a class="c2html-lineno" name="l382" href="#l382">382 </a> <span class="c2html-keyword">if</span> ((simulation.board[opkingrow + dr][opkingfile + df] 435 <a class="c2html-lineno" name="l382" href="#l382">382 </a> <span class="c2html-keyword">if</span> ((simulation.board[opkingrow + dr][opkingfile + df]
436 <a class="c2html-lineno" name="l383" href="#l383">383 </a> & <span class="c2html-macroconst">COLOR_MASK</span>) != opponent_color(piececolor)) { 436 <a class="c2html-lineno" name="l383" href="#l383">383 </a> &amp; <span class="c2html-macroconst">COLOR_MASK</span>) != opponent_color(piececolor)) {
437 <a class="c2html-lineno" name="l384" href="#l384">384 </a> canescape |= !is_covered(&simulation, 437 <a class="c2html-lineno" name="l384" href="#l384">384 </a> canescape |= !is_covered(&amp;simulation,
438 <a class="c2html-lineno" name="l385" href="#l385">385 </a> opkingrow + dr, opkingfile + df, piececolor); 438 <a class="c2html-lineno" name="l385" href="#l385">385 </a> opkingrow + dr, opkingfile + df, piececolor);
439 <a class="c2html-lineno" name="l386" href="#l386">386 </a> } 439 <a class="c2html-lineno" name="l386" href="#l386">386 </a> }
440 <a class="c2html-lineno" name="l387" href="#l387">387 </a> } 440 <a class="c2html-lineno" name="l387" href="#l387">387 </a> }
441 <a class="c2html-lineno" name="l388" href="#l388">388 </a> } 441 <a class="c2html-lineno" name="l388" href="#l388">388 </a> }
442 <a class="c2html-lineno" name="l389" href="#l389">389 </a> } 442 <a class="c2html-lineno" name="l389" href="#l389">389 </a> }
443 <a class="c2html-lineno" name="l390" href="#l390">390 </a> <span class="c2html-comment">/* can't escape, can he capture? */</span> 443 <a class="c2html-lineno" name="l390" href="#l390">390 </a> <span class="c2html-comment">/* can't escape, can he capture? */</span>
444 <a class="c2html-lineno" name="l391" href="#l391">391 </a> <span class="c2html-keyword">if</span> (!canescape && threatcount == <span class="c2html-macroconst">1</span>) { 444 <a class="c2html-lineno" name="l391" href="#l391">391 </a> <span class="c2html-keyword">if</span> (!canescape &amp;&amp; threatcount == <span class="c2html-macroconst">1</span>) {
445 <a class="c2html-lineno" name="l392" href="#l392">392 </a> canescape = is_attacked(&simulation, threats[<span class="c2html-macroconst">0</span>].fromrow, 445 <a class="c2html-lineno" name="l392" href="#l392">392 </a> canescape = is_attacked(&amp;simulation, threats[<span class="c2html-macroconst">0</span>].fromrow,
446 <a class="c2html-lineno" name="l393" href="#l393">393 </a> threats[<span class="c2html-macroconst">0</span>].fromfile, opponent_color(piececolor)); 446 <a class="c2html-lineno" name="l393" href="#l393">393 </a> threats[<span class="c2html-macroconst">0</span>].fromfile, opponent_color(piececolor));
447 <a class="c2html-lineno" name="l394" href="#l394">394 </a> } 447 <a class="c2html-lineno" name="l394" href="#l394">394 </a> }
448 <a class="c2html-lineno" name="l395" href="#l395">395 </a> 448 <a class="c2html-lineno" name="l395" href="#l395">395 </a>
449 <a class="c2html-lineno" name="l396" href="#l396">396 </a> <span class="c2html-comment">/* can't capture, can he block? */</span> 449 <a class="c2html-lineno" name="l396" href="#l396">396 </a> <span class="c2html-comment">/* can't capture, can he block? */</span>
450 <a class="c2html-lineno" name="l397" href="#l397">397 </a> <span class="c2html-keyword">if</span> (!canescape && threatcount == <span class="c2html-macroconst">1</span>) { 450 <a class="c2html-lineno" name="l397" href="#l397">397 </a> <span class="c2html-keyword">if</span> (!canescape &amp;&amp; threatcount == <span class="c2html-macroconst">1</span>) {
451 <a class="c2html-lineno" name="l398" href="#l398">398 </a> Move *threat = &(threats[<span class="c2html-macroconst">0</span>]); 451 <a class="c2html-lineno" name="l398" href="#l398">398 </a> Move *threat = &amp;(threats[<span class="c2html-macroconst">0</span>]);
452 <a class="c2html-lineno" name="l399" href="#l399">399 </a> <span class="c2html-type">uint8_t</span> threatpiece = threat-&gt;piece & <span class="c2html-macroconst">PIECE_MASK</span>; 452 <a class="c2html-lineno" name="l399" href="#l399">399 </a> <span class="c2html-type">uint8_t</span> threatpiece = threat-&gt;piece &amp; <span class="c2html-macroconst">PIECE_MASK</span>;
453 <a class="c2html-lineno" name="l400" href="#l400">400 </a> 453 <a class="c2html-lineno" name="l400" href="#l400">400 </a>
454 <a class="c2html-lineno" name="l401" href="#l401">401 </a> <span class="c2html-comment">/* knight, pawns and the king cannot be blocked */</span> 454 <a class="c2html-lineno" name="l401" href="#l401">401 </a> <span class="c2html-comment">/* knight, pawns and the king cannot be blocked */</span>
455 <a class="c2html-lineno" name="l402" href="#l402">402 </a> <span class="c2html-keyword">if</span> (threatpiece == <span class="c2html-macroconst">BISHOP</span> || threatpiece == <span class="c2html-macroconst">ROOK</span> 455 <a class="c2html-lineno" name="l402" href="#l402">402 </a> <span class="c2html-keyword">if</span> (threatpiece == <span class="c2html-macroconst">BISHOP</span> || threatpiece == <span class="c2html-macroconst">ROOK</span>
456 <a class="c2html-lineno" name="l403" href="#l403">403 </a> || threatpiece == <span class="c2html-macroconst">QUEEN</span>) { 456 <a class="c2html-lineno" name="l403" href="#l403">403 </a> || threatpiece == <span class="c2html-macroconst">QUEEN</span>) {
457 <a class="c2html-lineno" name="l404" href="#l404">404 </a> <span class="c2html-keyword">if</span> (threat-&gt;fromrow == threat-&gt;torow) { 457 <a class="c2html-lineno" name="l404" href="#l404">404 </a> <span class="c2html-keyword">if</span> (threat-&gt;fromrow == threat-&gt;torow) {
458 <a class="c2html-lineno" name="l405" href="#l405">405 </a> <span class="c2html-comment">/* rook aspect (on row) */</span> 458 <a class="c2html-lineno" name="l405" href="#l405">405 </a> <span class="c2html-comment">/* rook aspect (on row) */</span>
459 <a class="c2html-lineno" name="l406" href="#l406">406 </a> <span class="c2html-keyword">int</span> d = threat-&gt;tofile &gt; threat-&gt;fromfile ? <span class="c2html-macroconst">1</span> : -<span class="c2html-macroconst">1</span>; 459 <a class="c2html-lineno" name="l406" href="#l406">406 </a> <span class="c2html-keyword">int</span> d = threat-&gt;tofile &gt; threat-&gt;fromfile ? <span class="c2html-macroconst">1</span> : -<span class="c2html-macroconst">1</span>;
460 <a class="c2html-lineno" name="l407" href="#l407">407 </a> <span class="c2html-type">uint8_t</span> file = threat-&gt;fromfile; 460 <a class="c2html-lineno" name="l407" href="#l407">407 </a> <span class="c2html-type">uint8_t</span> file = threat-&gt;fromfile;
461 <a class="c2html-lineno" name="l408" href="#l408">408 </a> <span class="c2html-keyword">while</span> (!canescape && file != threat-&gt;tofile - d) { 461 <a class="c2html-lineno" name="l408" href="#l408">408 </a> <span class="c2html-keyword">while</span> (!canescape &amp;&amp; file != threat-&gt;tofile - d) {
462 <a class="c2html-lineno" name="l409" href="#l409">409 </a> file += d; 462 <a class="c2html-lineno" name="l409" href="#l409">409 </a> file += d;
463 <a class="c2html-lineno" name="l410" href="#l410">410 </a> canescape |= is_protected(&simulation, 463 <a class="c2html-lineno" name="l410" href="#l410">410 </a> canescape |= is_protected(&amp;simulation,
464 <a class="c2html-lineno" name="l411" href="#l411">411 </a> threat-&gt;torow, file, opponent_color(piececolor)); 464 <a class="c2html-lineno" name="l411" href="#l411">411 </a> threat-&gt;torow, file, opponent_color(piececolor));
465 <a class="c2html-lineno" name="l412" href="#l412">412 </a> } 465 <a class="c2html-lineno" name="l412" href="#l412">412 </a> }
466 <a class="c2html-lineno" name="l413" href="#l413">413 </a> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span> (threat-&gt;fromfile == threat-&gt;tofile) { 466 <a class="c2html-lineno" name="l413" href="#l413">413 </a> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span> (threat-&gt;fromfile == threat-&gt;tofile) {
467 <a class="c2html-lineno" name="l414" href="#l414">414 </a> <span class="c2html-comment">/* rook aspect (on file) */</span> 467 <a class="c2html-lineno" name="l414" href="#l414">414 </a> <span class="c2html-comment">/* rook aspect (on file) */</span>
468 <a class="c2html-lineno" name="l415" href="#l415">415 </a> <span class="c2html-keyword">int</span> d = threat-&gt;torow &gt; threat-&gt;fromrow ? <span class="c2html-macroconst">1</span> : -<span class="c2html-macroconst">1</span>; 468 <a class="c2html-lineno" name="l415" href="#l415">415 </a> <span class="c2html-keyword">int</span> d = threat-&gt;torow &gt; threat-&gt;fromrow ? <span class="c2html-macroconst">1</span> : -<span class="c2html-macroconst">1</span>;
469 <a class="c2html-lineno" name="l416" href="#l416">416 </a> <span class="c2html-type">uint8_t</span> row = threat-&gt;fromrow; 469 <a class="c2html-lineno" name="l416" href="#l416">416 </a> <span class="c2html-type">uint8_t</span> row = threat-&gt;fromrow;
470 <a class="c2html-lineno" name="l417" href="#l417">417 </a> <span class="c2html-keyword">while</span> (!canescape && row != threat-&gt;torow - d) { 470 <a class="c2html-lineno" name="l417" href="#l417">417 </a> <span class="c2html-keyword">while</span> (!canescape &amp;&amp; row != threat-&gt;torow - d) {
471 <a class="c2html-lineno" name="l418" href="#l418">418 </a> row += d; 471 <a class="c2html-lineno" name="l418" href="#l418">418 </a> row += d;
472 <a class="c2html-lineno" name="l419" href="#l419">419 </a> canescape |= is_protected(&simulation, 472 <a class="c2html-lineno" name="l419" href="#l419">419 </a> canescape |= is_protected(&amp;simulation,
473 <a class="c2html-lineno" name="l420" href="#l420">420 </a> row, threat-&gt;tofile, opponent_color(piececolor)); 473 <a class="c2html-lineno" name="l420" href="#l420">420 </a> row, threat-&gt;tofile, opponent_color(piececolor));
474 <a class="c2html-lineno" name="l421" href="#l421">421 </a> } 474 <a class="c2html-lineno" name="l421" href="#l421">421 </a> }
475 <a class="c2html-lineno" name="l422" href="#l422">422 </a> } <span class="c2html-keyword">else</span> { 475 <a class="c2html-lineno" name="l422" href="#l422">422 </a> } <span class="c2html-keyword">else</span> {
476 <a class="c2html-lineno" name="l423" href="#l423">423 </a> <span class="c2html-comment">/* bishop aspect */</span> 476 <a class="c2html-lineno" name="l423" href="#l423">423 </a> <span class="c2html-comment">/* bishop aspect */</span>
477 <a class="c2html-lineno" name="l424" href="#l424">424 </a> <span class="c2html-keyword">int</span> dr = threat-&gt;torow &gt; threat-&gt;fromrow ? <span class="c2html-macroconst">1</span> : -<span class="c2html-macroconst">1</span>; 477 <a class="c2html-lineno" name="l424" href="#l424">424 </a> <span class="c2html-keyword">int</span> dr = threat-&gt;torow &gt; threat-&gt;fromrow ? <span class="c2html-macroconst">1</span> : -<span class="c2html-macroconst">1</span>;
478 <a class="c2html-lineno" name="l425" href="#l425">425 </a> <span class="c2html-keyword">int</span> df = threat-&gt;tofile &gt; threat-&gt;fromfile ? <span class="c2html-macroconst">1</span> : -<span class="c2html-macroconst">1</span>; 478 <a class="c2html-lineno" name="l425" href="#l425">425 </a> <span class="c2html-keyword">int</span> df = threat-&gt;tofile &gt; threat-&gt;fromfile ? <span class="c2html-macroconst">1</span> : -<span class="c2html-macroconst">1</span>;
479 <a class="c2html-lineno" name="l426" href="#l426">426 </a> 479 <a class="c2html-lineno" name="l426" href="#l426">426 </a>
480 <a class="c2html-lineno" name="l427" href="#l427">427 </a> <span class="c2html-type">uint8_t</span> row = threat-&gt;fromrow; 480 <a class="c2html-lineno" name="l427" href="#l427">427 </a> <span class="c2html-type">uint8_t</span> row = threat-&gt;fromrow;
481 <a class="c2html-lineno" name="l428" href="#l428">428 </a> <span class="c2html-type">uint8_t</span> file = threat-&gt;fromfile; 481 <a class="c2html-lineno" name="l428" href="#l428">428 </a> <span class="c2html-type">uint8_t</span> file = threat-&gt;fromfile;
482 <a class="c2html-lineno" name="l429" href="#l429">429 </a> <span class="c2html-keyword">while</span> (!canescape && file != threat-&gt;tofile - df 482 <a class="c2html-lineno" name="l429" href="#l429">429 </a> <span class="c2html-keyword">while</span> (!canescape &amp;&amp; file != threat-&gt;tofile - df
483 <a class="c2html-lineno" name="l430" href="#l430">430 </a> && row != threat-&gt;torow - dr) { 483 <a class="c2html-lineno" name="l430" href="#l430">430 </a> &amp;&amp; row != threat-&gt;torow - dr) {
484 <a class="c2html-lineno" name="l431" href="#l431">431 </a> row += dr; 484 <a class="c2html-lineno" name="l431" href="#l431">431 </a> row += dr;
485 <a class="c2html-lineno" name="l432" href="#l432">432 </a> file += df; 485 <a class="c2html-lineno" name="l432" href="#l432">432 </a> file += df;
486 <a class="c2html-lineno" name="l433" href="#l433">433 </a> canescape |= is_protected(&simulation, row, file, 486 <a class="c2html-lineno" name="l433" href="#l433">433 </a> canescape |= is_protected(&amp;simulation, row, file,
487 <a class="c2html-lineno" name="l434" href="#l434">434 </a> opponent_color(piececolor)); 487 <a class="c2html-lineno" name="l434" href="#l434">434 </a> opponent_color(piececolor));
488 <a class="c2html-lineno" name="l435" href="#l435">435 </a> } 488 <a class="c2html-lineno" name="l435" href="#l435">435 </a> }
489 <a class="c2html-lineno" name="l436" href="#l436">436 </a> } 489 <a class="c2html-lineno" name="l436" href="#l436">436 </a> }
490 <a class="c2html-lineno" name="l437" href="#l437">437 </a> } 490 <a class="c2html-lineno" name="l437" href="#l437">437 </a> }
491 <a class="c2html-lineno" name="l438" href="#l438">438 </a> } 491 <a class="c2html-lineno" name="l438" href="#l438">438 </a> }
493 <a class="c2html-lineno" name="l440" href="#l440">440 </a> <span class="c2html-keyword">if</span> (!canescape) { 493 <a class="c2html-lineno" name="l440" href="#l440">440 </a> <span class="c2html-keyword">if</span> (!canescape) {
494 <a class="c2html-lineno" name="l441" href="#l441">441 </a> gamestate-&gt;checkmate = <span class="c2html-macroconst">1</span>; 494 <a class="c2html-lineno" name="l441" href="#l441">441 </a> gamestate-&gt;checkmate = <span class="c2html-macroconst">1</span>;
495 <a class="c2html-lineno" name="l442" href="#l442">442 </a> } 495 <a class="c2html-lineno" name="l442" href="#l442">442 </a> }
496 <a class="c2html-lineno" name="l443" href="#l443">443 </a> } 496 <a class="c2html-lineno" name="l443" href="#l443">443 </a> }
497 <a class="c2html-lineno" name="l444" href="#l444">444 </a> 497 <a class="c2html-lineno" name="l444" href="#l444">444 </a>
498 <a class="c2html-lineno" name="l445" href="#l445">445 </a> gamestate_cleanup(&simulation); 498 <a class="c2html-lineno" name="l445" href="#l445">445 </a> gamestate_cleanup(&amp;simulation);
499 <a class="c2html-lineno" name="l446" href="#l446">446 </a> 499 <a class="c2html-lineno" name="l446" href="#l446">446 </a>
500 <a class="c2html-lineno" name="l447" href="#l447">447 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">VALID_MOVE_SEMANTICS</span>; 500 <a class="c2html-lineno" name="l447" href="#l447">447 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">VALID_MOVE_SEMANTICS</span>;
501 <a class="c2html-lineno" name="l448" href="#l448">448 </a>} 501 <a class="c2html-lineno" name="l448" href="#l448">448 </a>}
502 <a class="c2html-lineno" name="l449" href="#l449">449 </a> 502 <a class="c2html-lineno" name="l449" href="#l449">449 </a>
503 <a class="c2html-lineno" name="l450" href="#l450">450 </a>_Bool get_threats(GameState *gamestate, <span class="c2html-type">uint8_t</span> row, <span class="c2html-type">uint8_t</span> file, 503 <a class="c2html-lineno" name="l450" href="#l450">450 </a>_Bool get_threats(GameState *gamestate, <span class="c2html-type">uint8_t</span> row, <span class="c2html-type">uint8_t</span> file,
504 <a class="c2html-lineno" name="l451" href="#l451">451 </a> <span class="c2html-type">uint8_t</span> color, Move *threats, <span class="c2html-type">uint8_t</span> *threatcount) { 504 <a class="c2html-lineno" name="l451" href="#l451">451 </a> <span class="c2html-type">uint8_t</span> color, Move *threats, <span class="c2html-type">uint8_t</span> *threatcount) {
505 <a class="c2html-lineno" name="l452" href="#l452">452 </a> Move candidates[<span class="c2html-macroconst">32</span>]; 505 <a class="c2html-lineno" name="l452" href="#l452">452 </a> Move candidates[<span class="c2html-macroconst">32</span>];
506 <a class="c2html-lineno" name="l453" href="#l453">453 </a> <span class="c2html-keyword">int</span> candidatecount = <span class="c2html-macroconst">0</span>; 506 <a class="c2html-lineno" name="l453" href="#l453">453 </a> <span class="c2html-keyword">int</span> candidatecount = <span class="c2html-macroconst">0</span>;
507 <a class="c2html-lineno" name="l454" href="#l454">454 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> r = <span class="c2html-macroconst">0</span> ; r &lt; <span class="c2html-macroconst">8</span> ; r++) { 507 <a class="c2html-lineno" name="l454" href="#l454">454 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> r = <span class="c2html-macroconst">0</span> ; r &lt; <span class="c2html-macroconst">8</span> ; r++) {
508 <a class="c2html-lineno" name="l455" href="#l455">455 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> f = <span class="c2html-macroconst">0</span> ; f &lt; <span class="c2html-macroconst">8</span> ; f++) { 508 <a class="c2html-lineno" name="l455" href="#l455">455 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> f = <span class="c2html-macroconst">0</span> ; f &lt; <span class="c2html-macroconst">8</span> ; f++) {
509 <a class="c2html-lineno" name="l456" href="#l456">456 </a> <span class="c2html-keyword">if</span> ((gamestate-&gt;board[r][f] & <span class="c2html-macroconst">COLOR_MASK</span>) == color) { 509 <a class="c2html-lineno" name="l456" href="#l456">456 </a> <span class="c2html-keyword">if</span> ((gamestate-&gt;board[r][f] &amp; <span class="c2html-macroconst">COLOR_MASK</span>) == color) {
510 <a class="c2html-lineno" name="l457" href="#l457">457 </a> <span class="c2html-comment">// non-capturing move</span> 510 <a class="c2html-lineno" name="l457" href="#l457">457 </a> <span class="c2html-comment">// non-capturing move</span>
511 <a class="c2html-lineno" name="l458" href="#l458">458 </a> memset(&(candidates[candidatecount]), <span class="c2html-macroconst">0</span>, <span class="c2html-keyword">sizeof</span>(Move)); 511 <a class="c2html-lineno" name="l458" href="#l458">458 </a> memset(&amp;(candidates[candidatecount]), <span class="c2html-macroconst">0</span>, <span class="c2html-keyword">sizeof</span>(Move));
512 <a class="c2html-lineno" name="l459" href="#l459">459 </a> candidates[candidatecount].piece = gamestate-&gt;board[r][f]; 512 <a class="c2html-lineno" name="l459" href="#l459">459 </a> candidates[candidatecount].piece = gamestate-&gt;board[r][f];
513 <a class="c2html-lineno" name="l460" href="#l460">460 </a> candidates[candidatecount].fromrow = r; 513 <a class="c2html-lineno" name="l460" href="#l460">460 </a> candidates[candidatecount].fromrow = r;
514 <a class="c2html-lineno" name="l461" href="#l461">461 </a> candidates[candidatecount].fromfile = f; 514 <a class="c2html-lineno" name="l461" href="#l461">461 </a> candidates[candidatecount].fromfile = f;
515 <a class="c2html-lineno" name="l462" href="#l462">462 </a> candidates[candidatecount].torow = row; 515 <a class="c2html-lineno" name="l462" href="#l462">462 </a> candidates[candidatecount].torow = row;
516 <a class="c2html-lineno" name="l463" href="#l463">463 </a> candidates[candidatecount].tofile = file; 516 <a class="c2html-lineno" name="l463" href="#l463">463 </a> candidates[candidatecount].tofile = file;
517 <a class="c2html-lineno" name="l464" href="#l464">464 </a> candidatecount++; 517 <a class="c2html-lineno" name="l464" href="#l464">464 </a> candidatecount++;
518 <a class="c2html-lineno" name="l465" href="#l465">465 </a> 518 <a class="c2html-lineno" name="l465" href="#l465">465 </a>
519 <a class="c2html-lineno" name="l466" href="#l466">466 </a> <span class="c2html-comment">// capturing move</span> 519 <a class="c2html-lineno" name="l466" href="#l466">466 </a> <span class="c2html-comment">// capturing move</span>
520 <a class="c2html-lineno" name="l467" href="#l467">467 </a> memcpy(&(candidates[candidatecount]), 520 <a class="c2html-lineno" name="l467" href="#l467">467 </a> memcpy(&amp;(candidates[candidatecount]),
521 <a class="c2html-lineno" name="l468" href="#l468">468 </a> &(candidates[candidatecount-<span class="c2html-macroconst">1</span>]), <span class="c2html-keyword">sizeof</span>(Move)); 521 <a class="c2html-lineno" name="l468" href="#l468">468 </a> &amp;(candidates[candidatecount-<span class="c2html-macroconst">1</span>]), <span class="c2html-keyword">sizeof</span>(Move));
522 <a class="c2html-lineno" name="l469" href="#l469">469 </a> candidates[candidatecount].capture = <span class="c2html-macroconst">1</span>; 522 <a class="c2html-lineno" name="l469" href="#l469">469 </a> candidates[candidatecount].capture = <span class="c2html-macroconst">1</span>;
523 <a class="c2html-lineno" name="l470" href="#l470">470 </a> candidatecount++; 523 <a class="c2html-lineno" name="l470" href="#l470">470 </a> candidatecount++;
524 <a class="c2html-lineno" name="l471" href="#l471">471 </a> } 524 <a class="c2html-lineno" name="l471" href="#l471">471 </a> }
525 <a class="c2html-lineno" name="l472" href="#l472">472 </a> } 525 <a class="c2html-lineno" name="l472" href="#l472">472 </a> }
526 <a class="c2html-lineno" name="l473" href="#l473">473 </a> } 526 <a class="c2html-lineno" name="l473" href="#l473">473 </a> }
531 <a class="c2html-lineno" name="l478" href="#l478">478 </a> 531 <a class="c2html-lineno" name="l478" href="#l478">478 </a>
532 <a class="c2html-lineno" name="l479" href="#l479">479 </a> 532 <a class="c2html-lineno" name="l479" href="#l479">479 </a>
533 <a class="c2html-lineno" name="l480" href="#l480">480 </a> _Bool result = <span class="c2html-macroconst">0</span>; 533 <a class="c2html-lineno" name="l480" href="#l480">480 </a> _Bool result = <span class="c2html-macroconst">0</span>;
534 <a class="c2html-lineno" name="l481" href="#l481">481 </a> 534 <a class="c2html-lineno" name="l481" href="#l481">481 </a>
535 <a class="c2html-lineno" name="l482" href="#l482">482 </a> <span class="c2html-keyword">for</span> (<span class="c2html-keyword">int</span> i = <span class="c2html-macroconst">0</span> ; i &lt; candidatecount ; i++) { 535 <a class="c2html-lineno" name="l482" href="#l482">482 </a> <span class="c2html-keyword">for</span> (<span class="c2html-keyword">int</span> i = <span class="c2html-macroconst">0</span> ; i &lt; candidatecount ; i++) {
536 <a class="c2html-lineno" name="l483" href="#l483">483 </a> <span class="c2html-keyword">if</span> (validate_move_rules(gamestate, &(candidates[i])) 536 <a class="c2html-lineno" name="l483" href="#l483">483 </a> <span class="c2html-keyword">if</span> (validate_move_rules(gamestate, &amp;(candidates[i]))
537 <a class="c2html-lineno" name="l484" href="#l484">484 </a> == <span class="c2html-macroconst">VALID_MOVE_SEMANTICS</span>) { 537 <a class="c2html-lineno" name="l484" href="#l484">484 </a> == <span class="c2html-macroconst">VALID_MOVE_SEMANTICS</span>) {
538 <a class="c2html-lineno" name="l485" href="#l485">485 </a> result = <span class="c2html-macroconst">1</span>; 538 <a class="c2html-lineno" name="l485" href="#l485">485 </a> result = <span class="c2html-macroconst">1</span>;
539 <a class="c2html-lineno" name="l486" href="#l486">486 </a> <span class="c2html-keyword">if</span> (threats && threatcount) { 539 <a class="c2html-lineno" name="l486" href="#l486">486 </a> <span class="c2html-keyword">if</span> (threats &amp;&amp; threatcount) {
540 <a class="c2html-lineno" name="l487" href="#l487">487 </a> threats[(*threatcount)++] = candidates[i]; 540 <a class="c2html-lineno" name="l487" href="#l487">487 </a> threats[(*threatcount)++] = candidates[i];
541 <a class="c2html-lineno" name="l488" href="#l488">488 </a> } 541 <a class="c2html-lineno" name="l488" href="#l488">488 </a> }
542 <a class="c2html-lineno" name="l489" href="#l489">489 </a> } 542 <a class="c2html-lineno" name="l489" href="#l489">489 </a> }
543 <a class="c2html-lineno" name="l490" href="#l490">490 </a> } 543 <a class="c2html-lineno" name="l490" href="#l490">490 </a> }
544 <a class="c2html-lineno" name="l491" href="#l491">491 </a> 544 <a class="c2html-lineno" name="l491" href="#l491">491 </a>
545 <a class="c2html-lineno" name="l492" href="#l492">492 </a> <span class="c2html-keyword">return</span> result; 545 <a class="c2html-lineno" name="l492" href="#l492">492 </a> <span class="c2html-keyword">return</span> result;
546 <a class="c2html-lineno" name="l493" href="#l493">493 </a>} 546 <a class="c2html-lineno" name="l493" href="#l493">493 </a>}
547 <a class="c2html-lineno" name="l494" href="#l494">494 </a> 547 <a class="c2html-lineno" name="l494" href="#l494">494 </a>
548 <a class="c2html-lineno" name="l495" href="#l495">495 </a>_Bool is_pinned(GameState *gamestate, Move *move) { 548 <a class="c2html-lineno" name="l495" href="#l495">495 </a>_Bool is_pinned(GameState *gamestate, Move *move) {
549 <a class="c2html-lineno" name="l496" href="#l496">496 </a> <span class="c2html-type">uint8_t</span> color = move-&gt;piece & <span class="c2html-macroconst">COLOR_MASK</span>; 549 <a class="c2html-lineno" name="l496" href="#l496">496 </a> <span class="c2html-type">uint8_t</span> color = move-&gt;piece &amp; <span class="c2html-macroconst">COLOR_MASK</span>;
550 <a class="c2html-lineno" name="l497" href="#l497">497 </a> 550 <a class="c2html-lineno" name="l497" href="#l497">497 </a>
551 <a class="c2html-lineno" name="l498" href="#l498">498 </a> <span class="c2html-type">uint8_t</span> kingfile = <span class="c2html-macroconst">0</span>, kingrow = <span class="c2html-macroconst">0</span>; 551 <a class="c2html-lineno" name="l498" href="#l498">498 </a> <span class="c2html-type">uint8_t</span> kingfile = <span class="c2html-macroconst">0</span>, kingrow = <span class="c2html-macroconst">0</span>;
552 <a class="c2html-lineno" name="l499" href="#l499">499 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> row = <span class="c2html-macroconst">0</span> ; row &lt; <span class="c2html-macroconst">8</span> ; row++) { 552 <a class="c2html-lineno" name="l499" href="#l499">499 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> row = <span class="c2html-macroconst">0</span> ; row &lt; <span class="c2html-macroconst">8</span> ; row++) {
553 <a class="c2html-lineno" name="l500" href="#l500">500 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> file = <span class="c2html-macroconst">0</span> ; file &lt; <span class="c2html-macroconst">8</span> ; file++) { 553 <a class="c2html-lineno" name="l500" href="#l500">500 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> file = <span class="c2html-macroconst">0</span> ; file &lt; <span class="c2html-macroconst">8</span> ; file++) {
554 <a class="c2html-lineno" name="l501" href="#l501">501 </a> <span class="c2html-keyword">if</span> (gamestate-&gt;board[row][file] == (color|<span class="c2html-macroconst">KING</span>)) { 554 <a class="c2html-lineno" name="l501" href="#l501">501 </a> <span class="c2html-keyword">if</span> (gamestate-&gt;board[row][file] == (color|<span class="c2html-macroconst">KING</span>)) {
558 <a class="c2html-lineno" name="l505" href="#l505">505 </a> } 558 <a class="c2html-lineno" name="l505" href="#l505">505 </a> }
559 <a class="c2html-lineno" name="l506" href="#l506">506 </a> } 559 <a class="c2html-lineno" name="l506" href="#l506">506 </a> }
560 <a class="c2html-lineno" name="l507" href="#l507">507 </a> 560 <a class="c2html-lineno" name="l507" href="#l507">507 </a>
561 <a class="c2html-lineno" name="l508" href="#l508">508 </a> GameState simulation = gamestate_copy_sim(gamestate); 561 <a class="c2html-lineno" name="l508" href="#l508">508 </a> GameState simulation = gamestate_copy_sim(gamestate);
562 <a class="c2html-lineno" name="l509" href="#l509">509 </a> Move simmove = *move; 562 <a class="c2html-lineno" name="l509" href="#l509">509 </a> Move simmove = *move;
563 <a class="c2html-lineno" name="l510" href="#l510">510 </a> apply_move(&simulation, &simmove); 563 <a class="c2html-lineno" name="l510" href="#l510">510 </a> apply_move(&amp;simulation, &amp;simmove);
564 <a class="c2html-lineno" name="l511" href="#l511">511 </a> _Bool covered = is_covered(&simulation, 564 <a class="c2html-lineno" name="l511" href="#l511">511 </a> _Bool covered = is_covered(&amp;simulation,
565 <a class="c2html-lineno" name="l512" href="#l512">512 </a> kingrow, kingfile, opponent_color(color)); 565 <a class="c2html-lineno" name="l512" href="#l512">512 </a> kingrow, kingfile, opponent_color(color));
566 <a class="c2html-lineno" name="l513" href="#l513">513 </a> gamestate_cleanup(&simulation); 566 <a class="c2html-lineno" name="l513" href="#l513">513 </a> gamestate_cleanup(&amp;simulation);
567 <a class="c2html-lineno" name="l514" href="#l514">514 </a> 567 <a class="c2html-lineno" name="l514" href="#l514">514 </a>
568 <a class="c2html-lineno" name="l515" href="#l515">515 </a> <span class="c2html-keyword">return</span> covered; 568 <a class="c2html-lineno" name="l515" href="#l515">515 </a> <span class="c2html-keyword">return</span> covered;
569 <a class="c2html-lineno" name="l516" href="#l516">516 </a>} 569 <a class="c2html-lineno" name="l516" href="#l516">516 </a>}
570 <a class="c2html-lineno" name="l517" href="#l517">517 </a> 570 <a class="c2html-lineno" name="l517" href="#l517">517 </a>
571 <a class="c2html-lineno" name="l518" href="#l518">518 </a>_Bool get_real_threats(GameState *gamestate, <span class="c2html-type">uint8_t</span> row, <span class="c2html-type">uint8_t</span> file, 571 <a class="c2html-lineno" name="l518" href="#l518">518 </a>_Bool get_real_threats(GameState *gamestate, <span class="c2html-type">uint8_t</span> row, <span class="c2html-type">uint8_t</span> file,
575 <a class="c2html-lineno" name="l522" href="#l522">522 </a> *threatcount = <span class="c2html-macroconst">0</span>; 575 <a class="c2html-lineno" name="l522" href="#l522">522 </a> *threatcount = <span class="c2html-macroconst">0</span>;
576 <a class="c2html-lineno" name="l523" href="#l523">523 </a> } 576 <a class="c2html-lineno" name="l523" href="#l523">523 </a> }
577 <a class="c2html-lineno" name="l524" href="#l524">524 </a> 577 <a class="c2html-lineno" name="l524" href="#l524">524 </a>
578 <a class="c2html-lineno" name="l525" href="#l525">525 </a> Move candidates[<span class="c2html-macroconst">16</span>]; 578 <a class="c2html-lineno" name="l525" href="#l525">525 </a> Move candidates[<span class="c2html-macroconst">16</span>];
579 <a class="c2html-lineno" name="l526" href="#l526">526 </a> <span class="c2html-type">uint8_t</span> candidatecount; 579 <a class="c2html-lineno" name="l526" href="#l526">526 </a> <span class="c2html-type">uint8_t</span> candidatecount;
580 <a class="c2html-lineno" name="l527" href="#l527">527 </a> <span class="c2html-keyword">if</span> (get_threats(gamestate, row, file, color, candidates, &candidatecount)) { 580 <a class="c2html-lineno" name="l527" href="#l527">527 </a> <span class="c2html-keyword">if</span> (get_threats(gamestate, row, file, color, candidates, &amp;candidatecount)) {
581 <a class="c2html-lineno" name="l528" href="#l528">528 </a> 581 <a class="c2html-lineno" name="l528" href="#l528">528 </a>
582 <a class="c2html-lineno" name="l529" href="#l529">529 </a> _Bool result = <span class="c2html-macroconst">0</span>; 582 <a class="c2html-lineno" name="l529" href="#l529">529 </a> _Bool result = <span class="c2html-macroconst">0</span>;
583 <a class="c2html-lineno" name="l530" href="#l530">530 </a> <span class="c2html-type">uint8_t</span> kingfile = <span class="c2html-macroconst">0</span>, kingrow = <span class="c2html-macroconst">0</span>; 583 <a class="c2html-lineno" name="l530" href="#l530">530 </a> <span class="c2html-type">uint8_t</span> kingfile = <span class="c2html-macroconst">0</span>, kingrow = <span class="c2html-macroconst">0</span>;
584 <a class="c2html-lineno" name="l531" href="#l531">531 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> row = <span class="c2html-macroconst">0</span> ; row &lt; <span class="c2html-macroconst">8</span> ; row++) { 584 <a class="c2html-lineno" name="l531" href="#l531">531 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> row = <span class="c2html-macroconst">0</span> ; row &lt; <span class="c2html-macroconst">8</span> ; row++) {
585 <a class="c2html-lineno" name="l532" href="#l532">532 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> file = <span class="c2html-macroconst">0</span> ; file &lt; <span class="c2html-macroconst">8</span> ; file++) { 585 <a class="c2html-lineno" name="l532" href="#l532">532 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> file = <span class="c2html-macroconst">0</span> ; file &lt; <span class="c2html-macroconst">8</span> ; file++) {
591 <a class="c2html-lineno" name="l538" href="#l538">538 </a> } 591 <a class="c2html-lineno" name="l538" href="#l538">538 </a> }
592 <a class="c2html-lineno" name="l539" href="#l539">539 </a> 592 <a class="c2html-lineno" name="l539" href="#l539">539 </a>
593 <a class="c2html-lineno" name="l540" href="#l540">540 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> i = <span class="c2html-macroconst">0</span> ; i &lt; candidatecount ; i++) { 593 <a class="c2html-lineno" name="l540" href="#l540">540 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> i = <span class="c2html-macroconst">0</span> ; i &lt; candidatecount ; i++) {
594 <a class="c2html-lineno" name="l541" href="#l541">541 </a> GameState simulation = gamestate_copy_sim(gamestate); 594 <a class="c2html-lineno" name="l541" href="#l541">541 </a> GameState simulation = gamestate_copy_sim(gamestate);
595 <a class="c2html-lineno" name="l542" href="#l542">542 </a> Move simmove = candidates[i]; 595 <a class="c2html-lineno" name="l542" href="#l542">542 </a> Move simmove = candidates[i];
596 <a class="c2html-lineno" name="l543" href="#l543">543 </a> apply_move(&simulation, &simmove); 596 <a class="c2html-lineno" name="l543" href="#l543">543 </a> apply_move(&amp;simulation, &amp;simmove);
597 <a class="c2html-lineno" name="l544" href="#l544">544 </a> <span class="c2html-keyword">if</span> (!is_covered(&simulation, kingrow, kingfile, 597 <a class="c2html-lineno" name="l544" href="#l544">544 </a> <span class="c2html-keyword">if</span> (!is_covered(&amp;simulation, kingrow, kingfile,
598 <a class="c2html-lineno" name="l545" href="#l545">545 </a> opponent_color(color))) { 598 <a class="c2html-lineno" name="l545" href="#l545">545 </a> opponent_color(color))) {
599 <a class="c2html-lineno" name="l546" href="#l546">546 </a> result = <span class="c2html-macroconst">1</span>; 599 <a class="c2html-lineno" name="l546" href="#l546">546 </a> result = <span class="c2html-macroconst">1</span>;
600 <a class="c2html-lineno" name="l547" href="#l547">547 </a> <span class="c2html-keyword">if</span> (threats && threatcount) { 600 <a class="c2html-lineno" name="l547" href="#l547">547 </a> <span class="c2html-keyword">if</span> (threats &amp;&amp; threatcount) {
601 <a class="c2html-lineno" name="l548" href="#l548">548 </a> threats[(*threatcount)++] = candidates[i]; 601 <a class="c2html-lineno" name="l548" href="#l548">548 </a> threats[(*threatcount)++] = candidates[i];
602 <a class="c2html-lineno" name="l549" href="#l549">549 </a> } 602 <a class="c2html-lineno" name="l549" href="#l549">549 </a> }
603 <a class="c2html-lineno" name="l550" href="#l550">550 </a> } 603 <a class="c2html-lineno" name="l550" href="#l550">550 </a> }
604 <a class="c2html-lineno" name="l551" href="#l551">551 </a> } 604 <a class="c2html-lineno" name="l551" href="#l551">551 </a> }
605 <a class="c2html-lineno" name="l552" href="#l552">552 </a> 605 <a class="c2html-lineno" name="l552" href="#l552">552 </a>
609 <a class="c2html-lineno" name="l556" href="#l556">556 </a> } 609 <a class="c2html-lineno" name="l556" href="#l556">556 </a> }
610 <a class="c2html-lineno" name="l557" href="#l557">557 </a>} 610 <a class="c2html-lineno" name="l557" href="#l557">557 </a>}
611 <a class="c2html-lineno" name="l558" href="#l558">558 </a> 611 <a class="c2html-lineno" name="l558" href="#l558">558 </a>
612 <a class="c2html-lineno" name="l559" href="#l559">559 </a><span class="c2html-keyword">static</span> <span class="c2html-keyword">int</span> getlocation(GameState *gamestate, Move *move) { 612 <a class="c2html-lineno" name="l559" href="#l559">559 </a><span class="c2html-keyword">static</span> <span class="c2html-keyword">int</span> getlocation(GameState *gamestate, Move *move) {
613 <a class="c2html-lineno" name="l560" href="#l560">560 </a> 613 <a class="c2html-lineno" name="l560" href="#l560">560 </a>
614 <a class="c2html-lineno" name="l561" href="#l561">561 </a> <span class="c2html-type">uint8_t</span> color = move-&gt;piece & <span class="c2html-macroconst">COLOR_MASK</span>; 614 <a class="c2html-lineno" name="l561" href="#l561">561 </a> <span class="c2html-type">uint8_t</span> color = move-&gt;piece &amp; <span class="c2html-macroconst">COLOR_MASK</span>;
615 <a class="c2html-lineno" name="l562" href="#l562">562 </a> _Bool incheck = gamestate-&gt;lastmove?gamestate-&gt;lastmove-&gt;move.check:<span class="c2html-macroconst">0</span>; 615 <a class="c2html-lineno" name="l562" href="#l562">562 </a> _Bool incheck = gamestate-&gt;lastmove?gamestate-&gt;lastmove-&gt;move.check:<span class="c2html-macroconst">0</span>;
616 <a class="c2html-lineno" name="l563" href="#l563">563 </a> 616 <a class="c2html-lineno" name="l563" href="#l563">563 </a>
617 <a class="c2html-lineno" name="l564" href="#l564">564 </a> Move threats[<span class="c2html-macroconst">16</span>], *threat = <span class="c2html-macroconst">NULL</span>; 617 <a class="c2html-lineno" name="l564" href="#l564">564 </a> Move threats[<span class="c2html-macroconst">16</span>], *threat = <span class="c2html-macroconst">NULL</span>;
618 <a class="c2html-lineno" name="l565" href="#l565">565 </a> <span class="c2html-type">uint8_t</span> threatcount; 618 <a class="c2html-lineno" name="l565" href="#l565">565 </a> <span class="c2html-type">uint8_t</span> threatcount;
619 <a class="c2html-lineno" name="l566" href="#l566">566 </a> 619 <a class="c2html-lineno" name="l566" href="#l566">566 </a>
620 <a class="c2html-lineno" name="l567" href="#l567">567 </a> <span class="c2html-keyword">if</span> (get_threats(gamestate, move-&gt;torow, move-&gt;tofile, color, 620 <a class="c2html-lineno" name="l567" href="#l567">567 </a> <span class="c2html-keyword">if</span> (get_threats(gamestate, move-&gt;torow, move-&gt;tofile, color,
621 <a class="c2html-lineno" name="l568" href="#l568">568 </a> threats, &threatcount)) { 621 <a class="c2html-lineno" name="l568" href="#l568">568 </a> threats, &amp;threatcount)) {
622 <a class="c2html-lineno" name="l569" href="#l569">569 </a> 622 <a class="c2html-lineno" name="l569" href="#l569">569 </a>
623 <a class="c2html-lineno" name="l570" href="#l570">570 </a> <span class="c2html-keyword">int</span> reason = <span class="c2html-macroconst">INVALID_POSITION</span>; 623 <a class="c2html-lineno" name="l570" href="#l570">570 </a> <span class="c2html-keyword">int</span> reason = <span class="c2html-macroconst">INVALID_POSITION</span>;
624 <a class="c2html-lineno" name="l571" href="#l571">571 </a> 624 <a class="c2html-lineno" name="l571" href="#l571">571 </a>
625 <a class="c2html-lineno" name="l572" href="#l572">572 </a> <span class="c2html-comment">// find threats for the specified position</span> 625 <a class="c2html-lineno" name="l572" href="#l572">572 </a> <span class="c2html-comment">// find threats for the specified position</span>
626 <a class="c2html-lineno" name="l573" href="#l573">573 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> i = <span class="c2html-macroconst">0</span> ; i &lt; threatcount ; i++) { 626 <a class="c2html-lineno" name="l573" href="#l573">573 </a> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> i = <span class="c2html-macroconst">0</span> ; i &lt; threatcount ; i++) {
627 <a class="c2html-lineno" name="l574" href="#l574">574 </a> <span class="c2html-keyword">if</span> ((threats[i].piece & (<span class="c2html-macroconst">PIECE_MASK</span> | <span class="c2html-macroconst">COLOR_MASK</span>)) 627 <a class="c2html-lineno" name="l574" href="#l574">574 </a> <span class="c2html-keyword">if</span> ((threats[i].piece &amp; (<span class="c2html-macroconst">PIECE_MASK</span> | <span class="c2html-macroconst">COLOR_MASK</span>))
628 <a class="c2html-lineno" name="l575" href="#l575">575 </a> == move-&gt;piece && 628 <a class="c2html-lineno" name="l575" href="#l575">575 </a> == move-&gt;piece &amp;&amp;
629 <a class="c2html-lineno" name="l576" href="#l576">576 </a> (move-&gt;fromrow == <span class="c2html-macroconst">POS_UNSPECIFIED</span> || 629 <a class="c2html-lineno" name="l576" href="#l576">576 </a> (move-&gt;fromrow == <span class="c2html-macroconst">POS_UNSPECIFIED</span> ||
630 <a class="c2html-lineno" name="l577" href="#l577">577 </a> move-&gt;fromrow == threats[i].fromrow) && 630 <a class="c2html-lineno" name="l577" href="#l577">577 </a> move-&gt;fromrow == threats[i].fromrow) &amp;&amp;
631 <a class="c2html-lineno" name="l578" href="#l578">578 </a> (move-&gt;fromfile == <span class="c2html-macroconst">POS_UNSPECIFIED</span> || 631 <a class="c2html-lineno" name="l578" href="#l578">578 </a> (move-&gt;fromfile == <span class="c2html-macroconst">POS_UNSPECIFIED</span> ||
632 <a class="c2html-lineno" name="l579" href="#l579">579 </a> move-&gt;fromfile == threats[i].fromfile)) { 632 <a class="c2html-lineno" name="l579" href="#l579">579 </a> move-&gt;fromfile == threats[i].fromfile)) {
633 <a class="c2html-lineno" name="l580" href="#l580">580 </a> 633 <a class="c2html-lineno" name="l580" href="#l580">580 </a>
634 <a class="c2html-lineno" name="l581" href="#l581">581 </a> <span class="c2html-keyword">if</span> (threat) { 634 <a class="c2html-lineno" name="l581" href="#l581">581 </a> <span class="c2html-keyword">if</span> (threat) {
635 <a class="c2html-lineno" name="l582" href="#l582">582 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">AMBIGUOUS_MOVE</span>; 635 <a class="c2html-lineno" name="l582" href="#l582">582 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">AMBIGUOUS_MOVE</span>;
636 <a class="c2html-lineno" name="l583" href="#l583">583 </a> } <span class="c2html-keyword">else</span> { 636 <a class="c2html-lineno" name="l583" href="#l583">583 </a> } <span class="c2html-keyword">else</span> {
637 <a class="c2html-lineno" name="l584" href="#l584">584 </a> <span class="c2html-comment">// found threat is no real threat</span> 637 <a class="c2html-lineno" name="l584" href="#l584">584 </a> <span class="c2html-comment">// found threat is no real threat</span>
638 <a class="c2html-lineno" name="l585" href="#l585">585 </a> <span class="c2html-keyword">if</span> (is_pinned(gamestate, &(threats[i]))) { 638 <a class="c2html-lineno" name="l585" href="#l585">585 </a> <span class="c2html-keyword">if</span> (is_pinned(gamestate, &amp;(threats[i]))) {
639 <a class="c2html-lineno" name="l586" href="#l586">586 </a> reason = incheck?<span class="c2html-macroconst">KING_IN_CHECK</span>:<span class="c2html-macroconst">PIECE_PINNED</span>; 639 <a class="c2html-lineno" name="l586" href="#l586">586 </a> reason = incheck?<span class="c2html-macroconst">KING_IN_CHECK</span>:<span class="c2html-macroconst">PIECE_PINNED</span>;
640 <a class="c2html-lineno" name="l587" href="#l587">587 </a> } <span class="c2html-keyword">else</span> { 640 <a class="c2html-lineno" name="l587" href="#l587">587 </a> } <span class="c2html-keyword">else</span> {
641 <a class="c2html-lineno" name="l588" href="#l588">588 </a> threat = &(threats[i]); 641 <a class="c2html-lineno" name="l588" href="#l588">588 </a> threat = &amp;(threats[i]);
642 <a class="c2html-lineno" name="l589" href="#l589">589 </a> } 642 <a class="c2html-lineno" name="l589" href="#l589">589 </a> }
643 <a class="c2html-lineno" name="l590" href="#l590">590 </a> } 643 <a class="c2html-lineno" name="l590" href="#l590">590 </a> }
644 <a class="c2html-lineno" name="l591" href="#l591">591 </a> } 644 <a class="c2html-lineno" name="l591" href="#l591">591 </a> }
645 <a class="c2html-lineno" name="l592" href="#l592">592 </a> } 645 <a class="c2html-lineno" name="l592" href="#l592">592 </a> }
646 <a class="c2html-lineno" name="l593" href="#l593">593 </a> 646 <a class="c2html-lineno" name="l593" href="#l593">593 </a>
674 <a class="c2html-lineno" name="l621" href="#l621">621 </a> len--; mstr[len] = <span class="c2html-string">'\0'</span>; 674 <a class="c2html-lineno" name="l621" href="#l621">621 </a> len--; mstr[len] = <span class="c2html-string">'\0'</span>;
675 <a class="c2html-lineno" name="l622" href="#l622">622 </a> <span class="c2html-comment">/* ignore - validation should set game state */</span> 675 <a class="c2html-lineno" name="l622" href="#l622">622 </a> <span class="c2html-comment">/* ignore - validation should set game state */</span>
676 <a class="c2html-lineno" name="l623" href="#l623">623 </a> } 676 <a class="c2html-lineno" name="l623" href="#l623">623 </a> }
677 <a class="c2html-lineno" name="l624" href="#l624">624 </a> 677 <a class="c2html-lineno" name="l624" href="#l624">624 </a>
678 <a class="c2html-lineno" name="l625" href="#l625">625 </a> <span class="c2html-comment">/* evaluate promotion */</span> 678 <a class="c2html-lineno" name="l625" href="#l625">625 </a> <span class="c2html-comment">/* evaluate promotion */</span>
679 <a class="c2html-lineno" name="l626" href="#l626">626 </a> <span class="c2html-keyword">if</span> (len &gt; <span class="c2html-macroconst">3</span> && mstr[len-<span class="c2html-macroconst">2</span>] == <span class="c2html-string">'='</span>) { 679 <a class="c2html-lineno" name="l626" href="#l626">626 </a> <span class="c2html-keyword">if</span> (len &gt; <span class="c2html-macroconst">3</span> &amp;&amp; mstr[len-<span class="c2html-macroconst">2</span>] == <span class="c2html-string">'='</span>) {
680 <a class="c2html-lineno" name="l627" href="#l627">627 </a> move-&gt;promotion = getpiece(mstr[len-<span class="c2html-macroconst">1</span>]); 680 <a class="c2html-lineno" name="l627" href="#l627">627 </a> move-&gt;promotion = getpiece(mstr[len-<span class="c2html-macroconst">1</span>]);
681 <a class="c2html-lineno" name="l628" href="#l628">628 </a> <span class="c2html-keyword">if</span> (!move-&gt;promotion) { 681 <a class="c2html-lineno" name="l628" href="#l628">628 </a> <span class="c2html-keyword">if</span> (!move-&gt;promotion) {
682 <a class="c2html-lineno" name="l629" href="#l629">629 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_MOVE_SYNTAX</span>; 682 <a class="c2html-lineno" name="l629" href="#l629">629 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_MOVE_SYNTAX</span>;
683 <a class="c2html-lineno" name="l630" href="#l630">630 </a> } <span class="c2html-keyword">else</span> { 683 <a class="c2html-lineno" name="l630" href="#l630">630 </a> } <span class="c2html-keyword">else</span> {
684 <a class="c2html-lineno" name="l631" href="#l631">631 </a> move-&gt;promotion |= color; 684 <a class="c2html-lineno" name="l631" href="#l631">631 </a> move-&gt;promotion |= color;
768 <a class="c2html-lineno" name="l715" href="#l715">715 </a> } 768 <a class="c2html-lineno" name="l715" href="#l715">715 </a> }
769 <a class="c2html-lineno" name="l716" href="#l716">716 </a> 769 <a class="c2html-lineno" name="l716" href="#l716">716 </a>
770 <a class="c2html-lineno" name="l717" href="#l717">717 </a> 770 <a class="c2html-lineno" name="l717" href="#l717">717 </a>
771 <a class="c2html-lineno" name="l718" href="#l718">718 </a> <span class="c2html-keyword">if</span> (move-&gt;piece) { 771 <a class="c2html-lineno" name="l718" href="#l718">718 </a> <span class="c2html-keyword">if</span> (move-&gt;piece) {
772 <a class="c2html-lineno" name="l719" href="#l719">719 </a> <span class="c2html-keyword">if</span> (move-&gt;piece == <span class="c2html-macroconst">PAWN</span> 772 <a class="c2html-lineno" name="l719" href="#l719">719 </a> <span class="c2html-keyword">if</span> (move-&gt;piece == <span class="c2html-macroconst">PAWN</span>
773 <a class="c2html-lineno" name="l720" href="#l720">720 </a> && move-&gt;torow == (color==<span class="c2html-macroconst">WHITE</span>?<span class="c2html-macroconst">7</span>:<span class="c2html-macroconst">0</span>) 773 <a class="c2html-lineno" name="l720" href="#l720">720 </a> &amp;&amp; move-&gt;torow == (color==<span class="c2html-macroconst">WHITE</span>?<span class="c2html-macroconst">7</span>:<span class="c2html-macroconst">0</span>)
774 <a class="c2html-lineno" name="l721" href="#l721">721 </a> && !move-&gt;promotion) { 774 <a class="c2html-lineno" name="l721" href="#l721">721 </a> &amp;&amp; !move-&gt;promotion) {
775 <a class="c2html-lineno" name="l722" href="#l722">722 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">NEED_PROMOTION</span>; 775 <a class="c2html-lineno" name="l722" href="#l722">722 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">NEED_PROMOTION</span>;
776 <a class="c2html-lineno" name="l723" href="#l723">723 </a> } 776 <a class="c2html-lineno" name="l723" href="#l723">723 </a> }
777 <a class="c2html-lineno" name="l724" href="#l724">724 </a> 777 <a class="c2html-lineno" name="l724" href="#l724">724 </a>
778 <a class="c2html-lineno" name="l725" href="#l725">725 </a> move-&gt;piece |= color; 778 <a class="c2html-lineno" name="l725" href="#l725">725 </a> move-&gt;piece |= color;
779 <a class="c2html-lineno" name="l726" href="#l726">726 </a> <span class="c2html-keyword">if</span> (move-&gt;fromfile == <span class="c2html-macroconst">POS_UNSPECIFIED</span> 779 <a class="c2html-lineno" name="l726" href="#l726">726 </a> <span class="c2html-keyword">if</span> (move-&gt;fromfile == <span class="c2html-macroconst">POS_UNSPECIFIED</span>
790 <a class="c2html-lineno" name="l737" href="#l737">737 </a>_Bool is_protected(GameState *gamestate, <span class="c2html-type">uint8_t</span> row, <span class="c2html-type">uint8_t</span> file, 790 <a class="c2html-lineno" name="l737" href="#l737">737 </a>_Bool is_protected(GameState *gamestate, <span class="c2html-type">uint8_t</span> row, <span class="c2html-type">uint8_t</span> file,
791 <a class="c2html-lineno" name="l738" href="#l738">738 </a> <span class="c2html-type">uint8_t</span> color) { 791 <a class="c2html-lineno" name="l738" href="#l738">738 </a> <span class="c2html-type">uint8_t</span> color) {
792 <a class="c2html-lineno" name="l739" href="#l739">739 </a> 792 <a class="c2html-lineno" name="l739" href="#l739">739 </a>
793 <a class="c2html-lineno" name="l740" href="#l740">740 </a> Move threats[<span class="c2html-macroconst">16</span>]; 793 <a class="c2html-lineno" name="l740" href="#l740">740 </a> Move threats[<span class="c2html-macroconst">16</span>];
794 <a class="c2html-lineno" name="l741" href="#l741">741 </a> <span class="c2html-type">uint8_t</span> threatcount; 794 <a class="c2html-lineno" name="l741" href="#l741">741 </a> <span class="c2html-type">uint8_t</span> threatcount;
795 <a class="c2html-lineno" name="l742" href="#l742">742 </a> <span class="c2html-keyword">if</span> (get_real_threats(gamestate, row, file, color, threats, &threatcount)) { 795 <a class="c2html-lineno" name="l742" href="#l742">742 </a> <span class="c2html-keyword">if</span> (get_real_threats(gamestate, row, file, color, threats, &amp;threatcount)) {
796 <a class="c2html-lineno" name="l743" href="#l743">743 </a> <span class="c2html-keyword">for</span> (<span class="c2html-keyword">int</span> i = <span class="c2html-macroconst">0</span> ; i &lt; threatcount ; i++) { 796 <a class="c2html-lineno" name="l743" href="#l743">743 </a> <span class="c2html-keyword">for</span> (<span class="c2html-keyword">int</span> i = <span class="c2html-macroconst">0</span> ; i &lt; threatcount ; i++) {
797 <a class="c2html-lineno" name="l744" href="#l744">744 </a> <span class="c2html-keyword">if</span> (threats[i].piece != (color|<span class="c2html-macroconst">KING</span>)) { 797 <a class="c2html-lineno" name="l744" href="#l744">744 </a> <span class="c2html-keyword">if</span> (threats[i].piece != (color|<span class="c2html-macroconst">KING</span>)) {
798 <a class="c2html-lineno" name="l745" href="#l745">745 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">1</span>; 798 <a class="c2html-lineno" name="l745" href="#l745">745 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">1</span>;
799 <a class="c2html-lineno" name="l746" href="#l746">746 </a> } 799 <a class="c2html-lineno" name="l746" href="#l746">746 </a> }
800 <a class="c2html-lineno" name="l747" href="#l747">747 </a> } 800 <a class="c2html-lineno" name="l747" href="#l747">747 </a> }
818 <a class="c2html-lineno" name="l765" href="#l765">765 </a> gamestate-&gt;movelist : gamestate-&gt;movelist-&gt;next; 818 <a class="c2html-lineno" name="l765" href="#l765">765 </a> gamestate-&gt;movelist : gamestate-&gt;movelist-&gt;next;
819 <a class="c2html-lineno" name="l766" href="#l766">766 </a> 819 <a class="c2html-lineno" name="l766" href="#l766">766 </a>
820 <a class="c2html-lineno" name="l767" href="#l767">767 </a> <span class="c2html-keyword">while</span> (movelist) { 820 <a class="c2html-lineno" name="l767" href="#l767">767 </a> <span class="c2html-keyword">while</span> (movelist) {
821 <a class="c2html-lineno" name="l768" href="#l768">768 </a> time += gameinfo-&gt;addtime; 821 <a class="c2html-lineno" name="l768" href="#l768">768 </a> time += gameinfo-&gt;addtime;
822 <a class="c2html-lineno" name="l769" href="#l769">769 </a> 822 <a class="c2html-lineno" name="l769" href="#l769">769 </a>
823 <a class="c2html-lineno" name="l770" href="#l770">770 </a> <span class="c2html-keyword">struct</span> movetimeval *movetime = &(movelist-&gt;move.movetime); 823 <a class="c2html-lineno" name="l770" href="#l770">770 </a> <span class="c2html-keyword">struct</span> movetimeval *movetime = &amp;(movelist-&gt;move.movetime);
824 <a class="c2html-lineno" name="l771" href="#l771">771 </a> <span class="c2html-keyword">if</span> (movetime-&gt;tv_sec &gt;= time) { 824 <a class="c2html-lineno" name="l771" href="#l771">771 </a> <span class="c2html-keyword">if</span> (movetime-&gt;tv_sec &gt;= time) {
825 <a class="c2html-lineno" name="l772" href="#l772">772 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>; 825 <a class="c2html-lineno" name="l772" href="#l772">772 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>;
826 <a class="c2html-lineno" name="l773" href="#l773">773 </a> } 826 <a class="c2html-lineno" name="l773" href="#l773">773 </a> }
827 <a class="c2html-lineno" name="l774" href="#l774">774 </a> 827 <a class="c2html-lineno" name="l774" href="#l774">774 </a>
828 <a class="c2html-lineno" name="l775" href="#l775">775 </a> time -= movetime-&gt;tv_sec; 828 <a class="c2html-lineno" name="l775" href="#l775">775 </a> time -= movetime-&gt;tv_sec;
831 <a class="c2html-lineno" name="l778" href="#l778">778 </a> movelist = movelist-&gt;next ? movelist-&gt;next-&gt;next : <span class="c2html-macroconst">NULL</span>; 831 <a class="c2html-lineno" name="l778" href="#l778">778 </a> movelist = movelist-&gt;next ? movelist-&gt;next-&gt;next : <span class="c2html-macroconst">NULL</span>;
832 <a class="c2html-lineno" name="l779" href="#l779">779 </a> } 832 <a class="c2html-lineno" name="l779" href="#l779">779 </a> }
833 <a class="c2html-lineno" name="l780" href="#l780">780 </a> 833 <a class="c2html-lineno" name="l780" href="#l780">780 </a>
834 <a class="c2html-lineno" name="l781" href="#l781">781 </a> <span class="c2html-type">time_t</span> sec; 834 <a class="c2html-lineno" name="l781" href="#l781">781 </a> <span class="c2html-type">time_t</span> sec;
835 <a class="c2html-lineno" name="l782" href="#l782">782 </a> movelist = gamestate-&gt;lastmove; 835 <a class="c2html-lineno" name="l782" href="#l782">782 </a> movelist = gamestate-&gt;lastmove;
836 <a class="c2html-lineno" name="l783" href="#l783">783 </a> <span class="c2html-keyword">if</span> ((movelist-&gt;move.piece & <span class="c2html-macroconst">COLOR_MASK</span>) != color) { 836 <a class="c2html-lineno" name="l783" href="#l783">783 </a> <span class="c2html-keyword">if</span> ((movelist-&gt;move.piece &amp; <span class="c2html-macroconst">COLOR_MASK</span>) != color) {
837 <a class="c2html-lineno" name="l784" href="#l784">784 </a> <span class="c2html-keyword">struct</span> movetimeval *lastmovetstamp = &(movelist-&gt;move.timestamp); 837 <a class="c2html-lineno" name="l784" href="#l784">784 </a> <span class="c2html-keyword">struct</span> movetimeval *lastmovetstamp = &amp;(movelist-&gt;move.timestamp);
838 <a class="c2html-lineno" name="l785" href="#l785">785 </a> <span class="c2html-keyword">struct</span> timeval currenttstamp; 838 <a class="c2html-lineno" name="l785" href="#l785">785 </a> <span class="c2html-keyword">struct</span> timeval currenttstamp;
839 <a class="c2html-lineno" name="l786" href="#l786">786 </a> gettimeofday(&currenttstamp, <span class="c2html-macroconst">NULL</span>); 839 <a class="c2html-lineno" name="l786" href="#l786">786 </a> gettimeofday(&amp;currenttstamp, <span class="c2html-macroconst">NULL</span>);
840 <a class="c2html-lineno" name="l787" href="#l787">787 </a> micros += currenttstamp.tv_usec - lastmovetstamp-&gt;tv_usec; 840 <a class="c2html-lineno" name="l787" href="#l787">787 </a> micros += currenttstamp.tv_usec - lastmovetstamp-&gt;tv_usec;
841 <a class="c2html-lineno" name="l788" href="#l788">788 </a> sec = currenttstamp.tv_sec - lastmovetstamp-&gt;tv_sec; 841 <a class="c2html-lineno" name="l788" href="#l788">788 </a> sec = currenttstamp.tv_sec - lastmovetstamp-&gt;tv_sec;
842 <a class="c2html-lineno" name="l789" href="#l789">789 </a> <span class="c2html-keyword">if</span> (sec &gt;= time) { 842 <a class="c2html-lineno" name="l789" href="#l789">789 </a> <span class="c2html-keyword">if</span> (sec &gt;= time) {
843 <a class="c2html-lineno" name="l790" href="#l790">790 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>; 843 <a class="c2html-lineno" name="l790" href="#l790">790 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>;
844 <a class="c2html-lineno" name="l791" href="#l791">791 </a> } 844 <a class="c2html-lineno" name="l791" href="#l791">791 </a> }

mercurial