This preset now uses the new code for identifying check, checkmate, and stalemate. Let me know of any problems with it.
Syntax Error on line 13
Unknown error concerning the definition of subroutine postauto1.
Edit the Settings File for Fusion Chess
For the sake of debugging, here is the full GAME Code program that this error occurred in. The lines have been properly indented to help you spot scope errors.
0 echo This preset now uses the new code for identifying check, checkmate, and stalemate. Let me know of any problems with it. 1 setflag a1 a8 h1 h8 e1 e8 2 set k findpiece k spaces 3 set K findpiece K spaces 4 set ep false 5 include chess2 6 set fuse assoc RB Q BR Q RN M NR M NB A BN A KR O KB Y KN X rb q br q rn m nr m nb a bn a kr o kb y kn x 7 set COMPOUND array Q M A O Y X 8 set compound array q m a o y x 9 set simple array r b n 10 set SIMPLE array R B N 11 setglobal piecekeys allvars 12 setglobal noerrorcheck true 13 sub postauto1 14 if != moved P 15 set ep false 16 if == moved K 17 if match moved var simple 18 if isupper old 19 if != space dest elem join moved old var fuse 20 set np space dest 21 die You may not move a moved onto a old to make a #np 22 endif 23 elseif != moved P 24 set ep false 25 if != space dest moved 26 if not match moved elem join space origin space dest var fuse elem join space dest space origin var fuse 27 set msg list array "You may not split a " moved " into a " space origin " and a " space dest "." 28 die #msg 29 endif 30 endif 31 endif 32 set legal false 33 if match moved P K 34 gosub moved origin dest 35 if equal moved K 36 set K dest 37 endif 38 elseif match moved Q R B N 39 set legal fn moved origin dest 40 if == moved R 41 unsetflag origin 42 else 43 unsetflag dest 44 endif 45 elseif islower moved 46 die You may not move one of your opponent's pieces. 47 endif 48 if not var legal 49 die You may not move a moved from origin to dest 50 endif 51 if sub checked #K 52 die You may not move into check. 53 endif 54 endsub 55 sub postauto2 56 if islower old 57 if != space dest elem join moved old var fuse 58 set np space dest 59 die You may not move a moved onto a old to make a #np 60 endif 61 endif 62 elseif != moved p 63 set ep false 64 if != space dest moved 65 if not match moved elem join space origin space dest var fuse elem join space dest space origin var fuse 66 set msg list array "You may not split a " moved " into a " space origin " and a " space dest "." 67 die #msg 68 endif 69 endif 70 endif 71 set legal false 72 if match moved p k 73 gosub moved origin dest 74 if equal moved k 75 set k dest 76 endif 77 elseif match moved q r b n 78 set legal fn moved origin dest 79 if == moved r 80 unsetflag origin 81 else 82 unsetflag dest 83 endif 84 elseif isupper moved 85 die You may not move one of your opponent's pieces. 86 endif 87 if not var legal 88 die You may not move a moved from origin to dest 89 endif 90 if sub checked #k 91 die You may not move into check. 92 endif 93 endsub 94 if sub checked #K 95 if sub stalemated #K 96 say Checkmate! Black has won! 97 won 98 else 99 say Check! 100 endif 101 elseif sub stalemated #K 102 say Stalemate! The game is drawn. 103 drawn 104 endif 105 end 106 107 lib chess2 108 set wpr 2 109 set bpr 7 110 set fps 2 111 set pzs 1 112 set wcastle c1 g1 113 set bcastle c8 g8 114 setsystem maxmove 2 115 ban commands allmoves 116 allow moves 1 captures 1 promotions 2 117 for x piecekeys 118 if match #x P K p k 119 continue 120 elseif isupper #x 121 push wprom #x 122 elseif islower #x 123 push bprom #x 124 endif 125 next 126 def N checkleap #0 #1 1 2 127 def B checkride #0 #1 1 1 128 def R checkride #0 #1 1 0 129 def Q fn B #0 #1 or fn R #0 #1 130 def K checkleap #0 #1 1 1 or checkleap #0 #1 1 0 131 def M fn N #0 #1 or fn R #0 #1 132 def A fn N #0 #1 or fn B #0 #1 133 def n checkleap #0 #1 1 2 134 def b checkride #0 #1 1 1 135 def r checkride #0 #1 1 0 136 def q fn B #0 #1 or fn R #0 #1 137 def k checkleap #0 #1 1 1 or checkleap #0 #1 1 0 138 def m fn N #0 #1 or fn R #0 #1 139 def a fn N #0 #1 or fn B #0 #1 140 def C cond cond empty #0 capture (not empty #1) (checkhop #0 #1 0 1) (checkride #0 #1 0 1) and #1 141 def V cond cond empty #0 capture (not empty #1) (checkhop #0 #1 1 1) (checkride #0 #1 1 1) and #1 142 def c cond cond empty #0 capture (not empty #1) (checkhop #0 #1 0 1) (checkride #0 #1 0 1) and #1 143 def v cond cond empty #0 capture (not empty #1) (checkhop #0 #1 1 1) (checkride #0 #1 1 1) and #1 144 def P remove var ep and checkleap #0 #1 1 1 and == var ep join filename #1 rankname #0 or and checkride #0 #1 0 1 == rankname #0 var wpr or checkleap #0 #1 0 1 and empty #1 or and islower space #1 checkleap #0 #1 1 1 and <= distance #0 #1 var fps and > rank #1 rank #0 145 def p remove var ep and checkleap #0 #1 1 1 and == var ep join filename #1 rankname #0 or and checkride #0 #1 0 1 == rankname #0 var bpr or checkleap #0 #1 0 1 and empty #1 or and isupper space #1 checkleap #0 #1 1 1 and <= distance #0 #1 var fps and < rank #1 rank #0 146 def PL filter lambda (onboard #1) mergeall where #ori -1 1 where #ori 1 1 values lambda (where #ori 0 #1) range 1 var fps =ori 147 def pL filter lambda (onboard #1) mergeall where #ori -1 -1 where #ori 1 -1 values lambda (where #ori 0 neg #1) range 1 var fps =ori 148 setflag rules 149 def NL leaps #0 1 2 150 def BL rays #0 1 1 151 def RL rays #0 1 0 152 def VL rays #0 1 1 153 def CL rays #0 1 0 154 def QL merge rays #0 1 0 rays #0 1 1 155 def KL merge leaps #0 1 0 leaps #0 1 1 156 def AL merge leaps #0 1 2 rays #0 1 1 157 def ML merge rays #0 1 0 leaps #0 1 2 158 def nL leaps #0 1 2 159 def bL rays #0 1 1 160 def rL rays #0 1 0 161 def vL rays #0 1 1 162 def cL rays #0 1 0 163 def qL merge rays #0 1 0 rays #0 1 1 164 def kL merge leaps #0 1 0 leaps #0 1 1 165 def aL merge leaps #0 1 2 rays #0 1 1 166 def mL merge rays #0 1 0 leaps #0 1 2 167 sub checked king 168 my from piece 169 if isupper cond empty #king moved space #king 170 def enemies onlylower 171 else 172 def enemies onlyupper 173 endif 174 for (from piece) fn enemies 175 if fn #piece #from #king 176 return #from 177 endif 178 next 179 return false 180 endsub 181 sub P from to 182 local ydir 183 if == file #from file #to and not capture 184 set legal checkaleap #from #to 0 1 185 if var legal 186 set ep false 187 else 188 set legal checkaride #from #to 0 1 and <= distance #from #to #fps and == rankname #from #wpr 189 set ep #to 190 endif 191 set epc false 192 elseif capture or #ep 193 set legal checkaleap #from #to -1 1 or checkaleap #from #to 1 1 194 set epc false 195 if not capture and var legal 196 set legal > rank #to rank #ep and < rankname #to #bpr and == file #to file #ep 197 if var legal 198 capture #ep 199 set epc #ep 200 endif 201 endif 202 set ep false 203 endif 204 if != space #to moved and onboard where #to 0 #pzs 205 die "You may not promote a Pawn until it reaches the promotion zone." 206 endif 207 if not onboard where #to 0 #pzs 208 if == P space #to 209 askpromote #wprom 210 elseif not match space #to var wprom 211 set np space #to 212 die "You may not promote your Pawn to a" #np 213 endif 214 endif 215 return true 216 endsub 217 sub p from to 218 if == file #from file #to and not capture 219 set legal checkaleap #from #to 0 -1 220 if var legal 221 set ep false 222 else 223 set legal checkaride #from #to 0 -1 and <= distance #from #to #fps and == rankname #from #bpr 224 set ep #to 225 endif 226 set epc false 227 elseif capture or #ep 228 set legal checkaleap #from #to -1 -1 or checkaleap #from #to 1 -1 229 set epc false 230 if not capture and var legal 231 set legal < rank #to rank #ep and > rankname #to #wpr and == file #to file #ep 232 if var legal 233 capture #ep 234 set epc #ep 235 endif 236 endif 237 set ep false 238 endif 239 if != space #to moved and onboard where #to 0 neg #pzs 240 die You may not promote a Pawn until it reaches the promotion zone. 241 endif 242 if not onboard where #to 0 neg #pzs 243 if == p space #to 244 askpromote #bprom 245 elseif not match space #to var bprom 246 set np space #to 247 die You may not promote your Pawn to a #np 248 endif 249 endif 250 return true 251 endsub 252 sub K from to 253 set legal fn K #from #to 254 if match #to where #from 2 0 where #from -2 0 255 set legal sub castle 256 endif 257 set K #to 258 unsetflag #from 259 endsub 260 sub k from to 261 set legal fn K #from #to 262 if match #to where #from 2 0 where #from -2 0 263 set legal sub castle 264 endif 265 set k #to 266 unsetflag #from 267 endsub 268 sub castle 269 local c RPOS RDEST xdir 270 if not flag #from 271 die A King may not castle after it moves. 272 endif 273 if capture 274 die A King may not castle to an occupied space. 275 endif 276 set xdir sign minus file #to file #from 277 if not checkaride #from #to #xdir 0 278 die A King may not castle across any occupied space. 279 endif 280 set c #to 281 do 282 set c where #c #xdir 0 283 if flag #c 284 break 285 elseif not onboard #c 286 die No piece was found to castle with. 287 elseif not empty #c 288 die The King cannot castle with the piece at #c 289 endif 290 loop 291 set RPOS #c 292 move #to #from 293 if sub checked #from 294 die A King may not castle out of check. 295 endif 296 store 297 for c path #from #to 298 move #from #c 299 if sub checked #c 300 die A King may not castle through check. 301 endif 302 restore 303 next 304 move #from #to 305 if == count var subargs 0 306 set RDEST where #to neg #xdir 0 307 else 308 set RDEST elem 0 subargs 309 endif 310 unsetflag #RPOS 311 move #RPOS #RDEST 312 return true 313 endsub 314 sub castlepos from to 315 local c RPOS RDEST xdir safe 316 verify flag #from 317 verify empty #to 318 set xdir sign minus file #to file #from 319 verify checkaride #from #to #xdir 0 320 verify not sub checked #from 321 set c #to 322 do 323 set c where #c #xdir 0 324 if flag #c 325 break 326 endif 327 verify onboard #c 328 verify empty #c 329 loop 330 verify flag #c 331 set RPOS #c 332 store 333 for c path #from #to 334 move #from #c 335 set safe not sub checked #c 336 restore 337 verify #safe 338 next 339 move #from #to 340 set RDEST where #to neg #xdir 0 341 move #RPOS #RDEST 342 return true 343 endsub 344 sub stalemated kingpos 345 store 346 local from piece to 347 if isupper space #kingpos 348 def friends onlyupper 349 def nofriends noupper 350 def friend isupper #0 351 set cspaces var wcastle 352 else 353 def friends onlylower 354 def nofriends nolower 355 def friend islower #0 356 set cspaces var bcastle 357 endif 358 set royal space var kingpos 359 store 360 for (from piece) fn friends 361 for to fn join #piece L #from 362 if fn #piece #from #to and not fn friend space #to and onboard #to 363 move #from #to 364 if not sub checked cond == #from #kingpos #to #kingpos 365 setlegal #from #to 366 endif 367 endif 368 restore 369 next 370 next 371 for to var cspaces 372 if sub castlepos #kingpos #to 373 if not sub checked #to 374 setlegal #kingpos #to 375 endif 376 endif 377 restore 378 next 379 return cond count system legalmoves false true 380 endsub 381 sub enpassant piece from to 382 local pe 383 verify not capture and #ep 384 verify == P toupper #piece 385 set pe join filename #to rankname #from 386 verify == #ep #pe 387 capture #ep 388 endsub 389 endlibfunctions
Array ( [N] => Array ( [0] => checkleap [1] => #0 [2] => #1 [3] => 1 [4] => 2 ) [B] => Array ( [0] => checkride [1] => #0 [2] => #1 [3] => 1 [4] => 1 ) [R] => Array ( [0] => checkride [1] => #0 [2] => #1 [3] => 1 [4] => 0 ) [Q] => Array ( [0] => fn [1] => B [2] => #0 [3] => #1 [4] => or [5] => fn [6] => R [7] => #0 [8] => #1 ) [K] => Array ( [0] => checkleap [1] => #0 [2] => #1 [3] => 1 [4] => 1 [5] => or [6] => checkleap [7] => #0 [8] => #1 [9] => 1 [10] => 0 ) [M] => Array ( [0] => fn [1] => N [2] => #0 [3] => #1 [4] => or [5] => fn [6] => R [7] => #0 [8] => #1 ) [A] => Array ( [0] => fn [1] => N [2] => #0 [3] => #1 [4] => or [5] => fn [6] => B [7] => #0 [8] => #1 ) [n] => Array ( [0] => checkleap [1] => #0 [2] => #1 [3] => 1 [4] => 2 ) [b] => Array ( [0] => checkride [1] => #0 [2] => #1 [3] => 1 [4] => 1 ) [r] => Array ( [0] => checkride [1] => #0 [2] => #1 [3] => 1 [4] => 0 ) [q] => Array ( [0] => fn [1] => B [2] => #0 [3] => #1 [4] => or [5] => fn [6] => R [7] => #0 [8] => #1 ) [k] => Array ( [0] => checkleap [1] => #0 [2] => #1 [3] => 1 [4] => 1 [5] => or [6] => checkleap [7] => #0 [8] => #1 [9] => 1 [10] => 0 ) [m] => Array ( [0] => fn [1] => N [2] => #0 [3] => #1 [4] => or [5] => fn [6] => R [7] => #0 [8] => #1 ) [a] => Array ( [0] => fn [1] => N [2] => #0 [3] => #1 [4] => or [5] => fn [6] => B [7] => #0 [8] => #1 ) [C] => Array ( [0] => cond [1] => cond [2] => empty [3] => #0 [4] => capture [5] => Array ( [0] => not [1] => empty [2] => #1 ) [6] => Array ( [0] => checkhop [1] => #0 [2] => #1 [3] => 0 [4] => 1 ) [7] => Array ( [0] => checkride [1] => #0 [2] => #1 [3] => 0 [4] => 1 ) [8] => and [9] => #1 ) [V] => Array ( [0] => cond [1] => cond [2] => empty [3] => #0 [4] => capture [5] => Array ( [0] => not [1] => empty [2] => #1 ) [6] => Array ( [0] => checkhop [1] => #0 [2] => #1 [3] => 1 [4] => 1 ) [7] => Array ( [0] => checkride [1] => #0 [2] => #1 [3] => 1 [4] => 1 ) [8] => and [9] => #1 ) [c] => Array ( [0] => cond [1] => cond [2] => empty [3] => #0 [4] => capture [5] => Array ( [0] => not [1] => empty [2] => #1 ) [6] => Array ( [0] => checkhop [1] => #0 [2] => #1 [3] => 0 [4] => 1 ) [7] => Array ( [0] => checkride [1] => #0 [2] => #1 [3] => 0 [4] => 1 ) [8] => and [9] => #1 ) [v] => Array ( [0] => cond [1] => cond [2] => empty [3] => #0 [4] => capture [5] => Array ( [0] => not [1] => empty [2] => #1 ) [6] => Array ( [0] => checkhop [1] => #0 [2] => #1 [3] => 1 [4] => 1 ) [7] => Array ( [0] => checkride [1] => #0 [2] => #1 [3] => 1 [4] => 1 ) [8] => and [9] => #1 ) [P] => Array ( [0] => remove [1] => var [2] => ep [3] => and [4] => checkleap [5] => #0 [6] => #1 [7] => 1 [8] => 1 [9] => and [10] => == [11] => var [12] => ep [13] => join [14] => filename [15] => #1 [16] => rankname [17] => #0 [18] => or [19] => and [20] => checkride [21] => #0 [22] => #1 [23] => 0 [24] => 1 [25] => == [26] => rankname [27] => #0 [28] => var [29] => wpr [30] => or [31] => checkleap [32] => #0 [33] => #1 [34] => 0 [35] => 1 [36] => and [37] => empty [38] => #1 [39] => or [40] => and [41] => islower [42] => space [43] => #1 [44] => checkleap [45] => #0 [46] => #1 [47] => 1 [48] => 1 [49] => and [50] => <= [51] => distance [52] => #0 [53] => #1 [54] => var [55] => fps [56] => and [57] => > [58] => rank [59] => #1 [60] => rank [61] => #0 ) [p] => Array ( [0] => remove [1] => var [2] => ep [3] => and [4] => checkleap [5] => #0 [6] => #1 [7] => 1 [8] => 1 [9] => and [10] => == [11] => var [12] => ep [13] => join [14] => filename [15] => #1 [16] => rankname [17] => #0 [18] => or [19] => and [20] => checkride [21] => #0 [22] => #1 [23] => 0 [24] => 1 [25] => == [26] => rankname [27] => #0 [28] => var [29] => bpr [30] => or [31] => checkleap [32] => #0 [33] => #1 [34] => 0 [35] => 1 [36] => and [37] => empty [38] => #1 [39] => or [40] => and [41] => isupper [42] => space [43] => #1 [44] => checkleap [45] => #0 [46] => #1 [47] => 1 [48] => 1 [49] => and [50] => <= [51] => distance [52] => #0 [53] => #1 [54] => var [55] => fps [56] => and [57] => < [58] => rank [59] => #1 [60] => rank [61] => #0 ) [PL] => Array ( [0] => filter [1] => lambda [2] => Array ( [0] => onboard [1] => #1 ) [3] => mergeall [4] => where [5] => #ori [6] => -1 [7] => 1 [8] => where [9] => #ori [10] => 1 [11] => 1 [12] => values [13] => lambda [14] => Array ( [0] => where [1] => #ori [2] => 0 [3] => #1 ) [15] => range [16] => 1 [17] => var [18] => fps [19] => =ori ) [pL] => Array ( [0] => filter [1] => lambda [2] => Array ( [0] => onboard [1] => #1 ) [3] => mergeall [4] => where [5] => #ori [6] => -1 [7] => -1 [8] => where [9] => #ori [10] => 1 [11] => -1 [12] => values [13] => lambda [14] => Array ( [0] => where [1] => #ori [2] => 0 [3] => neg [4] => #1 ) [15] => range [16] => 1 [17] => var [18] => fps [19] => =ori ) [NL] => Array ( [0] => leaps [1] => #0 [2] => 1 [3] => 2 ) [BL] => Array ( [0] => rays [1] => #0 [2] => 1 [3] => 1 ) [RL] => Array ( [0] => rays [1] => #0 [2] => 1 [3] => 0 ) [VL] => Array ( [0] => rays [1] => #0 [2] => 1 [3] => 1 ) [CL] => Array ( [0] => rays [1] => #0 [2] => 1 [3] => 0 ) [QL] => Array ( [0] => merge [1] => rays [2] => #0 [3] => 1 [4] => 0 [5] => rays [6] => #0 [7] => 1 [8] => 1 ) [KL] => Array ( [0] => merge [1] => leaps [2] => #0 [3] => 1 [4] => 0 [5] => leaps [6] => #0 [7] => 1 [8] => 1 ) [AL] => Array ( [0] => merge [1] => leaps [2] => #0 [3] => 1 [4] => 2 [5] => rays [6] => #0 [7] => 1 [8] => 1 ) [ML] => Array ( [0] => merge [1] => rays [2] => #0 [3] => 1 [4] => 0 [5] => leaps [6] => #0 [7] => 1 [8] => 2 ) [nL] => Array ( [0] => leaps [1] => #0 [2] => 1 [3] => 2 ) [bL] => Array ( [0] => rays [1] => #0 [2] => 1 [3] => 1 ) [rL] => Array ( [0] => rays [1] => #0 [2] => 1 [3] => 0 ) [vL] => Array ( [0] => rays [1] => #0 [2] => 1 [3] => 1 ) [cL] => Array ( [0] => rays [1] => #0 [2] => 1 [3] => 0 ) [qL] => Array ( [0] => merge [1] => rays [2] => #0 [3] => 1 [4] => 0 [5] => rays [6] => #0 [7] => 1 [8] => 1 ) [kL] => Array ( [0] => merge [1] => leaps [2] => #0 [3] => 1 [4] => 0 [5] => leaps [6] => #0 [7] => 1 [8] => 1 ) [aL] => Array ( [0] => merge [1] => leaps [2] => #0 [3] => 1 [4] => 2 [5] => rays [6] => #0 [7] => 1 [8] => 1 ) [mL] => Array ( [0] => merge [1] => rays [2] => #0 [3] => 1 [4] => 0 [5] => leaps [6] => #0 [7] => 1 [8] => 2 ) )uservar
Array ( [0] => Array ( [main] => Array ( [k] => e8 [K] => e1 [ep] => [wpr] => 2 [bpr] => 7 [fps] => 2 [pzs] => 1 [wcastle] => Array ( [0] => g1 [1] => c1 ) [bcastle] => Array ( [0] => g8 [1] => c8 ) [x] => K [bprom] => Array ( [0] => r [1] => n [2] => b [3] => q ) [wprom] => Array ( [0] => R [1] => N [2] => B [3] => Q ) [fuse] => Array ( [RB] => Q [BR] => Q [RN] => M [NR] => M [NB] => A [BN] => A [KR] => O [KB] => Y [KN] => X [rb] => q [br] => q [rn] => m [nr] => m [nb] => a [bn] => a [kr] => o [kb] => y [kn] => x ) [COMPOUND] => Array ( [0] => Q [1] => M [2] => A [3] => O [4] => Y [5] => X ) [compound] => Array ( [0] => q [1] => m [2] => a [3] => o [4] => y [5] => x ) [simple] => Array ( [0] => r [1] => b [2] => n ) [SIMPLE] => Array ( [0] => R [1] => B [2] => N ) ) ) )mline
Array ( [0] => MoveLine Object ( [movenum] => 0 [move] => [level] => 0 [comment] => [length] => 0 [newturn] => [turn] => 0 ) )allmoves
Array ( )movelist
constants
Array