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