Tue, 23 Aug 2016 16:34:02 +0200
words (token) are now stored as sstr_t
41
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1 | <!DOCTYPE html> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
2 | <html> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
3 | <head> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
4 | <title>c2html</title> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
5 | <style type="text/css"> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
6 | span.c2html-lineno a { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
7 | font-style: italic; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
8 | text-decoration: none; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
9 | color: grey; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
10 | } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
11 | span.c2html-keyword { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
12 | color: blue; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
13 | } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
14 | span.c2html-macroconst { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
15 | color: cornflowerblue; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
16 | } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
17 | span.c2html-type { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
18 | color: cornflowerblue; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
19 | } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
20 | span.c2html-directive { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
21 | color: green; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
22 | } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
23 | span.c2html-string { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
24 | color: darkorange; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
25 | } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
26 | span.c2html-comment { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
27 | color: grey; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
28 | } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
29 | span.c2html-stdinclude { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
30 | color: darkorange; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
31 | } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
32 | span.c2html-userinclude { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
33 | color: darkorange; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
34 | } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
35 | a.c2html-userinclude { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
36 | color: darkorange; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
37 | text-decoration: underline; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
38 | } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
39 | </style> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
40 | </head> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
41 | <body> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
42 | |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
43 | <pre> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
44 | <span class="c2html-lineno"><a name="l1" href="#l1"> 1 </a></span> <span class="c2html-comment">/*</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
45 | <span class="c2html-lineno"><a name="l2" href="#l2"> 2 </a></span> <span class="c2html-comment"> * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
46 | <span class="c2html-lineno"><a name="l3" href="#l3"> 3 </a></span> <span class="c2html-comment"> *</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
47 | <span class="c2html-lineno"><a name="l4" href="#l4"> 4 </a></span> <span class="c2html-comment"> * Copyright 2014 Mike Becker. All rights reserved.</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
48 | <span class="c2html-lineno"><a name="l5" href="#l5"> 5 </a></span> <span class="c2html-comment"> *</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
49 | <span class="c2html-lineno"><a name="l6" href="#l6"> 6 </a></span> <span class="c2html-comment"> * Redistribution and use in source and binary forms, with or without</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
50 | <span class="c2html-lineno"><a name="l7" href="#l7"> 7 </a></span> <span class="c2html-comment"> * modification, are permitted provided that the following conditions are met:</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
51 | <span class="c2html-lineno"><a name="l8" href="#l8"> 8 </a></span> <span class="c2html-comment"> *</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
52 | <span class="c2html-lineno"><a name="l9" href="#l9"> 9 </a></span> <span class="c2html-comment"> * 1. Redistributions of source code must retain the above copyright</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
53 | <span class="c2html-lineno"><a name="l10" href="#l10"> 10 </a></span> <span class="c2html-comment"> * notice, this list of conditions and the following disclaimer.</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
54 | <span class="c2html-lineno"><a name="l11" href="#l11"> 11 </a></span> <span class="c2html-comment"> *</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
55 | <span class="c2html-lineno"><a name="l12" href="#l12"> 12 </a></span> <span class="c2html-comment"> * 2. Redistributions in binary form must reproduce the above copyright</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
56 | <span class="c2html-lineno"><a name="l13" href="#l13"> 13 </a></span> <span class="c2html-comment"> * notice, this list of conditions and the following disclaimer in the</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
57 | <span class="c2html-lineno"><a name="l14" href="#l14"> 14 </a></span> <span class="c2html-comment"> * documentation and/or other materials provided with the distribution.</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
58 | <span class="c2html-lineno"><a name="l15" href="#l15"> 15 </a></span> <span class="c2html-comment"> *</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
59 | <span class="c2html-lineno"><a name="l16" href="#l16"> 16 </a></span> <span class="c2html-comment"> * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
60 | <span class="c2html-lineno"><a name="l17" href="#l17"> 17 </a></span> <span class="c2html-comment"> * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
61 | <span class="c2html-lineno"><a name="l18" href="#l18"> 18 </a></span> <span class="c2html-comment"> * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
62 | <span class="c2html-lineno"><a name="l19" href="#l19"> 19 </a></span> <span class="c2html-comment"> * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
63 | <span class="c2html-lineno"><a name="l20" href="#l20"> 20 </a></span> <span class="c2html-comment"> * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
64 | <span class="c2html-lineno"><a name="l21" href="#l21"> 21 </a></span> <span class="c2html-comment"> * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
65 | <span class="c2html-lineno"><a name="l22" href="#l22"> 22 </a></span> <span class="c2html-comment"> * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
66 | <span class="c2html-lineno"><a name="l23" href="#l23"> 23 </a></span> <span class="c2html-comment"> * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
67 | <span class="c2html-lineno"><a name="l24" href="#l24"> 24 </a></span> <span class="c2html-comment"> * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
68 | <span class="c2html-lineno"><a name="l25" href="#l25"> 25 </a></span> <span class="c2html-comment"> * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
69 | <span class="c2html-lineno"><a name="l26" href="#l26"> 26 </a></span> <span class="c2html-comment"> * POSSIBILITY OF SUCH DAMAGE.</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
70 | <span class="c2html-lineno"><a name="l27" href="#l27"> 27 </a></span> <span class="c2html-comment"> *</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
71 | <span class="c2html-lineno"><a name="l28" href="#l28"> 28 </a></span> <span class="c2html-comment"> */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
72 | <span class="c2html-lineno"><a name="l29" href="#l29"> 29 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
73 | <span class="c2html-lineno"><a name="l30" href="#l30"> 30 </a></span> <span class="c2html-directive">#include</span> <a class="c2html-userinclude" href="rules.h">"rules.h"</a> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
74 | <span class="c2html-lineno"><a name="l31" href="#l31"> 31 </a></span> <span class="c2html-directive">#include</span> <a class="c2html-userinclude" href="chess.h">"chess.h"</a> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
75 | <span class="c2html-lineno"><a name="l32" href="#l32"> 32 </a></span> <span class="c2html-directive">#include</span> <span class="c2html-stdinclude"><string.h></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
76 | <span class="c2html-lineno"><a name="l33" href="#l33"> 33 </a></span> <span class="c2html-directive">#include</span> <span class="c2html-stdinclude"><stdlib.h></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
77 | <span class="c2html-lineno"><a name="l34" href="#l34"> 34 </a></span> <span class="c2html-directive">#include</span> <span class="c2html-stdinclude"><sys/time.h></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
78 | <span class="c2html-lineno"><a name="l35" href="#l35"> 35 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
79 | <span class="c2html-lineno"><a name="l36" href="#l36"> 36 </a></span> <span class="c2html-keyword">static</span> GameState gamestate_copy_sim(GameState *gamestate) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
80 | <span class="c2html-lineno"><a name="l37" href="#l37"> 37 </a></span> GameState simulation = *gamestate; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
81 | <span class="c2html-lineno"><a name="l38" href="#l38"> 38 </a></span> <span class="c2html-keyword">if</span> (simulation.lastmove) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
82 | <span class="c2html-lineno"><a name="l39" href="#l39"> 39 </a></span> MoveList *lastmovecopy = malloc(<span class="c2html-keyword">sizeof</span>(MoveList)); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
83 | <span class="c2html-lineno"><a name="l40" href="#l40"> 40 </a></span> *lastmovecopy = *(simulation.lastmove); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
84 | <span class="c2html-lineno"><a name="l41" href="#l41"> 41 </a></span> simulation.movelist = simulation.lastmove = lastmovecopy; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
85 | <span class="c2html-lineno"><a name="l42" href="#l42"> 42 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
86 | <span class="c2html-lineno"><a name="l43" href="#l43"> 43 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
87 | <span class="c2html-lineno"><a name="l44" href="#l44"> 44 </a></span> <span class="c2html-keyword">return</span> simulation; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
88 | <span class="c2html-lineno"><a name="l45" href="#l45"> 45 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
89 | <span class="c2html-lineno"><a name="l46" href="#l46"> 46 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
90 | <span class="c2html-lineno"><a name="l47" href="#l47"> 47 </a></span> <span class="c2html-keyword">void</span> gamestate_init(GameState *gamestate) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
91 | <span class="c2html-lineno"><a name="l48" href="#l48"> 48 </a></span> memset(gamestate, <span class="c2html-macroconst">0</span>, <span class="c2html-keyword">sizeof</span>(GameState)); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
92 | <span class="c2html-lineno"><a name="l49" href="#l49"> 49 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
93 | <span class="c2html-lineno"><a name="l50" href="#l50"> 50 </a></span> Board initboard = { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
94 | <span class="c2html-lineno"><a name="l51" href="#l51"> 51 </a></span> {<span class="c2html-macroconst">WROOK</span>, <span class="c2html-macroconst">WKNIGHT</span>, <span class="c2html-macroconst">WBISHOP</span>, <span class="c2html-macroconst">WQUEEN</span>, <span class="c2html-macroconst">WKING</span>, <span class="c2html-macroconst">WBISHOP</span>, <span class="c2html-macroconst">WKNIGHT</span>, <span class="c2html-macroconst">WROOK</span>}, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
95 | <span class="c2html-lineno"><a name="l52" href="#l52"> 52 </a></span> {<span class="c2html-macroconst">WPAWN</span>, <span class="c2html-macroconst">WPAWN</span>, <span class="c2html-macroconst">WPAWN</span>, <span class="c2html-macroconst">WPAWN</span>, <span class="c2html-macroconst">WPAWN</span>, <span class="c2html-macroconst">WPAWN</span>, <span class="c2html-macroconst">WPAWN</span>, <span class="c2html-macroconst">WPAWN</span>}, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
96 | <span class="c2html-lineno"><a name="l53" href="#l53"> 53 </a></span> {<span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>}, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
97 | <span class="c2html-lineno"><a name="l54" href="#l54"> 54 </a></span> {<span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>}, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
98 | <span class="c2html-lineno"><a name="l55" href="#l55"> 55 </a></span> {<span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>}, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
99 | <span class="c2html-lineno"><a name="l56" href="#l56"> 56 </a></span> {<span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">0</span>}, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
100 | <span class="c2html-lineno"><a name="l57" href="#l57"> 57 </a></span> {<span class="c2html-macroconst">BPAWN</span>, <span class="c2html-macroconst">BPAWN</span>, <span class="c2html-macroconst">BPAWN</span>, <span class="c2html-macroconst">BPAWN</span>, <span class="c2html-macroconst">BPAWN</span>, <span class="c2html-macroconst">BPAWN</span>, <span class="c2html-macroconst">BPAWN</span>, <span class="c2html-macroconst">BPAWN</span>}, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
101 | <span class="c2html-lineno"><a name="l58" href="#l58"> 58 </a></span> {<span class="c2html-macroconst">BROOK</span>, <span class="c2html-macroconst">BKNIGHT</span>, <span class="c2html-macroconst">BBISHOP</span>, <span class="c2html-macroconst">BQUEEN</span>, <span class="c2html-macroconst">BKING</span>, <span class="c2html-macroconst">BBISHOP</span>, <span class="c2html-macroconst">BKNIGHT</span>, <span class="c2html-macroconst">BROOK</span>} |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
102 | <span class="c2html-lineno"><a name="l59" href="#l59"> 59 </a></span> }; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
103 | <span class="c2html-lineno"><a name="l60" href="#l60"> 60 </a></span> memcpy(gamestate->board, initboard, <span class="c2html-keyword">sizeof</span>(Board)); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
104 | <span class="c2html-lineno"><a name="l61" href="#l61"> 61 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
105 | <span class="c2html-lineno"><a name="l62" href="#l62"> 62 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
106 | <span class="c2html-lineno"><a name="l63" href="#l63"> 63 </a></span> <span class="c2html-keyword">void</span> gamestate_cleanup(GameState *gamestate) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
107 | <span class="c2html-lineno"><a name="l64" href="#l64"> 64 </a></span> MoveList *elem; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
108 | <span class="c2html-lineno"><a name="l65" href="#l65"> 65 </a></span> elem = gamestate->movelist; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
109 | <span class="c2html-lineno"><a name="l66" href="#l66"> 66 </a></span> <span class="c2html-keyword">while</span> (elem) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
110 | <span class="c2html-lineno"><a name="l67" href="#l67"> 67 </a></span> MoveList *cur = elem; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
111 | <span class="c2html-lineno"><a name="l68" href="#l68"> 68 </a></span> elem = elem->next; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
112 | <span class="c2html-lineno"><a name="l69" href="#l69"> 69 </a></span> free(cur); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
113 | <span class="c2html-lineno"><a name="l70" href="#l70"> 70 </a></span> }; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
114 | <span class="c2html-lineno"><a name="l71" href="#l71"> 71 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
115 | <span class="c2html-lineno"><a name="l72" href="#l72"> 72 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
116 | <span class="c2html-lineno"><a name="l73" href="#l73"> 73 </a></span> <span class="c2html-comment">/* MUST be called IMMEDIATLY after applying a move to work correctly */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
117 | <span class="c2html-lineno"><a name="l74" href="#l74"> 74 </a></span> <span class="c2html-keyword">static</span> <span class="c2html-keyword">void</span> format_move(GameState *gamestate, Move *move) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
118 | <span class="c2html-lineno"><a name="l75" href="#l75"> 75 </a></span> <span class="c2html-keyword">char</span> *string = move->string; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
119 | <span class="c2html-lineno"><a name="l76" href="#l76"> 76 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
120 | <span class="c2html-lineno"><a name="l77" href="#l77"> 77 </a></span> <span class="c2html-comment">/* at least 8 characters should be available, wipe them out */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
121 | <span class="c2html-lineno"><a name="l78" href="#l78"> 78 </a></span> memset(string, <span class="c2html-macroconst">0</span>, <span class="c2html-macroconst">8</span>); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
122 | <span class="c2html-lineno"><a name="l79" href="#l79"> 79 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
123 | <span class="c2html-lineno"><a name="l80" href="#l80"> 80 </a></span> <span class="c2html-comment">/* special formats for castling */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
124 | <span class="c2html-lineno"><a name="l81" href="#l81"> 81 </a></span> <span class="c2html-keyword">if</span> ((move->piece&<span class="c2html-macroconst">PIECE_MASK</span>) == <span class="c2html-macroconst">KING</span> && |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
125 | <span class="c2html-lineno"><a name="l82" href="#l82"> 82 </a></span> abs(move->tofile-move->fromfile) == <span class="c2html-macroconst">2</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
126 | <span class="c2html-lineno"><a name="l83" href="#l83"> 83 </a></span> <span class="c2html-keyword">if</span> (move->tofile==fileidx(<span class="c2html-string">'c'</span>)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
127 | <span class="c2html-lineno"><a name="l84" href="#l84"> 84 </a></span> memcpy(string, <span class="c2html-string">"O-O-O"</span>, <span class="c2html-macroconst">5</span>); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
128 | <span class="c2html-lineno"><a name="l85" href="#l85"> 85 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
129 | <span class="c2html-lineno"><a name="l86" href="#l86"> 86 </a></span> memcpy(string, <span class="c2html-string">"O-O"</span>, <span class="c2html-macroconst">3</span>); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
130 | <span class="c2html-lineno"><a name="l87" href="#l87"> 87 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
131 | <span class="c2html-lineno"><a name="l88" href="#l88"> 88 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
132 | <span class="c2html-lineno"><a name="l89" href="#l89"> 89 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
133 | <span class="c2html-lineno"><a name="l90" href="#l90"> 90 </a></span> <span class="c2html-comment">/* start by notating the piece character */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
134 | <span class="c2html-lineno"><a name="l91" href="#l91"> 91 </a></span> string[<span class="c2html-macroconst">0</span>] = getpiecechr(move->piece); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
135 | <span class="c2html-lineno"><a name="l92" href="#l92"> 92 </a></span> <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>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
136 | <span class="c2html-lineno"><a name="l93" href="#l93"> 93 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
137 | <span class="c2html-lineno"><a name="l94" href="#l94"> 94 </a></span> <span class="c2html-comment">/* find out how many source information we do need */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
138 | <span class="c2html-lineno"><a name="l95" href="#l95"> 95 </a></span> <span class="c2html-type">uint8_t</span> piece = move->piece & <span class="c2html-macroconst">PIECE_MASK</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
139 | <span class="c2html-lineno"><a name="l96" href="#l96"> 96 </a></span> <span class="c2html-keyword">if</span> (piece == <span class="c2html-macroconst">PAWN</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
140 | <span class="c2html-lineno"><a name="l97" href="#l97"> 97 </a></span> <span class="c2html-keyword">if</span> (move->capture) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
141 | <span class="c2html-lineno"><a name="l98" href="#l98"> 98 </a></span> string[idx++] = filechr(move->fromfile); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
142 | <span class="c2html-lineno"><a name="l99" href="#l99"> 99 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
143 | <span class="c2html-lineno"><a name="l100" href="#l100">100 </a></span> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span> (piece != <span class="c2html-macroconst">KING</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
144 | <span class="c2html-lineno"><a name="l101" href="#l101">101 </a></span> Move threats[<span class="c2html-macroconst">16</span>]; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
145 | <span class="c2html-lineno"><a name="l102" href="#l102">102 </a></span> <span class="c2html-type">uint8_t</span> threatcount; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
146 | <span class="c2html-lineno"><a name="l103" href="#l103">103 </a></span> get_real_threats(gamestate, move->torow, move->tofile, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
147 | <span class="c2html-lineno"><a name="l104" href="#l104">104 </a></span> move->piece&<span class="c2html-macroconst">COLOR_MASK</span>, threats, &threatcount); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
148 | <span class="c2html-lineno"><a name="l105" href="#l105">105 </a></span> <span class="c2html-keyword">if</span> (threatcount > <span class="c2html-macroconst">1</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
149 | <span class="c2html-lineno"><a name="l106" href="#l106">106 </a></span> <span class="c2html-keyword">int</span> ambrows = <span class="c2html-macroconst">0</span>, ambfiles = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
150 | <span class="c2html-lineno"><a name="l107" href="#l107">107 </a></span> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> i = <span class="c2html-macroconst">0</span> ; i < threatcount ; i++) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
151 | <span class="c2html-lineno"><a name="l108" href="#l108">108 </a></span> <span class="c2html-keyword">if</span> (threats[i].fromrow == move->fromrow) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
152 | <span class="c2html-lineno"><a name="l109" href="#l109">109 </a></span> ambrows++; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
153 | <span class="c2html-lineno"><a name="l110" href="#l110">110 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
154 | <span class="c2html-lineno"><a name="l111" href="#l111">111 </a></span> <span class="c2html-keyword">if</span> (threats[i].fromfile == move->fromfile) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
155 | <span class="c2html-lineno"><a name="l112" href="#l112">112 </a></span> ambfiles++; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
156 | <span class="c2html-lineno"><a name="l113" href="#l113">113 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
157 | <span class="c2html-lineno"><a name="l114" href="#l114">114 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
158 | <span class="c2html-lineno"><a name="l115" href="#l115">115 </a></span> <span class="c2html-comment">/* ambiguous row, name file */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
159 | <span class="c2html-lineno"><a name="l116" href="#l116">116 </a></span> <span class="c2html-keyword">if</span> (ambrows > <span class="c2html-macroconst">1</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
160 | <span class="c2html-lineno"><a name="l117" href="#l117">117 </a></span> string[idx++] = filechr(move->fromfile); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
161 | <span class="c2html-lineno"><a name="l118" href="#l118">118 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
162 | <span class="c2html-lineno"><a name="l119" href="#l119">119 </a></span> <span class="c2html-comment">/* ambiguous file, name row */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
163 | <span class="c2html-lineno"><a name="l120" href="#l120">120 </a></span> <span class="c2html-keyword">if</span> (ambfiles > <span class="c2html-macroconst">1</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
164 | <span class="c2html-lineno"><a name="l121" href="#l121">121 </a></span> string[idx++] = filechr(move->fromrow); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
165 | <span class="c2html-lineno"><a name="l122" href="#l122">122 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
166 | <span class="c2html-lineno"><a name="l123" href="#l123">123 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
167 | <span class="c2html-lineno"><a name="l124" href="#l124">124 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
168 | <span class="c2html-lineno"><a name="l125" href="#l125">125 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
169 | <span class="c2html-lineno"><a name="l126" href="#l126">126 </a></span> <span class="c2html-comment">/* capturing? */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
170 | <span class="c2html-lineno"><a name="l127" href="#l127">127 </a></span> <span class="c2html-keyword">if</span> (move->capture) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
171 | <span class="c2html-lineno"><a name="l128" href="#l128">128 </a></span> string[idx++] = <span class="c2html-string">'x'</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
172 | <span class="c2html-lineno"><a name="l129" href="#l129">129 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
173 | <span class="c2html-lineno"><a name="l130" href="#l130">130 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
174 | <span class="c2html-lineno"><a name="l131" href="#l131">131 </a></span> <span class="c2html-comment">/* destination */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
175 | <span class="c2html-lineno"><a name="l132" href="#l132">132 </a></span> string[idx++] = filechr(move->tofile); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
176 | <span class="c2html-lineno"><a name="l133" href="#l133">133 </a></span> string[idx++] = rowchr(move->torow); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
177 | <span class="c2html-lineno"><a name="l134" href="#l134">134 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
178 | <span class="c2html-lineno"><a name="l135" href="#l135">135 </a></span> <span class="c2html-comment">/* promotion? */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
179 | <span class="c2html-lineno"><a name="l136" href="#l136">136 </a></span> <span class="c2html-keyword">if</span> (move->promotion) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
180 | <span class="c2html-lineno"><a name="l137" href="#l137">137 </a></span> string[idx++] = <span class="c2html-string">'='</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
181 | <span class="c2html-lineno"><a name="l138" href="#l138">138 </a></span> string[idx++] = getpiecechr(move->promotion); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
182 | <span class="c2html-lineno"><a name="l139" href="#l139">139 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
183 | <span class="c2html-lineno"><a name="l140" href="#l140">140 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
184 | <span class="c2html-lineno"><a name="l141" href="#l141">141 </a></span> <span class="c2html-comment">/* check? */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
185 | <span class="c2html-lineno"><a name="l142" href="#l142">142 </a></span> <span class="c2html-keyword">if</span> (move->check) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
186 | <span class="c2html-lineno"><a name="l143" href="#l143">143 </a></span> <span class="c2html-comment">/* works only, if this function is called when applying the move */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
187 | <span class="c2html-lineno"><a name="l144" href="#l144">144 </a></span> string[idx++] = gamestate->checkmate?<span class="c2html-string">'#'</span>:<span class="c2html-string">'+'</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
188 | <span class="c2html-lineno"><a name="l145" href="#l145">145 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
189 | <span class="c2html-lineno"><a name="l146" href="#l146">146 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
190 | <span class="c2html-lineno"><a name="l147" href="#l147">147 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
191 | <span class="c2html-lineno"><a name="l148" href="#l148">148 </a></span> <span class="c2html-keyword">static</span> <span class="c2html-keyword">void</span> addmove(GameState* gamestate, Move *move) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
192 | <span class="c2html-lineno"><a name="l149" href="#l149">149 </a></span> MoveList *elem = malloc(<span class="c2html-keyword">sizeof</span>(MoveList)); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
193 | <span class="c2html-lineno"><a name="l150" href="#l150">150 </a></span> elem->next = <span class="c2html-macroconst">NULL</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
194 | <span class="c2html-lineno"><a name="l151" href="#l151">151 </a></span> elem->move = *move; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
195 | <span class="c2html-lineno"><a name="l152" href="#l152">152 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
196 | <span class="c2html-lineno"><a name="l153" href="#l153">153 </a></span> <span class="c2html-keyword">struct</span> timeval curtimestamp; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
197 | <span class="c2html-lineno"><a name="l154" href="#l154">154 </a></span> gettimeofday(&curtimestamp, <span class="c2html-macroconst">NULL</span>); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
198 | <span class="c2html-lineno"><a name="l155" href="#l155">155 </a></span> elem->move.timestamp.tv_sec = curtimestamp.tv_sec; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
199 | <span class="c2html-lineno"><a name="l156" href="#l156">156 </a></span> elem->move.timestamp.tv_usec = curtimestamp.tv_usec; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
200 | <span class="c2html-lineno"><a name="l157" href="#l157">157 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
201 | <span class="c2html-lineno"><a name="l158" href="#l158">158 </a></span> <span class="c2html-keyword">if</span> (gamestate->lastmove) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
202 | <span class="c2html-lineno"><a name="l159" href="#l159">159 </a></span> <span class="c2html-keyword">struct</span> movetimeval *lasttstamp = &(gamestate->lastmove->move.timestamp); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
203 | <span class="c2html-lineno"><a name="l160" href="#l160">160 </a></span> <span class="c2html-type">uint64_t</span> sec = curtimestamp.tv_sec - lasttstamp->tv_sec; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
204 | <span class="c2html-lineno"><a name="l161" href="#l161">161 </a></span> <span class="c2html-type">suseconds_t</span> micros; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
205 | <span class="c2html-lineno"><a name="l162" href="#l162">162 </a></span> <span class="c2html-keyword">if</span> (curtimestamp.tv_usec < lasttstamp->tv_usec) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
206 | <span class="c2html-lineno"><a name="l163" href="#l163">163 </a></span> micros = 1e6L-(lasttstamp->tv_usec - curtimestamp.tv_usec); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
207 | <span class="c2html-lineno"><a name="l164" href="#l164">164 </a></span> sec--; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
208 | <span class="c2html-lineno"><a name="l165" href="#l165">165 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
209 | <span class="c2html-lineno"><a name="l166" href="#l166">166 </a></span> micros = curtimestamp.tv_usec - lasttstamp->tv_usec; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
210 | <span class="c2html-lineno"><a name="l167" href="#l167">167 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
211 | <span class="c2html-lineno"><a name="l168" href="#l168">168 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
212 | <span class="c2html-lineno"><a name="l169" href="#l169">169 </a></span> elem->move.movetime.tv_sec = sec; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
213 | <span class="c2html-lineno"><a name="l170" href="#l170">170 </a></span> elem->move.movetime.tv_usec = micros; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
214 | <span class="c2html-lineno"><a name="l171" href="#l171">171 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
215 | <span class="c2html-lineno"><a name="l172" href="#l172">172 </a></span> gamestate->lastmove->next = elem; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
216 | <span class="c2html-lineno"><a name="l173" href="#l173">173 </a></span> gamestate->lastmove = elem; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
217 | <span class="c2html-lineno"><a name="l174" href="#l174">174 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
218 | <span class="c2html-lineno"><a name="l175" href="#l175">175 </a></span> elem->move.movetime.tv_usec = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
219 | <span class="c2html-lineno"><a name="l176" href="#l176">176 </a></span> elem->move.movetime.tv_sec = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
220 | <span class="c2html-lineno"><a name="l177" href="#l177">177 </a></span> gamestate->movelist = gamestate->lastmove = elem; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
221 | <span class="c2html-lineno"><a name="l178" href="#l178">178 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
222 | <span class="c2html-lineno"><a name="l179" href="#l179">179 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
223 | <span class="c2html-lineno"><a name="l180" href="#l180">180 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
224 | <span class="c2html-lineno"><a name="l181" href="#l181">181 </a></span> <span class="c2html-keyword">char</span> getpiecechr(<span class="c2html-type">uint8_t</span> piece) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
225 | <span class="c2html-lineno"><a name="l182" href="#l182">182 </a></span> <span class="c2html-keyword">switch</span> (piece & <span class="c2html-macroconst">PIECE_MASK</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
226 | <span class="c2html-lineno"><a name="l183" href="#l183">183 </a></span> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">ROOK</span>: <span class="c2html-keyword">return</span> <span class="c2html-string">'R'</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
227 | <span class="c2html-lineno"><a name="l184" href="#l184">184 </a></span> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">KNIGHT</span>: <span class="c2html-keyword">return</span> <span class="c2html-string">'N'</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
228 | <span class="c2html-lineno"><a name="l185" href="#l185">185 </a></span> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">BISHOP</span>: <span class="c2html-keyword">return</span> <span class="c2html-string">'B'</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
229 | <span class="c2html-lineno"><a name="l186" href="#l186">186 </a></span> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">QUEEN</span>: <span class="c2html-keyword">return</span> <span class="c2html-string">'Q'</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
230 | <span class="c2html-lineno"><a name="l187" href="#l187">187 </a></span> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">KING</span>: <span class="c2html-keyword">return</span> <span class="c2html-string">'K'</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
231 | <span class="c2html-lineno"><a name="l188" href="#l188">188 </a></span> <span class="c2html-keyword">default</span>: <span class="c2html-keyword">return</span> <span class="c2html-string">'\0'</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
232 | <span class="c2html-lineno"><a name="l189" href="#l189">189 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
233 | <span class="c2html-lineno"><a name="l190" href="#l190">190 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
234 | <span class="c2html-lineno"><a name="l191" href="#l191">191 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
235 | <span class="c2html-lineno"><a name="l192" href="#l192">192 </a></span> <span class="c2html-type">uint8_t</span> getpiece(<span class="c2html-keyword">char</span> c) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
236 | <span class="c2html-lineno"><a name="l193" href="#l193">193 </a></span> <span class="c2html-keyword">switch</span> (c) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
237 | <span class="c2html-lineno"><a name="l194" href="#l194">194 </a></span> <span class="c2html-keyword">case</span> <span class="c2html-string">'R'</span>: <span class="c2html-keyword">return</span> <span class="c2html-macroconst">ROOK</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
238 | <span class="c2html-lineno"><a name="l195" href="#l195">195 </a></span> <span class="c2html-keyword">case</span> <span class="c2html-string">'N'</span>: <span class="c2html-keyword">return</span> <span class="c2html-macroconst">KNIGHT</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
239 | <span class="c2html-lineno"><a name="l196" href="#l196">196 </a></span> <span class="c2html-keyword">case</span> <span class="c2html-string">'B'</span>: <span class="c2html-keyword">return</span> <span class="c2html-macroconst">BISHOP</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
240 | <span class="c2html-lineno"><a name="l197" href="#l197">197 </a></span> <span class="c2html-keyword">case</span> <span class="c2html-string">'Q'</span>: <span class="c2html-keyword">return</span> <span class="c2html-macroconst">QUEEN</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
241 | <span class="c2html-lineno"><a name="l198" href="#l198">198 </a></span> <span class="c2html-keyword">case</span> <span class="c2html-string">'K'</span>: <span class="c2html-keyword">return</span> <span class="c2html-macroconst">KING</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
242 | <span class="c2html-lineno"><a name="l199" href="#l199">199 </a></span> <span class="c2html-keyword">default</span>: <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
243 | <span class="c2html-lineno"><a name="l200" href="#l200">200 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
244 | <span class="c2html-lineno"><a name="l201" href="#l201">201 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
245 | <span class="c2html-lineno"><a name="l202" href="#l202">202 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
246 | <span class="c2html-lineno"><a name="l203" href="#l203">203 </a></span> <span class="c2html-keyword">static</span> <span class="c2html-keyword">void</span> apply_move_impl(GameState *gamestate, Move *move, _Bool simulate) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
247 | <span class="c2html-lineno"><a name="l204" href="#l204">204 </a></span> <span class="c2html-type">uint8_t</span> piece = move->piece & <span class="c2html-macroconst">PIECE_MASK</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
248 | <span class="c2html-lineno"><a name="l205" href="#l205">205 </a></span> <span class="c2html-type">uint8_t</span> color = move->piece & <span class="c2html-macroconst">COLOR_MASK</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
249 | <span class="c2html-lineno"><a name="l206" href="#l206">206 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
250 | <span class="c2html-lineno"><a name="l207" href="#l207">207 </a></span> <span class="c2html-comment">/* en passant capture */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
251 | <span class="c2html-lineno"><a name="l208" href="#l208">208 </a></span> <span class="c2html-keyword">if</span> (move->capture && piece == <span class="c2html-macroconst">PAWN</span> && |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
252 | <span class="c2html-lineno"><a name="l209" href="#l209">209 </a></span> mdst(gamestate->board, move) == <span class="c2html-macroconst">0</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
253 | <span class="c2html-lineno"><a name="l210" href="#l210">210 </a></span> gamestate->board[move->fromrow][move->tofile] = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
254 | <span class="c2html-lineno"><a name="l211" href="#l211">211 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
255 | <span class="c2html-lineno"><a name="l212" href="#l212">212 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
256 | <span class="c2html-lineno"><a name="l213" href="#l213">213 </a></span> <span class="c2html-comment">/* remove old en passant threats */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
257 | <span class="c2html-lineno"><a name="l214" href="#l214">214 </a></span> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> file = <span class="c2html-macroconst">0</span> ; file < <span class="c2html-macroconst">8</span> ; file++) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
258 | <span class="c2html-lineno"><a name="l215" href="#l215">215 </a></span> gamestate->board[<span class="c2html-macroconst">3</span>][file] &= ~<span class="c2html-macroconst">ENPASSANT_THREAT</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
259 | <span class="c2html-lineno"><a name="l216" href="#l216">216 </a></span> gamestate->board[<span class="c2html-macroconst">4</span>][file] &= ~<span class="c2html-macroconst">ENPASSANT_THREAT</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
260 | <span class="c2html-lineno"><a name="l217" href="#l217">217 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
261 | <span class="c2html-lineno"><a name="l218" href="#l218">218 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
262 | <span class="c2html-lineno"><a name="l219" href="#l219">219 </a></span> <span class="c2html-comment">/* add new en passant threat */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
263 | <span class="c2html-lineno"><a name="l220" href="#l220">220 </a></span> <span class="c2html-keyword">if</span> (piece == <span class="c2html-macroconst">PAWN</span> && ( |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
264 | <span class="c2html-lineno"><a name="l221" href="#l221">221 </a></span> (move->fromrow == <span class="c2html-macroconst">1</span> && move->torow == <span class="c2html-macroconst">3</span>) || |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
265 | <span class="c2html-lineno"><a name="l222" href="#l222">222 </a></span> (move->fromrow == <span class="c2html-macroconst">6</span> && move->torow == <span class="c2html-macroconst">4</span>))) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
266 | <span class="c2html-lineno"><a name="l223" href="#l223">223 </a></span> move->piece |= <span class="c2html-macroconst">ENPASSANT_THREAT</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
267 | <span class="c2html-lineno"><a name="l224" href="#l224">224 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
268 | <span class="c2html-lineno"><a name="l225" href="#l225">225 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
269 | <span class="c2html-lineno"><a name="l226" href="#l226">226 </a></span> <span class="c2html-comment">/* move (and maybe capture or promote) */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
270 | <span class="c2html-lineno"><a name="l227" href="#l227">227 </a></span> msrc(gamestate->board, move) = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
271 | <span class="c2html-lineno"><a name="l228" href="#l228">228 </a></span> <span class="c2html-keyword">if</span> (move->promotion) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
272 | <span class="c2html-lineno"><a name="l229" href="#l229">229 </a></span> mdst(gamestate->board, move) = move->promotion; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
273 | <span class="c2html-lineno"><a name="l230" href="#l230">230 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
274 | <span class="c2html-lineno"><a name="l231" href="#l231">231 </a></span> mdst(gamestate->board, move) = move->piece; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
275 | <span class="c2html-lineno"><a name="l232" href="#l232">232 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
276 | <span class="c2html-lineno"><a name="l233" href="#l233">233 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
277 | <span class="c2html-lineno"><a name="l234" href="#l234">234 </a></span> <span class="c2html-comment">/* castling */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
278 | <span class="c2html-lineno"><a name="l235" href="#l235">235 </a></span> <span class="c2html-keyword">if</span> (piece == <span class="c2html-macroconst">KING</span> && move->fromfile == fileidx(<span class="c2html-string">'e'</span>)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
279 | <span class="c2html-lineno"><a name="l236" href="#l236">236 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
280 | <span class="c2html-lineno"><a name="l237" href="#l237">237 </a></span> <span class="c2html-keyword">if</span> (move->tofile == fileidx(<span class="c2html-string">'g'</span>)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
281 | <span class="c2html-lineno"><a name="l238" href="#l238">238 </a></span> gamestate->board[move->torow][fileidx(<span class="c2html-string">'h'</span>)] = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
282 | <span class="c2html-lineno"><a name="l239" href="#l239">239 </a></span> gamestate->board[move->torow][fileidx(<span class="c2html-string">'f'</span>)] = color|<span class="c2html-macroconst">ROOK</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
283 | <span class="c2html-lineno"><a name="l240" href="#l240">240 </a></span> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span> (move->tofile == fileidx(<span class="c2html-string">'c'</span>)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
284 | <span class="c2html-lineno"><a name="l241" href="#l241">241 </a></span> gamestate->board[move->torow][fileidx(<span class="c2html-string">'a'</span>)] = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
285 | <span class="c2html-lineno"><a name="l242" href="#l242">242 </a></span> gamestate->board[move->torow][fileidx(<span class="c2html-string">'d'</span>)] = color|<span class="c2html-macroconst">ROOK</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
286 | <span class="c2html-lineno"><a name="l243" href="#l243">243 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
287 | <span class="c2html-lineno"><a name="l244" href="#l244">244 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
288 | <span class="c2html-lineno"><a name="l245" href="#l245">245 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
289 | <span class="c2html-lineno"><a name="l246" href="#l246">246 </a></span> <span class="c2html-keyword">if</span> (!simulate) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
290 | <span class="c2html-lineno"><a name="l247" href="#l247">247 </a></span> <span class="c2html-keyword">if</span> (!move->string[<span class="c2html-macroconst">0</span>]) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
291 | <span class="c2html-lineno"><a name="l248" href="#l248">248 </a></span> format_move(gamestate, move); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
292 | <span class="c2html-lineno"><a name="l249" href="#l249">249 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
293 | <span class="c2html-lineno"><a name="l250" href="#l250">250 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
294 | <span class="c2html-lineno"><a name="l251" href="#l251">251 </a></span> <span class="c2html-comment">/* add move, even in simulation (checkmate test needs it) */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
295 | <span class="c2html-lineno"><a name="l252" href="#l252">252 </a></span> addmove(gamestate, move); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
296 | <span class="c2html-lineno"><a name="l253" href="#l253">253 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
297 | <span class="c2html-lineno"><a name="l254" href="#l254">254 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
298 | <span class="c2html-lineno"><a name="l255" href="#l255">255 </a></span> <span class="c2html-keyword">void</span> apply_move(GameState *gamestate, Move *move) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
299 | <span class="c2html-lineno"><a name="l256" href="#l256">256 </a></span> apply_move_impl(gamestate, move, <span class="c2html-macroconst">0</span>); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
300 | <span class="c2html-lineno"><a name="l257" href="#l257">257 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
301 | <span class="c2html-lineno"><a name="l258" href="#l258">258 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
302 | <span class="c2html-lineno"><a name="l259" href="#l259">259 </a></span> <span class="c2html-keyword">static</span> <span class="c2html-keyword">int</span> validate_move_rules(GameState *gamestate, Move *move) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
303 | <span class="c2html-lineno"><a name="l260" href="#l260">260 </a></span> <span class="c2html-comment">/* validate indices (don't trust opponent) */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
304 | <span class="c2html-lineno"><a name="l261" href="#l261">261 </a></span> <span class="c2html-keyword">if</span> (!chkidx(move)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
305 | <span class="c2html-lineno"><a name="l262" href="#l262">262 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_POSITION</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
306 | <span class="c2html-lineno"><a name="l263" href="#l263">263 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
307 | <span class="c2html-lineno"><a name="l264" href="#l264">264 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
308 | <span class="c2html-lineno"><a name="l265" href="#l265">265 </a></span> <span class="c2html-comment">/* must move */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
309 | <span class="c2html-lineno"><a name="l266" href="#l266">266 </a></span> <span class="c2html-keyword">if</span> (move->fromfile == move->tofile && move->fromrow == move->torow) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
310 | <span class="c2html-lineno"><a name="l267" href="#l267">267 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_MOVE_SYNTAX</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
311 | <span class="c2html-lineno"><a name="l268" href="#l268">268 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
312 | <span class="c2html-lineno"><a name="l269" href="#l269">269 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
313 | <span class="c2html-lineno"><a name="l270" href="#l270">270 </a></span> <span class="c2html-comment">/* does piece exist */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
314 | <span class="c2html-lineno"><a name="l271" href="#l271">271 </a></span> <span class="c2html-keyword">if</span> ((msrc(gamestate->board, move)&(<span class="c2html-macroconst">PIECE_MASK</span>|<span class="c2html-macroconst">COLOR_MASK</span>)) |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
315 | <span class="c2html-lineno"><a name="l272" href="#l272">272 </a></span> != (move->piece&(<span class="c2html-macroconst">PIECE_MASK</span>|<span class="c2html-macroconst">COLOR_MASK</span>))) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
316 | <span class="c2html-lineno"><a name="l273" href="#l273">273 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_POSITION</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
317 | <span class="c2html-lineno"><a name="l274" href="#l274">274 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
318 | <span class="c2html-lineno"><a name="l275" href="#l275">275 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
319 | <span class="c2html-lineno"><a name="l276" href="#l276">276 </a></span> <span class="c2html-comment">/* can't capture own pieces */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
320 | <span class="c2html-lineno"><a name="l277" href="#l277">277 </a></span> <span class="c2html-keyword">if</span> ((mdst(gamestate->board, move) & <span class="c2html-macroconst">COLOR_MASK</span>) |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
321 | <span class="c2html-lineno"><a name="l278" href="#l278">278 </a></span> == (move->piece & <span class="c2html-macroconst">COLOR_MASK</span>)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
322 | <span class="c2html-lineno"><a name="l279" href="#l279">279 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">RULES_VIOLATED</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
323 | <span class="c2html-lineno"><a name="l280" href="#l280">280 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
324 | <span class="c2html-lineno"><a name="l281" href="#l281">281 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
325 | <span class="c2html-lineno"><a name="l282" href="#l282">282 </a></span> <span class="c2html-comment">/* must capture, if and only if destination is occupied */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
326 | <span class="c2html-lineno"><a name="l283" href="#l283">283 </a></span> <span class="c2html-keyword">if</span> ((mdst(gamestate->board, move) == <span class="c2html-macroconst">0</span> && move->capture) || |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
327 | <span class="c2html-lineno"><a name="l284" href="#l284">284 </a></span> (mdst(gamestate->board, move) != <span class="c2html-macroconst">0</span> && !move->capture)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
328 | <span class="c2html-lineno"><a name="l285" href="#l285">285 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_MOVE_SYNTAX</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
329 | <span class="c2html-lineno"><a name="l286" href="#l286">286 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
330 | <span class="c2html-lineno"><a name="l287" href="#l287">287 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
331 | <span class="c2html-lineno"><a name="l288" href="#l288">288 </a></span> <span class="c2html-comment">/* validate individual rules */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
332 | <span class="c2html-lineno"><a name="l289" href="#l289">289 </a></span> _Bool chkrules; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
333 | <span class="c2html-lineno"><a name="l290" href="#l290">290 </a></span> <span class="c2html-keyword">switch</span> (move->piece & <span class="c2html-macroconst">PIECE_MASK</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
334 | <span class="c2html-lineno"><a name="l291" href="#l291">291 </a></span> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">PAWN</span>: |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
335 | <span class="c2html-lineno"><a name="l292" href="#l292">292 </a></span> chkrules = pawn_chkrules(gamestate, move) && |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
336 | <span class="c2html-lineno"><a name="l293" href="#l293">293 </a></span> !pawn_isblocked(gamestate, move); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
337 | <span class="c2html-lineno"><a name="l294" href="#l294">294 </a></span> <span class="c2html-keyword">break</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
338 | <span class="c2html-lineno"><a name="l295" href="#l295">295 </a></span> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">ROOK</span>: |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
339 | <span class="c2html-lineno"><a name="l296" href="#l296">296 </a></span> chkrules = rook_chkrules(move) && |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
340 | <span class="c2html-lineno"><a name="l297" href="#l297">297 </a></span> !rook_isblocked(gamestate, move); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
341 | <span class="c2html-lineno"><a name="l298" href="#l298">298 </a></span> <span class="c2html-keyword">break</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
342 | <span class="c2html-lineno"><a name="l299" href="#l299">299 </a></span> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">KNIGHT</span>: |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
343 | <span class="c2html-lineno"><a name="l300" href="#l300">300 </a></span> chkrules = knight_chkrules(move); <span class="c2html-comment">/* knight is never blocked */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
344 | <span class="c2html-lineno"><a name="l301" href="#l301">301 </a></span> <span class="c2html-keyword">break</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
345 | <span class="c2html-lineno"><a name="l302" href="#l302">302 </a></span> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">BISHOP</span>: |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
346 | <span class="c2html-lineno"><a name="l303" href="#l303">303 </a></span> chkrules = bishop_chkrules(move) && |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
347 | <span class="c2html-lineno"><a name="l304" href="#l304">304 </a></span> !bishop_isblocked(gamestate, move); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
348 | <span class="c2html-lineno"><a name="l305" href="#l305">305 </a></span> <span class="c2html-keyword">break</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
349 | <span class="c2html-lineno"><a name="l306" href="#l306">306 </a></span> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">QUEEN</span>: |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
350 | <span class="c2html-lineno"><a name="l307" href="#l307">307 </a></span> chkrules = queen_chkrules(move) && |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
351 | <span class="c2html-lineno"><a name="l308" href="#l308">308 </a></span> !queen_isblocked(gamestate, move); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
352 | <span class="c2html-lineno"><a name="l309" href="#l309">309 </a></span> <span class="c2html-keyword">break</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
353 | <span class="c2html-lineno"><a name="l310" href="#l310">310 </a></span> <span class="c2html-keyword">case</span> <span class="c2html-macroconst">KING</span>: |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
354 | <span class="c2html-lineno"><a name="l311" href="#l311">311 </a></span> chkrules = king_chkrules(gamestate, move) && |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
355 | <span class="c2html-lineno"><a name="l312" href="#l312">312 </a></span> !king_isblocked(gamestate, move); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
356 | <span class="c2html-lineno"><a name="l313" href="#l313">313 </a></span> <span class="c2html-keyword">break</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
357 | <span class="c2html-lineno"><a name="l314" href="#l314">314 </a></span> <span class="c2html-keyword">default</span>: |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
358 | <span class="c2html-lineno"><a name="l315" href="#l315">315 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_MOVE_SYNTAX</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
359 | <span class="c2html-lineno"><a name="l316" href="#l316">316 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
360 | <span class="c2html-lineno"><a name="l317" href="#l317">317 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
361 | <span class="c2html-lineno"><a name="l318" href="#l318">318 </a></span> <span class="c2html-keyword">return</span> chkrules ? <span class="c2html-macroconst">VALID_MOVE_SEMANTICS</span> : <span class="c2html-macroconst">RULES_VIOLATED</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
362 | <span class="c2html-lineno"><a name="l319" href="#l319">319 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
363 | <span class="c2html-lineno"><a name="l320" href="#l320">320 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
364 | <span class="c2html-lineno"><a name="l321" href="#l321">321 </a></span> <span class="c2html-keyword">int</span> validate_move(GameState *gamestate, Move *move) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
365 | <span class="c2html-lineno"><a name="l322" href="#l322">322 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
366 | <span class="c2html-lineno"><a name="l323" href="#l323">323 </a></span> <span class="c2html-keyword">int</span> result = validate_move_rules(gamestate, move); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
367 | <span class="c2html-lineno"><a name="l324" href="#l324">324 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
368 | <span class="c2html-lineno"><a name="l325" href="#l325">325 </a></span> <span class="c2html-comment">/* cancel processing to save resources */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
369 | <span class="c2html-lineno"><a name="l326" href="#l326">326 </a></span> <span class="c2html-keyword">if</span> (result != <span class="c2html-macroconst">VALID_MOVE_SEMANTICS</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
370 | <span class="c2html-lineno"><a name="l327" href="#l327">327 </a></span> <span class="c2html-keyword">return</span> result; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
371 | <span class="c2html-lineno"><a name="l328" href="#l328">328 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
372 | <span class="c2html-lineno"><a name="l329" href="#l329">329 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
373 | <span class="c2html-lineno"><a name="l330" href="#l330">330 </a></span> <span class="c2html-comment">/* find kings for check validation */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
374 | <span class="c2html-lineno"><a name="l331" href="#l331">331 </a></span> <span class="c2html-type">uint8_t</span> piececolor = (move->piece & <span class="c2html-macroconst">COLOR_MASK</span>); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
375 | <span class="c2html-lineno"><a name="l332" href="#l332">332 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
376 | <span class="c2html-lineno"><a name="l333" href="#l333">333 </a></span> <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>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
377 | <span class="c2html-lineno"><a name="l334" href="#l334">334 </a></span> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> row = <span class="c2html-macroconst">0</span> ; row < <span class="c2html-macroconst">8</span> ; row++) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
378 | <span class="c2html-lineno"><a name="l335" href="#l335">335 </a></span> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> file = <span class="c2html-macroconst">0</span> ; file < <span class="c2html-macroconst">8</span> ; file++) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
379 | <span class="c2html-lineno"><a name="l336" href="#l336">336 </a></span> <span class="c2html-keyword">if</span> (gamestate->board[row][file] == |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
380 | <span class="c2html-lineno"><a name="l337" href="#l337">337 </a></span> (piececolor == <span class="c2html-macroconst">WHITE</span>?<span class="c2html-macroconst">WKING</span>:<span class="c2html-macroconst">BKING</span>)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
381 | <span class="c2html-lineno"><a name="l338" href="#l338">338 </a></span> mykingfile = file; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
382 | <span class="c2html-lineno"><a name="l339" href="#l339">339 </a></span> mykingrow = row; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
383 | <span class="c2html-lineno"><a name="l340" href="#l340">340 </a></span> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span> (gamestate->board[row][file] == |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
384 | <span class="c2html-lineno"><a name="l341" href="#l341">341 </a></span> (piececolor == <span class="c2html-macroconst">WHITE</span>?<span class="c2html-macroconst">BKING</span>:<span class="c2html-macroconst">WKING</span>)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
385 | <span class="c2html-lineno"><a name="l342" href="#l342">342 </a></span> opkingfile = file; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
386 | <span class="c2html-lineno"><a name="l343" href="#l343">343 </a></span> opkingrow = row; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
387 | <span class="c2html-lineno"><a name="l344" href="#l344">344 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
388 | <span class="c2html-lineno"><a name="l345" href="#l345">345 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
389 | <span class="c2html-lineno"><a name="l346" href="#l346">346 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
390 | <span class="c2html-lineno"><a name="l347" href="#l347">347 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
391 | <span class="c2html-lineno"><a name="l348" href="#l348">348 </a></span> <span class="c2html-comment">/* simulate move for check validation */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
392 | <span class="c2html-lineno"><a name="l349" href="#l349">349 </a></span> GameState simulation = gamestate_copy_sim(gamestate); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
393 | <span class="c2html-lineno"><a name="l350" href="#l350">350 </a></span> Move simmove = *move; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
394 | <span class="c2html-lineno"><a name="l351" href="#l351">351 </a></span> apply_move_impl(&simulation, &simmove, <span class="c2html-macroconst">1</span>); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
395 | <span class="c2html-lineno"><a name="l352" href="#l352">352 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
396 | <span class="c2html-lineno"><a name="l353" href="#l353">353 </a></span> <span class="c2html-comment">/* don't move into or stay in check position */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
397 | <span class="c2html-lineno"><a name="l354" href="#l354">354 </a></span> <span class="c2html-keyword">if</span> (is_covered(&simulation, mykingrow, mykingfile, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
398 | <span class="c2html-lineno"><a name="l355" href="#l355">355 </a></span> opponent_color(piececolor))) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
399 | <span class="c2html-lineno"><a name="l356" href="#l356">356 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
400 | <span class="c2html-lineno"><a name="l357" href="#l357">357 </a></span> gamestate_cleanup(&simulation); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
401 | <span class="c2html-lineno"><a name="l358" href="#l358">358 </a></span> <span class="c2html-keyword">if</span> ((move->piece & <span class="c2html-macroconst">PIECE_MASK</span>) == <span class="c2html-macroconst">KING</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
402 | <span class="c2html-lineno"><a name="l359" href="#l359">359 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">KING_MOVES_INTO_CHECK</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
403 | <span class="c2html-lineno"><a name="l360" href="#l360">360 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
404 | <span class="c2html-lineno"><a name="l361" href="#l361">361 </a></span> <span class="c2html-comment">/* last move is always not null in this case */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
405 | <span class="c2html-lineno"><a name="l362" href="#l362">362 </a></span> <span class="c2html-keyword">return</span> gamestate->lastmove->move.check ? |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
406 | <span class="c2html-lineno"><a name="l363" href="#l363">363 </a></span> <span class="c2html-macroconst">KING_IN_CHECK</span> : <span class="c2html-macroconst">PIECE_PINNED</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
407 | <span class="c2html-lineno"><a name="l364" href="#l364">364 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
408 | <span class="c2html-lineno"><a name="l365" href="#l365">365 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
409 | <span class="c2html-lineno"><a name="l366" href="#l366">366 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
410 | <span class="c2html-lineno"><a name="l367" href="#l367">367 </a></span> <span class="c2html-comment">/* correct check and checkmate flags (move is still valid) */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
411 | <span class="c2html-lineno"><a name="l368" href="#l368">368 </a></span> Move threats[<span class="c2html-macroconst">16</span>]; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
412 | <span class="c2html-lineno"><a name="l369" href="#l369">369 </a></span> <span class="c2html-type">uint8_t</span> threatcount; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
413 | <span class="c2html-lineno"><a name="l370" href="#l370">370 </a></span> move->check = get_threats(&simulation, opkingrow, opkingfile, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
414 | <span class="c2html-lineno"><a name="l371" href="#l371">371 </a></span> piececolor, threats, &threatcount); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
415 | <span class="c2html-lineno"><a name="l372" href="#l372">372 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
416 | <span class="c2html-lineno"><a name="l373" href="#l373">373 </a></span> <span class="c2html-keyword">if</span> (move->check) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
417 | <span class="c2html-lineno"><a name="l374" href="#l374">374 </a></span> <span class="c2html-comment">/* determine possible escape fields */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
418 | <span class="c2html-lineno"><a name="l375" href="#l375">375 </a></span> _Bool canescape = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
419 | <span class="c2html-lineno"><a name="l376" href="#l376">376 </a></span> <span class="c2html-keyword">for</span> (<span class="c2html-keyword">int</span> dr = -<span class="c2html-macroconst">1</span> ; dr <= <span class="c2html-macroconst">1</span> && !canescape ; dr++) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
420 | <span class="c2html-lineno"><a name="l377" href="#l377">377 </a></span> <span class="c2html-keyword">for</span> (<span class="c2html-keyword">int</span> df = -<span class="c2html-macroconst">1</span> ; df <= <span class="c2html-macroconst">1</span> && !canescape ; df++) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
421 | <span class="c2html-lineno"><a name="l378" href="#l378">378 </a></span> <span class="c2html-keyword">if</span> (!(dr == <span class="c2html-macroconst">0</span> && df == <span class="c2html-macroconst">0</span>) && |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
422 | <span class="c2html-lineno"><a name="l379" href="#l379">379 </a></span> isidx(opkingrow + dr) && isidx(opkingfile + df)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
423 | <span class="c2html-lineno"><a name="l380" href="#l380">380 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
424 | <span class="c2html-lineno"><a name="l381" href="#l381">381 </a></span> <span class="c2html-comment">/* escape field neither blocked nor covered */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
425 | <span class="c2html-lineno"><a name="l382" href="#l382">382 </a></span> <span class="c2html-keyword">if</span> ((simulation.board[opkingrow + dr][opkingfile + df] |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
426 | <span class="c2html-lineno"><a name="l383" href="#l383">383 </a></span> & <span class="c2html-macroconst">COLOR_MASK</span>) != opponent_color(piececolor)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
427 | <span class="c2html-lineno"><a name="l384" href="#l384">384 </a></span> canescape |= !is_covered(&simulation, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
428 | <span class="c2html-lineno"><a name="l385" href="#l385">385 </a></span> opkingrow + dr, opkingfile + df, piececolor); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
429 | <span class="c2html-lineno"><a name="l386" href="#l386">386 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
430 | <span class="c2html-lineno"><a name="l387" href="#l387">387 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
431 | <span class="c2html-lineno"><a name="l388" href="#l388">388 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
432 | <span class="c2html-lineno"><a name="l389" href="#l389">389 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
433 | <span class="c2html-lineno"><a name="l390" href="#l390">390 </a></span> <span class="c2html-comment">/* can't escape, can he capture? */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
434 | <span class="c2html-lineno"><a name="l391" href="#l391">391 </a></span> <span class="c2html-keyword">if</span> (!canescape && threatcount == <span class="c2html-macroconst">1</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
435 | <span class="c2html-lineno"><a name="l392" href="#l392">392 </a></span> canescape = is_attacked(&simulation, threats[<span class="c2html-macroconst">0</span>].fromrow, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
436 | <span class="c2html-lineno"><a name="l393" href="#l393">393 </a></span> threats[<span class="c2html-macroconst">0</span>].fromfile, opponent_color(piececolor)); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
437 | <span class="c2html-lineno"><a name="l394" href="#l394">394 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
438 | <span class="c2html-lineno"><a name="l395" href="#l395">395 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
439 | <span class="c2html-lineno"><a name="l396" href="#l396">396 </a></span> <span class="c2html-comment">/* can't capture, can he block? */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
440 | <span class="c2html-lineno"><a name="l397" href="#l397">397 </a></span> <span class="c2html-keyword">if</span> (!canescape && threatcount == <span class="c2html-macroconst">1</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
441 | <span class="c2html-lineno"><a name="l398" href="#l398">398 </a></span> Move *threat = &(threats[<span class="c2html-macroconst">0</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
442 | <span class="c2html-lineno"><a name="l399" href="#l399">399 </a></span> <span class="c2html-type">uint8_t</span> threatpiece = threat->piece & <span class="c2html-macroconst">PIECE_MASK</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
443 | <span class="c2html-lineno"><a name="l400" href="#l400">400 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
444 | <span class="c2html-lineno"><a name="l401" href="#l401">401 </a></span> <span class="c2html-comment">/* knight, pawns and the king cannot be blocked */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
445 | <span class="c2html-lineno"><a name="l402" href="#l402">402 </a></span> <span class="c2html-keyword">if</span> (threatpiece == <span class="c2html-macroconst">BISHOP</span> || threatpiece == <span class="c2html-macroconst">ROOK</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
446 | <span class="c2html-lineno"><a name="l403" href="#l403">403 </a></span> || threatpiece == <span class="c2html-macroconst">QUEEN</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
447 | <span class="c2html-lineno"><a name="l404" href="#l404">404 </a></span> <span class="c2html-keyword">if</span> (threat->fromrow == threat->torow) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
448 | <span class="c2html-lineno"><a name="l405" href="#l405">405 </a></span> <span class="c2html-comment">/* rook aspect (on row) */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
449 | <span class="c2html-lineno"><a name="l406" href="#l406">406 </a></span> <span class="c2html-keyword">int</span> d = threat->tofile > threat->fromfile ? <span class="c2html-macroconst">1</span> : -<span class="c2html-macroconst">1</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
450 | <span class="c2html-lineno"><a name="l407" href="#l407">407 </a></span> <span class="c2html-type">uint8_t</span> file = threat->fromfile; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
451 | <span class="c2html-lineno"><a name="l408" href="#l408">408 </a></span> <span class="c2html-keyword">while</span> (!canescape && file != threat->tofile - d) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
452 | <span class="c2html-lineno"><a name="l409" href="#l409">409 </a></span> file += d; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
453 | <span class="c2html-lineno"><a name="l410" href="#l410">410 </a></span> canescape |= is_protected(&simulation, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
454 | <span class="c2html-lineno"><a name="l411" href="#l411">411 </a></span> threat->torow, file, opponent_color(piececolor)); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
455 | <span class="c2html-lineno"><a name="l412" href="#l412">412 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
456 | <span class="c2html-lineno"><a name="l413" href="#l413">413 </a></span> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span> (threat->fromfile == threat->tofile) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
457 | <span class="c2html-lineno"><a name="l414" href="#l414">414 </a></span> <span class="c2html-comment">/* rook aspect (on file) */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
458 | <span class="c2html-lineno"><a name="l415" href="#l415">415 </a></span> <span class="c2html-keyword">int</span> d = threat->torow > threat->fromrow ? <span class="c2html-macroconst">1</span> : -<span class="c2html-macroconst">1</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
459 | <span class="c2html-lineno"><a name="l416" href="#l416">416 </a></span> <span class="c2html-type">uint8_t</span> row = threat->fromrow; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
460 | <span class="c2html-lineno"><a name="l417" href="#l417">417 </a></span> <span class="c2html-keyword">while</span> (!canescape && row != threat->torow - d) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
461 | <span class="c2html-lineno"><a name="l418" href="#l418">418 </a></span> row += d; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
462 | <span class="c2html-lineno"><a name="l419" href="#l419">419 </a></span> canescape |= is_protected(&simulation, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
463 | <span class="c2html-lineno"><a name="l420" href="#l420">420 </a></span> row, threat->tofile, opponent_color(piececolor)); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
464 | <span class="c2html-lineno"><a name="l421" href="#l421">421 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
465 | <span class="c2html-lineno"><a name="l422" href="#l422">422 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
466 | <span class="c2html-lineno"><a name="l423" href="#l423">423 </a></span> <span class="c2html-comment">/* bishop aspect */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
467 | <span class="c2html-lineno"><a name="l424" href="#l424">424 </a></span> <span class="c2html-keyword">int</span> dr = threat->torow > threat->fromrow ? <span class="c2html-macroconst">1</span> : -<span class="c2html-macroconst">1</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
468 | <span class="c2html-lineno"><a name="l425" href="#l425">425 </a></span> <span class="c2html-keyword">int</span> df = threat->tofile > threat->fromfile ? <span class="c2html-macroconst">1</span> : -<span class="c2html-macroconst">1</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
469 | <span class="c2html-lineno"><a name="l426" href="#l426">426 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
470 | <span class="c2html-lineno"><a name="l427" href="#l427">427 </a></span> <span class="c2html-type">uint8_t</span> row = threat->fromrow; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
471 | <span class="c2html-lineno"><a name="l428" href="#l428">428 </a></span> <span class="c2html-type">uint8_t</span> file = threat->fromfile; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
472 | <span class="c2html-lineno"><a name="l429" href="#l429">429 </a></span> <span class="c2html-keyword">while</span> (!canescape && file != threat->tofile - df |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
473 | <span class="c2html-lineno"><a name="l430" href="#l430">430 </a></span> && row != threat->torow - dr) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
474 | <span class="c2html-lineno"><a name="l431" href="#l431">431 </a></span> row += dr; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
475 | <span class="c2html-lineno"><a name="l432" href="#l432">432 </a></span> file += df; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
476 | <span class="c2html-lineno"><a name="l433" href="#l433">433 </a></span> canescape |= is_protected(&simulation, row, file, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
477 | <span class="c2html-lineno"><a name="l434" href="#l434">434 </a></span> opponent_color(piececolor)); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
478 | <span class="c2html-lineno"><a name="l435" href="#l435">435 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
479 | <span class="c2html-lineno"><a name="l436" href="#l436">436 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
480 | <span class="c2html-lineno"><a name="l437" href="#l437">437 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
481 | <span class="c2html-lineno"><a name="l438" href="#l438">438 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
482 | <span class="c2html-lineno"><a name="l439" href="#l439">439 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
483 | <span class="c2html-lineno"><a name="l440" href="#l440">440 </a></span> <span class="c2html-keyword">if</span> (!canescape) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
484 | <span class="c2html-lineno"><a name="l441" href="#l441">441 </a></span> gamestate->checkmate = <span class="c2html-macroconst">1</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
485 | <span class="c2html-lineno"><a name="l442" href="#l442">442 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
486 | <span class="c2html-lineno"><a name="l443" href="#l443">443 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
487 | <span class="c2html-lineno"><a name="l444" href="#l444">444 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
488 | <span class="c2html-lineno"><a name="l445" href="#l445">445 </a></span> gamestate_cleanup(&simulation); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
489 | <span class="c2html-lineno"><a name="l446" href="#l446">446 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
490 | <span class="c2html-lineno"><a name="l447" href="#l447">447 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">VALID_MOVE_SEMANTICS</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
491 | <span class="c2html-lineno"><a name="l448" href="#l448">448 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
492 | <span class="c2html-lineno"><a name="l449" href="#l449">449 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
493 | <span class="c2html-lineno"><a name="l450" href="#l450">450 </a></span> _Bool get_threats(GameState *gamestate, <span class="c2html-type">uint8_t</span> row, <span class="c2html-type">uint8_t</span> file, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
494 | <span class="c2html-lineno"><a name="l451" href="#l451">451 </a></span> <span class="c2html-type">uint8_t</span> color, Move *threats, <span class="c2html-type">uint8_t</span> *threatcount) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
495 | <span class="c2html-lineno"><a name="l452" href="#l452">452 </a></span> Move candidates[<span class="c2html-macroconst">32</span>]; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
496 | <span class="c2html-lineno"><a name="l453" href="#l453">453 </a></span> <span class="c2html-keyword">int</span> candidatecount = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
497 | <span class="c2html-lineno"><a name="l454" href="#l454">454 </a></span> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> r = <span class="c2html-macroconst">0</span> ; r < <span class="c2html-macroconst">8</span> ; r++) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
498 | <span class="c2html-lineno"><a name="l455" href="#l455">455 </a></span> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> f = <span class="c2html-macroconst">0</span> ; f < <span class="c2html-macroconst">8</span> ; f++) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
499 | <span class="c2html-lineno"><a name="l456" href="#l456">456 </a></span> <span class="c2html-keyword">if</span> ((gamestate->board[r][f] & <span class="c2html-macroconst">COLOR_MASK</span>) == color) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
500 | <span class="c2html-lineno"><a name="l457" href="#l457">457 </a></span> <span class="c2html-comment">// non-capturing move</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
501 | <span class="c2html-lineno"><a name="l458" href="#l458">458 </a></span> memset(&(candidates[candidatecount]), <span class="c2html-macroconst">0</span>, <span class="c2html-keyword">sizeof</span>(Move)); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
502 | <span class="c2html-lineno"><a name="l459" href="#l459">459 </a></span> candidates[candidatecount].piece = gamestate->board[r][f]; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
503 | <span class="c2html-lineno"><a name="l460" href="#l460">460 </a></span> candidates[candidatecount].fromrow = r; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
504 | <span class="c2html-lineno"><a name="l461" href="#l461">461 </a></span> candidates[candidatecount].fromfile = f; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
505 | <span class="c2html-lineno"><a name="l462" href="#l462">462 </a></span> candidates[candidatecount].torow = row; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
506 | <span class="c2html-lineno"><a name="l463" href="#l463">463 </a></span> candidates[candidatecount].tofile = file; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
507 | <span class="c2html-lineno"><a name="l464" href="#l464">464 </a></span> candidatecount++; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
508 | <span class="c2html-lineno"><a name="l465" href="#l465">465 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
509 | <span class="c2html-lineno"><a name="l466" href="#l466">466 </a></span> <span class="c2html-comment">// capturing move</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
510 | <span class="c2html-lineno"><a name="l467" href="#l467">467 </a></span> memcpy(&(candidates[candidatecount]), |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
511 | <span class="c2html-lineno"><a name="l468" href="#l468">468 </a></span> &(candidates[candidatecount-<span class="c2html-macroconst">1</span>]), <span class="c2html-keyword">sizeof</span>(Move)); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
512 | <span class="c2html-lineno"><a name="l469" href="#l469">469 </a></span> candidates[candidatecount].capture = <span class="c2html-macroconst">1</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
513 | <span class="c2html-lineno"><a name="l470" href="#l470">470 </a></span> candidatecount++; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
514 | <span class="c2html-lineno"><a name="l471" href="#l471">471 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
515 | <span class="c2html-lineno"><a name="l472" href="#l472">472 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
516 | <span class="c2html-lineno"><a name="l473" href="#l473">473 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
517 | <span class="c2html-lineno"><a name="l474" href="#l474">474 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
518 | <span class="c2html-lineno"><a name="l475" href="#l475">475 </a></span> <span class="c2html-keyword">if</span> (threatcount) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
519 | <span class="c2html-lineno"><a name="l476" href="#l476">476 </a></span> *threatcount = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
520 | <span class="c2html-lineno"><a name="l477" href="#l477">477 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
521 | <span class="c2html-lineno"><a name="l478" href="#l478">478 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
522 | <span class="c2html-lineno"><a name="l479" href="#l479">479 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
523 | <span class="c2html-lineno"><a name="l480" href="#l480">480 </a></span> _Bool result = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
524 | <span class="c2html-lineno"><a name="l481" href="#l481">481 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
525 | <span class="c2html-lineno"><a name="l482" href="#l482">482 </a></span> <span class="c2html-keyword">for</span> (<span class="c2html-keyword">int</span> i = <span class="c2html-macroconst">0</span> ; i < candidatecount ; i++) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
526 | <span class="c2html-lineno"><a name="l483" href="#l483">483 </a></span> <span class="c2html-keyword">if</span> (validate_move_rules(gamestate, &(candidates[i])) |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
527 | <span class="c2html-lineno"><a name="l484" href="#l484">484 </a></span> == <span class="c2html-macroconst">VALID_MOVE_SEMANTICS</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
528 | <span class="c2html-lineno"><a name="l485" href="#l485">485 </a></span> result = <span class="c2html-macroconst">1</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
529 | <span class="c2html-lineno"><a name="l486" href="#l486">486 </a></span> <span class="c2html-keyword">if</span> (threats && threatcount) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
530 | <span class="c2html-lineno"><a name="l487" href="#l487">487 </a></span> threats[(*threatcount)++] = candidates[i]; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
531 | <span class="c2html-lineno"><a name="l488" href="#l488">488 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
532 | <span class="c2html-lineno"><a name="l489" href="#l489">489 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
533 | <span class="c2html-lineno"><a name="l490" href="#l490">490 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
534 | <span class="c2html-lineno"><a name="l491" href="#l491">491 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
535 | <span class="c2html-lineno"><a name="l492" href="#l492">492 </a></span> <span class="c2html-keyword">return</span> result; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
536 | <span class="c2html-lineno"><a name="l493" href="#l493">493 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
537 | <span class="c2html-lineno"><a name="l494" href="#l494">494 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
538 | <span class="c2html-lineno"><a name="l495" href="#l495">495 </a></span> _Bool is_pinned(GameState *gamestate, Move *move) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
539 | <span class="c2html-lineno"><a name="l496" href="#l496">496 </a></span> <span class="c2html-type">uint8_t</span> color = move->piece & <span class="c2html-macroconst">COLOR_MASK</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
540 | <span class="c2html-lineno"><a name="l497" href="#l497">497 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
541 | <span class="c2html-lineno"><a name="l498" href="#l498">498 </a></span> <span class="c2html-type">uint8_t</span> kingfile = <span class="c2html-macroconst">0</span>, kingrow = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
542 | <span class="c2html-lineno"><a name="l499" href="#l499">499 </a></span> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> row = <span class="c2html-macroconst">0</span> ; row < <span class="c2html-macroconst">8</span> ; row++) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
543 | <span class="c2html-lineno"><a name="l500" href="#l500">500 </a></span> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> file = <span class="c2html-macroconst">0</span> ; file < <span class="c2html-macroconst">8</span> ; file++) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
544 | <span class="c2html-lineno"><a name="l501" href="#l501">501 </a></span> <span class="c2html-keyword">if</span> (gamestate->board[row][file] == (color|<span class="c2html-macroconst">KING</span>)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
545 | <span class="c2html-lineno"><a name="l502" href="#l502">502 </a></span> kingfile = file; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
546 | <span class="c2html-lineno"><a name="l503" href="#l503">503 </a></span> kingrow = row; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
547 | <span class="c2html-lineno"><a name="l504" href="#l504">504 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
548 | <span class="c2html-lineno"><a name="l505" href="#l505">505 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
549 | <span class="c2html-lineno"><a name="l506" href="#l506">506 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
550 | <span class="c2html-lineno"><a name="l507" href="#l507">507 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
551 | <span class="c2html-lineno"><a name="l508" href="#l508">508 </a></span> GameState simulation = gamestate_copy_sim(gamestate); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
552 | <span class="c2html-lineno"><a name="l509" href="#l509">509 </a></span> Move simmove = *move; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
553 | <span class="c2html-lineno"><a name="l510" href="#l510">510 </a></span> apply_move(&simulation, &simmove); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
554 | <span class="c2html-lineno"><a name="l511" href="#l511">511 </a></span> _Bool covered = is_covered(&simulation, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
555 | <span class="c2html-lineno"><a name="l512" href="#l512">512 </a></span> kingrow, kingfile, opponent_color(color)); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
556 | <span class="c2html-lineno"><a name="l513" href="#l513">513 </a></span> gamestate_cleanup(&simulation); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
557 | <span class="c2html-lineno"><a name="l514" href="#l514">514 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
558 | <span class="c2html-lineno"><a name="l515" href="#l515">515 </a></span> <span class="c2html-keyword">return</span> covered; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
559 | <span class="c2html-lineno"><a name="l516" href="#l516">516 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
560 | <span class="c2html-lineno"><a name="l517" href="#l517">517 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
561 | <span class="c2html-lineno"><a name="l518" href="#l518">518 </a></span> _Bool get_real_threats(GameState *gamestate, <span class="c2html-type">uint8_t</span> row, <span class="c2html-type">uint8_t</span> file, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
562 | <span class="c2html-lineno"><a name="l519" href="#l519">519 </a></span> <span class="c2html-type">uint8_t</span> color, Move *threats, <span class="c2html-type">uint8_t</span> *threatcount) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
563 | <span class="c2html-lineno"><a name="l520" href="#l520">520 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
564 | <span class="c2html-lineno"><a name="l521" href="#l521">521 </a></span> <span class="c2html-keyword">if</span> (threatcount) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
565 | <span class="c2html-lineno"><a name="l522" href="#l522">522 </a></span> *threatcount = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
566 | <span class="c2html-lineno"><a name="l523" href="#l523">523 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
567 | <span class="c2html-lineno"><a name="l524" href="#l524">524 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
568 | <span class="c2html-lineno"><a name="l525" href="#l525">525 </a></span> Move candidates[<span class="c2html-macroconst">16</span>]; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
569 | <span class="c2html-lineno"><a name="l526" href="#l526">526 </a></span> <span class="c2html-type">uint8_t</span> candidatecount; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
570 | <span class="c2html-lineno"><a name="l527" href="#l527">527 </a></span> <span class="c2html-keyword">if</span> (get_threats(gamestate, row, file, color, candidates, &candidatecount)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
571 | <span class="c2html-lineno"><a name="l528" href="#l528">528 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
572 | <span class="c2html-lineno"><a name="l529" href="#l529">529 </a></span> _Bool result = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
573 | <span class="c2html-lineno"><a name="l530" href="#l530">530 </a></span> <span class="c2html-type">uint8_t</span> kingfile = <span class="c2html-macroconst">0</span>, kingrow = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
574 | <span class="c2html-lineno"><a name="l531" href="#l531">531 </a></span> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> row = <span class="c2html-macroconst">0</span> ; row < <span class="c2html-macroconst">8</span> ; row++) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
575 | <span class="c2html-lineno"><a name="l532" href="#l532">532 </a></span> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> file = <span class="c2html-macroconst">0</span> ; file < <span class="c2html-macroconst">8</span> ; file++) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
576 | <span class="c2html-lineno"><a name="l533" href="#l533">533 </a></span> <span class="c2html-keyword">if</span> (gamestate->board[row][file] == (color|<span class="c2html-macroconst">KING</span>)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
577 | <span class="c2html-lineno"><a name="l534" href="#l534">534 </a></span> kingfile = file; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
578 | <span class="c2html-lineno"><a name="l535" href="#l535">535 </a></span> kingrow = row; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
579 | <span class="c2html-lineno"><a name="l536" href="#l536">536 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
580 | <span class="c2html-lineno"><a name="l537" href="#l537">537 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
581 | <span class="c2html-lineno"><a name="l538" href="#l538">538 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
582 | <span class="c2html-lineno"><a name="l539" href="#l539">539 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
583 | <span class="c2html-lineno"><a name="l540" href="#l540">540 </a></span> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> i = <span class="c2html-macroconst">0</span> ; i < candidatecount ; i++) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
584 | <span class="c2html-lineno"><a name="l541" href="#l541">541 </a></span> GameState simulation = gamestate_copy_sim(gamestate); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
585 | <span class="c2html-lineno"><a name="l542" href="#l542">542 </a></span> Move simmove = candidates[i]; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
586 | <span class="c2html-lineno"><a name="l543" href="#l543">543 </a></span> apply_move(&simulation, &simmove); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
587 | <span class="c2html-lineno"><a name="l544" href="#l544">544 </a></span> <span class="c2html-keyword">if</span> (!is_covered(&simulation, kingrow, kingfile, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
588 | <span class="c2html-lineno"><a name="l545" href="#l545">545 </a></span> opponent_color(color))) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
589 | <span class="c2html-lineno"><a name="l546" href="#l546">546 </a></span> result = <span class="c2html-macroconst">1</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
590 | <span class="c2html-lineno"><a name="l547" href="#l547">547 </a></span> <span class="c2html-keyword">if</span> (threats && threatcount) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
591 | <span class="c2html-lineno"><a name="l548" href="#l548">548 </a></span> threats[(*threatcount)++] = candidates[i]; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
592 | <span class="c2html-lineno"><a name="l549" href="#l549">549 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
593 | <span class="c2html-lineno"><a name="l550" href="#l550">550 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
594 | <span class="c2html-lineno"><a name="l551" href="#l551">551 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
595 | <span class="c2html-lineno"><a name="l552" href="#l552">552 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
596 | <span class="c2html-lineno"><a name="l553" href="#l553">553 </a></span> <span class="c2html-keyword">return</span> result; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
597 | <span class="c2html-lineno"><a name="l554" href="#l554">554 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
598 | <span class="c2html-lineno"><a name="l555" href="#l555">555 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
599 | <span class="c2html-lineno"><a name="l556" href="#l556">556 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
600 | <span class="c2html-lineno"><a name="l557" href="#l557">557 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
601 | <span class="c2html-lineno"><a name="l558" href="#l558">558 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
602 | <span class="c2html-lineno"><a name="l559" href="#l559">559 </a></span> <span class="c2html-keyword">static</span> <span class="c2html-keyword">int</span> getlocation(GameState *gamestate, Move *move) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
603 | <span class="c2html-lineno"><a name="l560" href="#l560">560 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
604 | <span class="c2html-lineno"><a name="l561" href="#l561">561 </a></span> <span class="c2html-type">uint8_t</span> color = move->piece & <span class="c2html-macroconst">COLOR_MASK</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
605 | <span class="c2html-lineno"><a name="l562" href="#l562">562 </a></span> _Bool incheck = gamestate->lastmove?gamestate->lastmove->move.check:<span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
606 | <span class="c2html-lineno"><a name="l563" href="#l563">563 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
607 | <span class="c2html-lineno"><a name="l564" href="#l564">564 </a></span> Move threats[<span class="c2html-macroconst">16</span>], *threat = <span class="c2html-macroconst">NULL</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
608 | <span class="c2html-lineno"><a name="l565" href="#l565">565 </a></span> <span class="c2html-type">uint8_t</span> threatcount; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
609 | <span class="c2html-lineno"><a name="l566" href="#l566">566 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
610 | <span class="c2html-lineno"><a name="l567" href="#l567">567 </a></span> <span class="c2html-keyword">if</span> (get_threats(gamestate, move->torow, move->tofile, color, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
611 | <span class="c2html-lineno"><a name="l568" href="#l568">568 </a></span> threats, &threatcount)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
612 | <span class="c2html-lineno"><a name="l569" href="#l569">569 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
613 | <span class="c2html-lineno"><a name="l570" href="#l570">570 </a></span> <span class="c2html-keyword">int</span> reason = <span class="c2html-macroconst">INVALID_POSITION</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
614 | <span class="c2html-lineno"><a name="l571" href="#l571">571 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
615 | <span class="c2html-lineno"><a name="l572" href="#l572">572 </a></span> <span class="c2html-comment">// find threats for the specified position</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
616 | <span class="c2html-lineno"><a name="l573" href="#l573">573 </a></span> <span class="c2html-keyword">for</span> (<span class="c2html-type">uint8_t</span> i = <span class="c2html-macroconst">0</span> ; i < threatcount ; i++) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
617 | <span class="c2html-lineno"><a name="l574" href="#l574">574 </a></span> <span class="c2html-keyword">if</span> ((threats[i].piece & (<span class="c2html-macroconst">PIECE_MASK</span> | <span class="c2html-macroconst">COLOR_MASK</span>)) |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
618 | <span class="c2html-lineno"><a name="l575" href="#l575">575 </a></span> == move->piece && |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
619 | <span class="c2html-lineno"><a name="l576" href="#l576">576 </a></span> (move->fromrow == <span class="c2html-macroconst">POS_UNSPECIFIED</span> || |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
620 | <span class="c2html-lineno"><a name="l577" href="#l577">577 </a></span> move->fromrow == threats[i].fromrow) && |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
621 | <span class="c2html-lineno"><a name="l578" href="#l578">578 </a></span> (move->fromfile == <span class="c2html-macroconst">POS_UNSPECIFIED</span> || |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
622 | <span class="c2html-lineno"><a name="l579" href="#l579">579 </a></span> move->fromfile == threats[i].fromfile)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
623 | <span class="c2html-lineno"><a name="l580" href="#l580">580 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
624 | <span class="c2html-lineno"><a name="l581" href="#l581">581 </a></span> <span class="c2html-keyword">if</span> (threat) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
625 | <span class="c2html-lineno"><a name="l582" href="#l582">582 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">AMBIGUOUS_MOVE</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
626 | <span class="c2html-lineno"><a name="l583" href="#l583">583 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
627 | <span class="c2html-lineno"><a name="l584" href="#l584">584 </a></span> <span class="c2html-comment">// found threat is no real threat</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
628 | <span class="c2html-lineno"><a name="l585" href="#l585">585 </a></span> <span class="c2html-keyword">if</span> (is_pinned(gamestate, &(threats[i]))) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
629 | <span class="c2html-lineno"><a name="l586" href="#l586">586 </a></span> reason = incheck?<span class="c2html-macroconst">KING_IN_CHECK</span>:<span class="c2html-macroconst">PIECE_PINNED</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
630 | <span class="c2html-lineno"><a name="l587" href="#l587">587 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
631 | <span class="c2html-lineno"><a name="l588" href="#l588">588 </a></span> threat = &(threats[i]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
632 | <span class="c2html-lineno"><a name="l589" href="#l589">589 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
633 | <span class="c2html-lineno"><a name="l590" href="#l590">590 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
634 | <span class="c2html-lineno"><a name="l591" href="#l591">591 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
635 | <span class="c2html-lineno"><a name="l592" href="#l592">592 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
636 | <span class="c2html-lineno"><a name="l593" href="#l593">593 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
637 | <span class="c2html-lineno"><a name="l594" href="#l594">594 </a></span> <span class="c2html-comment">// can't threaten specified position</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
638 | <span class="c2html-lineno"><a name="l595" href="#l595">595 </a></span> <span class="c2html-keyword">if</span> (!threat) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
639 | <span class="c2html-lineno"><a name="l596" href="#l596">596 </a></span> <span class="c2html-keyword">return</span> reason; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
640 | <span class="c2html-lineno"><a name="l597" href="#l597">597 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
641 | <span class="c2html-lineno"><a name="l598" href="#l598">598 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
642 | <span class="c2html-lineno"><a name="l599" href="#l599">599 </a></span> memcpy(move, threat, <span class="c2html-keyword">sizeof</span>(Move)); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
643 | <span class="c2html-lineno"><a name="l600" href="#l600">600 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">VALID_MOVE_SYNTAX</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
644 | <span class="c2html-lineno"><a name="l601" href="#l601">601 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
645 | <span class="c2html-lineno"><a name="l602" href="#l602">602 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_POSITION</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
646 | <span class="c2html-lineno"><a name="l603" href="#l603">603 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
647 | <span class="c2html-lineno"><a name="l604" href="#l604">604 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
648 | <span class="c2html-lineno"><a name="l605" href="#l605">605 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
649 | <span class="c2html-lineno"><a name="l606" href="#l606">606 </a></span> <span class="c2html-keyword">int</span> eval_move(GameState *gamestate, <span class="c2html-keyword">char</span> *mstr, Move *move, <span class="c2html-type">uint8_t</span> color) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
650 | <span class="c2html-lineno"><a name="l607" href="#l607">607 </a></span> memset(move, <span class="c2html-macroconst">0</span>, <span class="c2html-keyword">sizeof</span>(Move)); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
651 | <span class="c2html-lineno"><a name="l608" href="#l608">608 </a></span> move->fromfile = <span class="c2html-macroconst">POS_UNSPECIFIED</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
652 | <span class="c2html-lineno"><a name="l609" href="#l609">609 </a></span> move->fromrow = <span class="c2html-macroconst">POS_UNSPECIFIED</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
653 | <span class="c2html-lineno"><a name="l610" href="#l610">610 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
654 | <span class="c2html-lineno"><a name="l611" href="#l611">611 </a></span> <span class="c2html-type">size_t</span> len = strlen(mstr); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
655 | <span class="c2html-lineno"><a name="l612" href="#l612">612 </a></span> <span class="c2html-keyword">if</span> (len < <span class="c2html-macroconst">1</span> || len > <span class="c2html-macroconst">6</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
656 | <span class="c2html-lineno"><a name="l613" href="#l613">613 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_MOVE_SYNTAX</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
657 | <span class="c2html-lineno"><a name="l614" href="#l614">614 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
658 | <span class="c2html-lineno"><a name="l615" href="#l615">615 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
659 | <span class="c2html-lineno"><a name="l616" href="#l616">616 </a></span> <span class="c2html-comment">/* evaluate check/checkmate flags */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
660 | <span class="c2html-lineno"><a name="l617" href="#l617">617 </a></span> <span class="c2html-keyword">if</span> (mstr[len-<span class="c2html-macroconst">1</span>] == <span class="c2html-string">'+'</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
661 | <span class="c2html-lineno"><a name="l618" href="#l618">618 </a></span> len--; mstr[len] = <span class="c2html-string">'\0'</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
662 | <span class="c2html-lineno"><a name="l619" href="#l619">619 </a></span> move->check = <span class="c2html-macroconst">1</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
663 | <span class="c2html-lineno"><a name="l620" href="#l620">620 </a></span> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span> (mstr[len-<span class="c2html-macroconst">1</span>] == <span class="c2html-string">'#'</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
664 | <span class="c2html-lineno"><a name="l621" href="#l621">621 </a></span> len--; mstr[len] = <span class="c2html-string">'\0'</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
665 | <span class="c2html-lineno"><a name="l622" href="#l622">622 </a></span> <span class="c2html-comment">/* ignore - validation should set game state */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
666 | <span class="c2html-lineno"><a name="l623" href="#l623">623 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
667 | <span class="c2html-lineno"><a name="l624" href="#l624">624 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
668 | <span class="c2html-lineno"><a name="l625" href="#l625">625 </a></span> <span class="c2html-comment">/* evaluate promotion */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
669 | <span class="c2html-lineno"><a name="l626" href="#l626">626 </a></span> <span class="c2html-keyword">if</span> (len > <span class="c2html-macroconst">3</span> && mstr[len-<span class="c2html-macroconst">2</span>] == <span class="c2html-string">'='</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
670 | <span class="c2html-lineno"><a name="l627" href="#l627">627 </a></span> move->promotion = getpiece(mstr[len-<span class="c2html-macroconst">1</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
671 | <span class="c2html-lineno"><a name="l628" href="#l628">628 </a></span> <span class="c2html-keyword">if</span> (!move->promotion) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
672 | <span class="c2html-lineno"><a name="l629" href="#l629">629 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_MOVE_SYNTAX</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
673 | <span class="c2html-lineno"><a name="l630" href="#l630">630 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
674 | <span class="c2html-lineno"><a name="l631" href="#l631">631 </a></span> move->promotion |= color; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
675 | <span class="c2html-lineno"><a name="l632" href="#l632">632 </a></span> len -= <span class="c2html-macroconst">2</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
676 | <span class="c2html-lineno"><a name="l633" href="#l633">633 </a></span> mstr[len] = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
677 | <span class="c2html-lineno"><a name="l634" href="#l634">634 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
678 | <span class="c2html-lineno"><a name="l635" href="#l635">635 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
679 | <span class="c2html-lineno"><a name="l636" href="#l636">636 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
680 | <span class="c2html-lineno"><a name="l637" href="#l637">637 </a></span> <span class="c2html-keyword">if</span> (len == <span class="c2html-macroconst">2</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
681 | <span class="c2html-lineno"><a name="l638" href="#l638">638 </a></span> <span class="c2html-comment">/* pawn move (e.g. "e4") */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
682 | <span class="c2html-lineno"><a name="l639" href="#l639">639 </a></span> move->piece = <span class="c2html-macroconst">PAWN</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
683 | <span class="c2html-lineno"><a name="l640" href="#l640">640 </a></span> move->tofile = fileidx(mstr[<span class="c2html-macroconst">0</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
684 | <span class="c2html-lineno"><a name="l641" href="#l641">641 </a></span> move->torow = rowidx(mstr[<span class="c2html-macroconst">1</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
685 | <span class="c2html-lineno"><a name="l642" href="#l642">642 </a></span> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span> (len == <span class="c2html-macroconst">3</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
686 | <span class="c2html-lineno"><a name="l643" href="#l643">643 </a></span> <span class="c2html-keyword">if</span> (strcmp(mstr, <span class="c2html-string">"O-O"</span>) == <span class="c2html-macroconst">0</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
687 | <span class="c2html-lineno"><a name="l644" href="#l644">644 </a></span> <span class="c2html-comment">/* king side castling */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
688 | <span class="c2html-lineno"><a name="l645" href="#l645">645 </a></span> move->piece = <span class="c2html-macroconst">KING</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
689 | <span class="c2html-lineno"><a name="l646" href="#l646">646 </a></span> move->fromfile = fileidx(<span class="c2html-string">'e'</span>); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
690 | <span class="c2html-lineno"><a name="l647" href="#l647">647 </a></span> move->tofile = fileidx(<span class="c2html-string">'g'</span>); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
691 | <span class="c2html-lineno"><a name="l648" href="#l648">648 </a></span> move->fromrow = move->torow = color == <span class="c2html-macroconst">WHITE</span> ? <span class="c2html-macroconst">0</span> : <span class="c2html-macroconst">7</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
692 | <span class="c2html-lineno"><a name="l649" href="#l649">649 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
693 | <span class="c2html-lineno"><a name="l650" href="#l650">650 </a></span> <span class="c2html-comment">/* move (e.g. "Nf3") */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
694 | <span class="c2html-lineno"><a name="l651" href="#l651">651 </a></span> move->piece = getpiece(mstr[<span class="c2html-macroconst">0</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
695 | <span class="c2html-lineno"><a name="l652" href="#l652">652 </a></span> move->tofile = fileidx(mstr[<span class="c2html-macroconst">1</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
696 | <span class="c2html-lineno"><a name="l653" href="#l653">653 </a></span> move->torow = rowidx(mstr[<span class="c2html-macroconst">2</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
697 | <span class="c2html-lineno"><a name="l654" href="#l654">654 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
698 | <span class="c2html-lineno"><a name="l655" href="#l655">655 </a></span> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span> (len == <span class="c2html-macroconst">4</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
699 | <span class="c2html-lineno"><a name="l656" href="#l656">656 </a></span> move->piece = getpiece(mstr[<span class="c2html-macroconst">0</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
700 | <span class="c2html-lineno"><a name="l657" href="#l657">657 </a></span> <span class="c2html-keyword">if</span> (!move->piece) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
701 | <span class="c2html-lineno"><a name="l658" href="#l658">658 </a></span> move->piece = <span class="c2html-macroconst">PAWN</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
702 | <span class="c2html-lineno"><a name="l659" href="#l659">659 </a></span> move->fromfile = fileidx(mstr[<span class="c2html-macroconst">0</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
703 | <span class="c2html-lineno"><a name="l660" href="#l660">660 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
704 | <span class="c2html-lineno"><a name="l661" href="#l661">661 </a></span> <span class="c2html-keyword">if</span> (mstr[<span class="c2html-macroconst">1</span>] == <span class="c2html-string">'x'</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
705 | <span class="c2html-lineno"><a name="l662" href="#l662">662 </a></span> <span class="c2html-comment">/* capture (e.g. "Nxf3", "dxe5") */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
706 | <span class="c2html-lineno"><a name="l663" href="#l663">663 </a></span> move->capture = <span class="c2html-macroconst">1</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
707 | <span class="c2html-lineno"><a name="l664" href="#l664">664 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
708 | <span class="c2html-lineno"><a name="l665" href="#l665">665 </a></span> <span class="c2html-comment">/* move (e.g. "Ndf3", "N2c3", "e2e4") */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
709 | <span class="c2html-lineno"><a name="l666" href="#l666">666 </a></span> <span class="c2html-keyword">if</span> (isfile(mstr[<span class="c2html-macroconst">1</span>])) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
710 | <span class="c2html-lineno"><a name="l667" href="#l667">667 </a></span> move->fromfile = fileidx(mstr[<span class="c2html-macroconst">1</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
711 | <span class="c2html-lineno"><a name="l668" href="#l668">668 </a></span> <span class="c2html-keyword">if</span> (move->piece == <span class="c2html-macroconst">PAWN</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
712 | <span class="c2html-lineno"><a name="l669" href="#l669">669 </a></span> move->piece = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
713 | <span class="c2html-lineno"><a name="l670" href="#l670">670 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
714 | <span class="c2html-lineno"><a name="l671" href="#l671">671 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
715 | <span class="c2html-lineno"><a name="l672" href="#l672">672 </a></span> move->fromrow = rowidx(mstr[<span class="c2html-macroconst">1</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
716 | <span class="c2html-lineno"><a name="l673" href="#l673">673 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
717 | <span class="c2html-lineno"><a name="l674" href="#l674">674 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
718 | <span class="c2html-lineno"><a name="l675" href="#l675">675 </a></span> move->tofile = fileidx(mstr[<span class="c2html-macroconst">2</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
719 | <span class="c2html-lineno"><a name="l676" href="#l676">676 </a></span> move->torow = rowidx(mstr[<span class="c2html-macroconst">3</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
720 | <span class="c2html-lineno"><a name="l677" href="#l677">677 </a></span> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span> (len == <span class="c2html-macroconst">5</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
721 | <span class="c2html-lineno"><a name="l678" href="#l678">678 </a></span> <span class="c2html-keyword">if</span> (strcmp(mstr, <span class="c2html-string">"O-O-O"</span>) == <span class="c2html-macroconst">0</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
722 | <span class="c2html-lineno"><a name="l679" href="#l679">679 </a></span> <span class="c2html-comment">/* queen side castling "O-O-O" */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
723 | <span class="c2html-lineno"><a name="l680" href="#l680">680 </a></span> move->piece = <span class="c2html-macroconst">KING</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
724 | <span class="c2html-lineno"><a name="l681" href="#l681">681 </a></span> move->fromfile = fileidx(<span class="c2html-string">'e'</span>); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
725 | <span class="c2html-lineno"><a name="l682" href="#l682">682 </a></span> move->tofile = fileidx(<span class="c2html-string">'c'</span>); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
726 | <span class="c2html-lineno"><a name="l683" href="#l683">683 </a></span> move->fromrow = move->torow = color == <span class="c2html-macroconst">WHITE</span> ? <span class="c2html-macroconst">0</span> : <span class="c2html-macroconst">7</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
727 | <span class="c2html-lineno"><a name="l684" href="#l684">684 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
728 | <span class="c2html-lineno"><a name="l685" href="#l685">685 </a></span> move->piece = getpiece(mstr[<span class="c2html-macroconst">0</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
729 | <span class="c2html-lineno"><a name="l686" href="#l686">686 </a></span> <span class="c2html-keyword">if</span> (mstr[<span class="c2html-macroconst">2</span>] == <span class="c2html-string">'x'</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
730 | <span class="c2html-lineno"><a name="l687" href="#l687">687 </a></span> move->capture = <span class="c2html-macroconst">1</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
731 | <span class="c2html-lineno"><a name="l688" href="#l688">688 </a></span> <span class="c2html-keyword">if</span> (move->piece) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
732 | <span class="c2html-lineno"><a name="l689" href="#l689">689 </a></span> <span class="c2html-comment">/* capture (e.g. "Ndxf3") */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
733 | <span class="c2html-lineno"><a name="l690" href="#l690">690 </a></span> move->fromfile = fileidx(mstr[<span class="c2html-macroconst">1</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
734 | <span class="c2html-lineno"><a name="l691" href="#l691">691 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
735 | <span class="c2html-lineno"><a name="l692" href="#l692">692 </a></span> <span class="c2html-comment">/* long notation capture (e.g. "e5xf6") */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
736 | <span class="c2html-lineno"><a name="l693" href="#l693">693 </a></span> move->piece = <span class="c2html-macroconst">PAWN</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
737 | <span class="c2html-lineno"><a name="l694" href="#l694">694 </a></span> move->fromfile = fileidx(mstr[<span class="c2html-macroconst">0</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
738 | <span class="c2html-lineno"><a name="l695" href="#l695">695 </a></span> move->fromrow = rowidx(mstr[<span class="c2html-macroconst">1</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
739 | <span class="c2html-lineno"><a name="l696" href="#l696">696 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
740 | <span class="c2html-lineno"><a name="l697" href="#l697">697 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
741 | <span class="c2html-lineno"><a name="l698" href="#l698">698 </a></span> <span class="c2html-comment">/* long notation move (e.g. "Nc5a4") */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
742 | <span class="c2html-lineno"><a name="l699" href="#l699">699 </a></span> move->fromfile = fileidx(mstr[<span class="c2html-macroconst">1</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
743 | <span class="c2html-lineno"><a name="l700" href="#l700">700 </a></span> move->fromrow = rowidx(mstr[<span class="c2html-macroconst">2</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
744 | <span class="c2html-lineno"><a name="l701" href="#l701">701 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
745 | <span class="c2html-lineno"><a name="l702" href="#l702">702 </a></span> move->tofile = fileidx(mstr[<span class="c2html-macroconst">3</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
746 | <span class="c2html-lineno"><a name="l703" href="#l703">703 </a></span> move->torow = rowidx(mstr[<span class="c2html-macroconst">4</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
747 | <span class="c2html-lineno"><a name="l704" href="#l704">704 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
748 | <span class="c2html-lineno"><a name="l705" href="#l705">705 </a></span> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span> (len == <span class="c2html-macroconst">6</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
749 | <span class="c2html-lineno"><a name="l706" href="#l706">706 </a></span> <span class="c2html-comment">/* long notation capture (e.g. "Nc5xf3") */</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
750 | <span class="c2html-lineno"><a name="l707" href="#l707">707 </a></span> <span class="c2html-keyword">if</span> (mstr[<span class="c2html-macroconst">3</span>] == <span class="c2html-string">'x'</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
751 | <span class="c2html-lineno"><a name="l708" href="#l708">708 </a></span> move->capture = <span class="c2html-macroconst">1</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
752 | <span class="c2html-lineno"><a name="l709" href="#l709">709 </a></span> move->piece = getpiece(mstr[<span class="c2html-macroconst">0</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
753 | <span class="c2html-lineno"><a name="l710" href="#l710">710 </a></span> move->fromfile = fileidx(mstr[<span class="c2html-macroconst">1</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
754 | <span class="c2html-lineno"><a name="l711" href="#l711">711 </a></span> move->fromrow = rowidx(mstr[<span class="c2html-macroconst">2</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
755 | <span class="c2html-lineno"><a name="l712" href="#l712">712 </a></span> move->tofile = fileidx(mstr[<span class="c2html-macroconst">4</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
756 | <span class="c2html-lineno"><a name="l713" href="#l713">713 </a></span> move->torow = rowidx(mstr[<span class="c2html-macroconst">5</span>]); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
757 | <span class="c2html-lineno"><a name="l714" href="#l714">714 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
758 | <span class="c2html-lineno"><a name="l715" href="#l715">715 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
759 | <span class="c2html-lineno"><a name="l716" href="#l716">716 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
760 | <span class="c2html-lineno"><a name="l717" href="#l717">717 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
761 | <span class="c2html-lineno"><a name="l718" href="#l718">718 </a></span> <span class="c2html-keyword">if</span> (move->piece) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
762 | <span class="c2html-lineno"><a name="l719" href="#l719">719 </a></span> <span class="c2html-keyword">if</span> (move->piece == <span class="c2html-macroconst">PAWN</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
763 | <span class="c2html-lineno"><a name="l720" href="#l720">720 </a></span> && move->torow == (color==<span class="c2html-macroconst">WHITE</span>?<span class="c2html-macroconst">7</span>:<span class="c2html-macroconst">0</span>) |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
764 | <span class="c2html-lineno"><a name="l721" href="#l721">721 </a></span> && !move->promotion) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
765 | <span class="c2html-lineno"><a name="l722" href="#l722">722 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">NEED_PROMOTION</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
766 | <span class="c2html-lineno"><a name="l723" href="#l723">723 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
767 | <span class="c2html-lineno"><a name="l724" href="#l724">724 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
768 | <span class="c2html-lineno"><a name="l725" href="#l725">725 </a></span> move->piece |= color; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
769 | <span class="c2html-lineno"><a name="l726" href="#l726">726 </a></span> <span class="c2html-keyword">if</span> (move->fromfile == <span class="c2html-macroconst">POS_UNSPECIFIED</span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
770 | <span class="c2html-lineno"><a name="l727" href="#l727">727 </a></span> || move->fromrow == <span class="c2html-macroconst">POS_UNSPECIFIED</span>) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
771 | <span class="c2html-lineno"><a name="l728" href="#l728">728 </a></span> <span class="c2html-keyword">return</span> getlocation(gamestate, move); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
772 | <span class="c2html-lineno"><a name="l729" href="#l729">729 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
773 | <span class="c2html-lineno"><a name="l730" href="#l730">730 </a></span> <span class="c2html-keyword">return</span> chkidx(move) ? <span class="c2html-macroconst">VALID_MOVE_SYNTAX</span> : <span class="c2html-macroconst">INVALID_POSITION</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
774 | <span class="c2html-lineno"><a name="l731" href="#l731">731 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
775 | <span class="c2html-lineno"><a name="l732" href="#l732">732 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
776 | <span class="c2html-lineno"><a name="l733" href="#l733">733 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">INVALID_MOVE_SYNTAX</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
777 | <span class="c2html-lineno"><a name="l734" href="#l734">734 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
778 | <span class="c2html-lineno"><a name="l735" href="#l735">735 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
779 | <span class="c2html-lineno"><a name="l736" href="#l736">736 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
780 | <span class="c2html-lineno"><a name="l737" href="#l737">737 </a></span> _Bool is_protected(GameState *gamestate, <span class="c2html-type">uint8_t</span> row, <span class="c2html-type">uint8_t</span> file, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
781 | <span class="c2html-lineno"><a name="l738" href="#l738">738 </a></span> <span class="c2html-type">uint8_t</span> color) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
782 | <span class="c2html-lineno"><a name="l739" href="#l739">739 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
783 | <span class="c2html-lineno"><a name="l740" href="#l740">740 </a></span> Move threats[<span class="c2html-macroconst">16</span>]; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
784 | <span class="c2html-lineno"><a name="l741" href="#l741">741 </a></span> <span class="c2html-type">uint8_t</span> threatcount; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
785 | <span class="c2html-lineno"><a name="l742" href="#l742">742 </a></span> <span class="c2html-keyword">if</span> (get_real_threats(gamestate, row, file, color, threats, &threatcount)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
786 | <span class="c2html-lineno"><a name="l743" href="#l743">743 </a></span> <span class="c2html-keyword">for</span> (<span class="c2html-keyword">int</span> i = <span class="c2html-macroconst">0</span> ; i < threatcount ; i++) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
787 | <span class="c2html-lineno"><a name="l744" href="#l744">744 </a></span> <span class="c2html-keyword">if</span> (threats[i].piece != (color|<span class="c2html-macroconst">KING</span>)) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
788 | <span class="c2html-lineno"><a name="l745" href="#l745">745 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">1</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
789 | <span class="c2html-lineno"><a name="l746" href="#l746">746 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
790 | <span class="c2html-lineno"><a name="l747" href="#l747">747 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
791 | <span class="c2html-lineno"><a name="l748" href="#l748">748 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
792 | <span class="c2html-lineno"><a name="l749" href="#l749">749 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
793 | <span class="c2html-lineno"><a name="l750" href="#l750">750 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
794 | <span class="c2html-lineno"><a name="l751" href="#l751">751 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
795 | <span class="c2html-lineno"><a name="l752" href="#l752">752 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
796 | <span class="c2html-lineno"><a name="l753" href="#l753">753 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
797 | <span class="c2html-lineno"><a name="l754" href="#l754">754 </a></span> <span class="c2html-type">uint16_t</span> remaining_movetime(GameInfo *gameinfo, GameState *gamestate, |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
798 | <span class="c2html-lineno"><a name="l755" href="#l755">755 </a></span> <span class="c2html-type">uint8_t</span> color) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
799 | <span class="c2html-lineno"><a name="l756" href="#l756">756 </a></span> <span class="c2html-keyword">if</span> (!gameinfo->timecontrol) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
800 | <span class="c2html-lineno"><a name="l757" href="#l757">757 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
801 | <span class="c2html-lineno"><a name="l758" href="#l758">758 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
802 | <span class="c2html-lineno"><a name="l759" href="#l759">759 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
803 | <span class="c2html-lineno"><a name="l760" href="#l760">760 </a></span> <span class="c2html-keyword">if</span> (gamestate->movelist) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
804 | <span class="c2html-lineno"><a name="l761" href="#l761">761 </a></span> <span class="c2html-type">uint16_t</span> time = gameinfo->time; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
805 | <span class="c2html-lineno"><a name="l762" href="#l762">762 </a></span> <span class="c2html-type">suseconds_t</span> micros = <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
806 | <span class="c2html-lineno"><a name="l763" href="#l763">763 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
807 | <span class="c2html-lineno"><a name="l764" href="#l764">764 </a></span> MoveList *movelist = color == <span class="c2html-macroconst">WHITE</span> ? |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
808 | <span class="c2html-lineno"><a name="l765" href="#l765">765 </a></span> gamestate->movelist : gamestate->movelist->next; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
809 | <span class="c2html-lineno"><a name="l766" href="#l766">766 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
810 | <span class="c2html-lineno"><a name="l767" href="#l767">767 </a></span> <span class="c2html-keyword">while</span> (movelist) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
811 | <span class="c2html-lineno"><a name="l768" href="#l768">768 </a></span> time += gameinfo->addtime; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
812 | <span class="c2html-lineno"><a name="l769" href="#l769">769 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
813 | <span class="c2html-lineno"><a name="l770" href="#l770">770 </a></span> <span class="c2html-keyword">struct</span> movetimeval *movetime = &(movelist->move.movetime); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
814 | <span class="c2html-lineno"><a name="l771" href="#l771">771 </a></span> <span class="c2html-keyword">if</span> (movetime->tv_sec >= time) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
815 | <span class="c2html-lineno"><a name="l772" href="#l772">772 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
816 | <span class="c2html-lineno"><a name="l773" href="#l773">773 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
817 | <span class="c2html-lineno"><a name="l774" href="#l774">774 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
818 | <span class="c2html-lineno"><a name="l775" href="#l775">775 </a></span> time -= movetime->tv_sec; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
819 | <span class="c2html-lineno"><a name="l776" href="#l776">776 </a></span> micros += movetime->tv_usec; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
820 | <span class="c2html-lineno"><a name="l777" href="#l777">777 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
821 | <span class="c2html-lineno"><a name="l778" href="#l778">778 </a></span> movelist = movelist->next ? movelist->next->next : <span class="c2html-macroconst">NULL</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
822 | <span class="c2html-lineno"><a name="l779" href="#l779">779 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
823 | <span class="c2html-lineno"><a name="l780" href="#l780">780 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
824 | <span class="c2html-lineno"><a name="l781" href="#l781">781 </a></span> <span class="c2html-type">time_t</span> sec; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
825 | <span class="c2html-lineno"><a name="l782" href="#l782">782 </a></span> movelist = gamestate->lastmove; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
826 | <span class="c2html-lineno"><a name="l783" href="#l783">783 </a></span> <span class="c2html-keyword">if</span> ((movelist->move.piece & <span class="c2html-macroconst">COLOR_MASK</span>) != color) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
827 | <span class="c2html-lineno"><a name="l784" href="#l784">784 </a></span> <span class="c2html-keyword">struct</span> movetimeval *lastmovetstamp = &(movelist->move.timestamp); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
828 | <span class="c2html-lineno"><a name="l785" href="#l785">785 </a></span> <span class="c2html-keyword">struct</span> timeval currenttstamp; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
829 | <span class="c2html-lineno"><a name="l786" href="#l786">786 </a></span> gettimeofday(¤ttstamp, <span class="c2html-macroconst">NULL</span>); |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
830 | <span class="c2html-lineno"><a name="l787" href="#l787">787 </a></span> micros += currenttstamp.tv_usec - lastmovetstamp->tv_usec; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
831 | <span class="c2html-lineno"><a name="l788" href="#l788">788 </a></span> sec = currenttstamp.tv_sec - lastmovetstamp->tv_sec; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
832 | <span class="c2html-lineno"><a name="l789" href="#l789">789 </a></span> <span class="c2html-keyword">if</span> (sec >= time) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
833 | <span class="c2html-lineno"><a name="l790" href="#l790">790 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
834 | <span class="c2html-lineno"><a name="l791" href="#l791">791 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
835 | <span class="c2html-lineno"><a name="l792" href="#l792">792 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
836 | <span class="c2html-lineno"><a name="l793" href="#l793">793 </a></span> time -= sec; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
837 | <span class="c2html-lineno"><a name="l794" href="#l794">794 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
838 | <span class="c2html-lineno"><a name="l795" href="#l795">795 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
839 | <span class="c2html-lineno"><a name="l796" href="#l796">796 </a></span> sec = micros / 1e6L; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
840 | <span class="c2html-lineno"><a name="l797" href="#l797">797 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
841 | <span class="c2html-lineno"><a name="l798" href="#l798">798 </a></span> <span class="c2html-keyword">if</span> (sec >= time) { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
842 | <span class="c2html-lineno"><a name="l799" href="#l799">799 </a></span> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
843 | <span class="c2html-lineno"><a name="l800" href="#l800">800 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
844 | <span class="c2html-lineno"><a name="l801" href="#l801">801 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
845 | <span class="c2html-lineno"><a name="l802" href="#l802">802 </a></span> time -= sec; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
846 | <span class="c2html-lineno"><a name="l803" href="#l803">803 </a></span> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
847 | <span class="c2html-lineno"><a name="l804" href="#l804">804 </a></span> <span class="c2html-keyword">return</span> time; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
848 | <span class="c2html-lineno"><a name="l805" href="#l805">805 </a></span> } <span class="c2html-keyword">else</span> { |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
849 | <span class="c2html-lineno"><a name="l806" href="#l806">806 </a></span> <span class="c2html-keyword">return</span> gameinfo->time; |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
850 | <span class="c2html-lineno"><a name="l807" href="#l807">807 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
851 | <span class="c2html-lineno"><a name="l808" href="#l808">808 </a></span> } |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
852 | </pre> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
853 | </body> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
854 | </html> |
c06ab07fd29d
increases input buffer + adds regression tests
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
855 |