You may not move a m from g8 to g6
Use your browser's BACK button to go back to the previous page, then reload if necessary.
For general reference, here is the complete list of moves:
1. P e2-e4 1... g8-g6 2. P d2-d4 2... d8-e6 3. P b2-b3 3... c7-c5 4. P d4-d5 4... e6-e4 5. FA f1-e2 5... e4-h4 // Hi Scott! 6. P g2-g3 6... h4-h2 7. BD h1-e4 7... f7-f5 8. BD e4-g2 8... f8-d8 9. WA g1-h1 9... h2-h5 10. FA e2-d3 10... h5-f6 11. BD a1-f6 11... e7-f6 // nice! 12. FA d3-f5 12... d8-d6 13. CA d1-e3 13... e8-g8 14. CA e3-f4If this is your settings file, you may edit it at https://www.chessvariants.com/play/pbm/play.php?game=Chess+with+Different+Armies&settings=default&submit=Edit
Here is a code listing:
0 if == thismove null 1 say This preset enforces the rules and displays legal moves. 2 endif 3 setflag a1 a8 h1 h8 e1 e8 4 set k findpiece k spaces 5 set K findpiece K spaces 6 set ep false 7 include cwda 8 setsystem originalpieces piececount 9 sub postauto1 10 if isupper old 11 die You may not capture your own pieces. 12 endif 13 if not equal moved P 14 set ep false 15 if unequal space dest moved 16 die You may not change the type of this piece. 17 endif 18 endif 19 set legal false 20 if match moved P K 21 gosub moved origin dest 22 if equal moved K 23 set K dest 24 endif 25 elseif match moved Q R B N A E F C I M D G L W J H 26 set legal fn moved origin dest 27 if match moved R A I L 28 unsetflag origin 29 endif 30 endif 31 if not var legal 32 die You may not move a moved from origin to dest 33 endif 34 if fn ATTACKEDBYB #K 35 die You may not move into check. 36 endif 37 endsub 38 sub postauto2 39 if islower old 40 die You may not capture your own pieces. 41 endif 42 if not equal moved p 43 set ep false 44 if unequal space dest moved 45 die You may not change the type of this piece. 46 endif 47 endif 48 set legal false 49 if match moved p k 50 gosub moved origin dest 51 if equal moved k 52 set k dest 53 endif 54 elseif match moved q r b n a e f c i m d g l w j h 55 set legal fn moved origin dest 56 if equal moved r a i l 57 unsetflag origin 58 endif 59 endif 60 if not var legal 61 die You may not move a moved from origin to dest 62 endif 63 if fn ATTACKEDBYW #k 64 die You may not move into check. 65 endif 66 endsub 67 moveindex 0 68 MOVE: P e2-e4 69 postauto1 70 moveindex 1 71 MOVE: g8-g6 72 postauto2 73 moveindex 2 74 MOVE: P d2-d4 75 postauto1 76 moveindex 3 77 MOVE: d8-e6 78 postauto2 79 moveindex 4 80 MOVE: P b2-b3 81 postauto1 82 moveindex 5 83 MOVE: c7-c5 84 postauto2 85 moveindex 6 86 MOVE: P d4-d5 87 postauto1 88 moveindex 7 89 MOVE: e6-e4 90 postauto2 91 moveindex 8 92 MOVE: FA f1-e2 93 postauto1 94 moveindex 9 95 MOVE: e4-h4 96 postauto2 97 moveindex 10 98 MOVE: P g2-g3 99 postauto1 100 moveindex 11 101 MOVE: h4-h2 102 postauto2 103 moveindex 12 104 MOVE: BD h1-e4 105 postauto1 106 moveindex 13 107 MOVE: f7-f5 108 postauto2 109 moveindex 14 110 MOVE: BD e4-g2 111 postauto1 112 moveindex 15 113 MOVE: f8-d8 114 postauto2 115 moveindex 16 116 MOVE: WA g1-h1 117 postauto1 118 moveindex 17 119 MOVE: h2-h5 120 postauto2 121 moveindex 18 122 MOVE: FA e2-d3 123 postauto1 124 moveindex 19 125 MOVE: h5-f6 126 postauto2 127 moveindex 20 128 MOVE: BD a1-f6 129 postauto1 130 moveindex 21 131 MOVE: e7-f6 132 postauto2 133 moveindex 22 134 MOVE: FA d3-f5 135 postauto1 136 moveindex 23 137 MOVE: d8-d6 138 postauto2 139 moveindex 24 140 MOVE: CA d1-e3 141 postauto1 142 moveindex 25 143 MOVE: e8-g8 144 postauto2 145 moveindex 26 146 MOVE: CA e3-f4 147 postauto1 148 set checks sub checks #k 149 if var checks 150 if sub checkmated #k #checks 151 say Checkmate! White has won! 152 won 153 else 154 say Check! 155 endif 156 elseif sub stalemated #k 157 say Stalemate! The game is drawn. 158 drawn 159 endif 160 end 161 162 lib cwda 163 include chess 164 alias BD A WA E FA F CA C CR I FN M CN D CO G SR L WR W HD J CH H bd a wa e fa f ca c cr i fn m cn d co g sr l wr w hd j ch h 165 def AF checkleap #0 #1 2 2 166 def DB checkleap #0 #1 2 0 167 def FZ checkleap #0 #1 1 1 168 def WZ checkleap #0 #1 1 0 169 def A fn B #0 #1 or fn DB #0 #1 170 def E fn WZ #0 #1 or fn AF #0 #1 171 def F fn FZ #0 #1 or fn AF #0 #1 or fn DB #0 #1 172 def C fn B #0 #1 or fn N #0 #1 173 def a fn b #0 #1 or fn DB #0 #1 174 def e fn WZ #0 #1 or fn AF #0 #1 175 def f fn FZ #0 #1 or fn AF #0 #1 or fn DB #0 #1 176 def c fn b #0 #1 or fn n #0 #1 177 def AL merge rays #0 1 1 leaps #0 2 0 178 def EL merge leaps #0 1 0 leaps #0 2 2 179 def FL merge leaps #0 1 1 merge leaps #0 2 2 leaps #0 2 0 180 def CL merge rays #0 1 1 leaps #0 1 2 181 def aL merge rays #0 1 1 leaps #0 2 0 182 def eL merge leaps #0 1 0 leaps #0 2 2 183 def fL merge leaps #0 1 1 merge leaps #0 2 2 leaps #0 2 0 184 def cL merge rays #0 1 1 leaps #0 1 2 185 def I checkaride #0 #1 1 0 or checkaride #0 #1 -1 0 or checkaride #0 #1 0 1 or checkaleap #0 #1 -1 -1 or checkaleap #0 #1 1 -1 or checkaleap #0 #1 0 -1 186 def M checkaleap #0 #1 1 2 or checkaleap #0 #1 -1 2 or checkaleap #0 #1 1 -2 or checkaleap #0 #1 -1 -2 or fn FZ #0 #1 187 def D checkaleap #0 #1 1 2 or checkaleap #0 #1 -1 2 or checkaleap #0 #1 2 1 or checkaleap #0 #1 -2 1 or checkaleap #0 #1 -1 -1 or checkaleap #0 #1 1 -1 or checkaleap #0 #1 -1 0 or checkaleap #0 #1 1 0 or checkaleap #0 #1 0 -1 188 def G checkaride #0 #1 1 0 or checkaride #0 #1 -1 0 or checkaride #0 #1 0 1 or checkaleap #0 #1 1 2 or checkaleap #0 #1 -1 2 or checkaleap #0 #1 2 1 or checkaleap #0 #1 -2 1 or fn FZ #0 #1 or fn WZ #0 #1 189 def i checkaride #0 #1 1 0 or checkaride #0 #1 -1 0 or checkaride #0 #1 0 -1 or checkaleap #0 #1 -1 1 or checkaleap #0 #1 1 1 or checkaleap #0 #1 0 1 190 def m checkaleap #0 #1 1 2 or checkaleap #0 #1 -1 2 or checkaleap #0 #1 1 -2 or checkaleap #0 #1 -1 -2 or fn FZ #0 #1 191 def d checkaleap #0 #1 1 -2 or checkaleap #0 #1 -1 -2 or checkaleap #0 #1 2 -1 or checkaleap #0 #1 -2 -1 or checkaleap #0 #1 -1 1 or checkaleap #0 #1 1 1 or checkaleap #0 #1 -1 0 or checkaleap #0 #1 1 0 or checkaleap #0 #1 0 1 192 def g checkaride #0 #1 1 0 or checkaride #0 #1 -1 0 or checkaride #0 #1 0 -1 or checkaleap #0 #1 1 -2 or checkaleap #0 #1 -1 -2 or checkaleap #0 #1 2 -1 or checkaleap #0 #1 -2 -1 or fn FZ #0 #1 or fn WZ #0 #1 193 def IL merge rays #0 1 0 array where #0 -1 -1 where #0 1 -1 194 def iL merge rays #0 1 0 array where #0 -1 1 where #0 1 1 195 def ML merge leaps #0 1 1 array where #0 1 2 where #0 -1 2 where #0 1 -2 where #0 -1 -2 196 def mL merge leaps #0 1 1 array where #0 1 2 where #0 -1 2 where #0 1 -2 where #0 -1 -2 197 def DL array where #0 1 2 where #0 -1 2 where #0 2 1 where #0 -2 1 where #0 -1 0 where #0 1 0 where #0 0 -1 where #0 -1 -1 where #0 1 -1 198 def dL array where #0 1 -2 where #0 -1 -2 where #0 2 -1 where #0 -2 -1 where #0 -1 0 where #0 1 0 where #0 0 1 where #0 -1 1 where #0 1 1 199 def GL merge merge leaps #0 1 1 rays #0 1 0 array where #0 1 2 where #0 -1 2 where #0 2 1 where #0 -2 1 200 def gL merge merge leaps #0 1 1 rays #0 1 0 array where #0 1 -2 where #0 -1 -2 where #0 2 -1 where #0 -2 -1 201 def L fn R #0 #1 and <= distance #0 #1 4 202 def W fn DB #0 #1 or fn WZ #0 #1 203 def J fn DB #0 #1 or fn FZ #0 #1 or checkleap #0 #1 0 3 204 def H fn N #0 #1 or fn R #0 #1 205 def l fn r #0 #1 and <= distance #0 #1 4 206 def w fn DB #0 #1 or fn WZ #0 #1 207 def j fn DB #0 #1 or fn FZ #0 #1 or checkleap #0 #1 0 3 208 def h fn n #0 #1 or fn r #0 #1 209 def LL merge merge leaps #0 1 0 leaps #0 2 0 merge leaps #0 3 0 leaps #0 4 0 210 def WL merge leaps #0 1 0 leaps #0 2 0 211 def JL merge leaps #0 3 0 merge leaps #0 1 1 leaps #0 2 0 212 def HL merge rays #0 1 0 leaps #0 1 2 213 def lL merge merge leaps #0 1 0 leaps #0 2 0 merge leaps #0 3 0 leaps #0 4 0 214 def wL merge leaps #0 1 0 leaps #0 2 0 215 def jL merge leaps #0 3 0 merge leaps #0 1 1 leaps #0 2 0 216 def hL merge rays #0 1 0 leaps #0 1 2 217 def DABBABAH check what #0 0 -2 check what #0 -2 0 check what #0 0 2 check what #0 2 0 target #1 218 def ALFIL check what #0 -2 -2 check what #0 -2 2 check what #0 2 -2 check what #0 2 2 target #1 219 def LONGKNIGHT check what #0 1 2 check what #0 -1 2 check what #0 1 -2 check what #0 -1 -2 target #1 220 def FOREKNIGHT check what #0 1 2 check what #0 -1 2 check what #0 2 1 check what #0 -2 1 target #1 221 def BACKKNIGHT check what #0 1 -2 check what #0 -1 -2 check what #0 2 -1 check what #0 -2 -1 target #1 222 def FOREKING check what #0 -1 1 check what #0 0 1 check what #0 1 1 target #1 223 def BACKKING check what #0 -1 -1 check what #0 0 -1 check what #0 1 -1 target #1 224 def SIDEKING check what #0 1 0 check what #0 -1 0 target #1 225 def FOREROOK match insight #0 0 1 #1 226 def BACKROOK match insight #0 0 -1 #1 227 def SIDEROOK check insight #0 1 0 check insight #0 -1 0 target #1 228 def SHORTROOK check inrange #0 0 -1 4 check inrange #0 -1 0 4 check inrange #0 0 1 4 check inrange #0 1 0 4 target #1 229 def O3 check what #0 0 -3 check what #0 -3 0 check what #0 0 3 check what #0 3 0 target #1 230 def WAZIR check what #0 0 -1 check what #0 -1 0 check what #0 0 1 check what #0 1 0 target #1 231 def FERZ check what #0 -1 -1 check what #0 -1 1 check what #0 1 -1 check what #0 1 1 target #1 232 def ATTACKEDBYW fn WPAWN #0 or fn O3 #0 J or fn SIDEKING #0 D or fn LONGKNIGHT #0 M or fn SHORTROOK #0 L or fn FOREKING #0 (I D) or fn ALFIL #0 (E F) or fn DABBABAH #0 (A F W J) or fn WAZIR #0 (E W K G) or fn FERZ #0 (F J K G M) or fn FOREROOK #0 (H Q R) or fn BACKROOK #0 (I G H Q R) or fn SIDEROOK #0 (I G H Q R) or fn FOREKNIGHT #0 (C H N) or fn BACKKNIGHT #0 (D G C H N) or fn BISHOP #0 (A C B Q) 233 def ATTACKEDBYB fn BPAWN #0 or fn O3 #0 j or fn SIDEKING #0 d or fn LONGKNIGHT #0 m or fn SHORTROOK #0 l or fn BACKKING #0 (i d) or fn ALFIL #0 (e f) or fn DABBABAH #0 (a f w j) or fn WAZIR #0 (e w k g) or fn FERZ #0 (f j k g m) or fn BACKROOK #0 (h q r) or fn FOREROOK #0 (i g h q r) or fn SIDEROOK #0 (i g h q r) or fn BACKKNIGHT #0 (c h n) or fn FOREKNIGHT #0 (d g c h n) or fn BISHOP #0 (a c b q) 234 sub checkedthru king loc 235 my dir c 236 set c revealed #king #loc 237 if samecase space #king space #c or not #c 238 return false 239 endif 240 set dir direction #king #loc 241 switch #dir 242 case n 243 if match space #c R r Q q i g H h 244 return #c 245 endif 246 if <= distance #king #loc 4 and match space #c L l 247 return #c 248 endif 249 return false 250 case s 251 if match space #c R r Q q I G H h 252 return #c 253 endif 254 if <= distance #king #loc 4 and match space #c L l 255 return #c 256 endif 257 return false 258 case e w 259 if match space #c R r Q q I i G g H h 260 return #c 261 endif 262 if <= distance #king #loc 4 and match space #c L l 263 return #c 264 endif 265 return false 266 case nw sw ne se 267 if match space #c B b Q q A a C c 268 return #c 269 endif 270 return false 271 default 272 return false 273 endswitch 274 endsub 275 set cdist 2 276 set CDIST 2 277 sub K from to 278 set legal fn K #from #to 279 if match #to where #from 2 0 where #from neg #CDIST 0 280 set legal sub castle 281 endif 282 set K #to 283 unsetflag #from 284 endsub 285 sub k from to 286 set legal fn K #from #to 287 if match #to where #from 2 0 where #from neg #cdist 0 288 set legal sub castle 289 endif 290 set k #to 291 unsetflag #from 292 endsub 293 set x 0 294 switch space d1 295 case C 296 set x 1 297 break 298 case G 299 set x 2 300 break 301 case H 302 set x 3 303 break 304 default 305 break 306 endswitch 307 switch space d8 308 case c 309 set x plus #x 4 310 break 311 case g 312 set x plus #x 8 313 break 314 case h 315 set x plus #x 12 316 break 317 default 318 break 319 endswitch 320 if == #x 0 321 if flag neversame 322 set x rand 1 12 323 if > #x 4 324 inc x 325 endif 326 if > #x 9 327 inc x 328 endif 329 else 330 set x rand 1 15 331 endif 332 endif 333 set wx mod #x 4 334 set bx / - #x #wx 4 335 switch #wx 336 case 0 337 add R a1 338 add N b1 339 add B c1 340 add Q d1 341 add B f1 342 add N g1 343 add R h1 344 pushall wprom R N B Q 345 pushall bprom r n b q 346 break 347 case 1 348 add A a1 349 add E b1 350 add F c1 351 add C d1 352 add F f1 353 add E g1 354 add A h1 355 pushall wprom A E F C 356 pushall bprom a e f c 357 set CDIST 3 358 set wcastle b1 g1 359 break 360 case 2 361 add I a1 362 add M b1 363 add D c1 364 add G d1 365 add D f1 366 add M g1 367 add I h1 368 pushall wprom I M D G 369 pushall bprom i m d g 370 break 371 case 3 372 add L a1 373 add W b1 374 add J c1 375 add H d1 376 add J f1 377 add W g1 378 add L h1 379 pushall wprom L W J H 380 pushall bprom l w j h 381 break 382 default 383 break 384 endswitch 385 switch #bx 386 case 0 387 add r a8 388 add n b8 389 add b c8 390 add q d8 391 add b f8 392 add n g8 393 add r h8 394 if != #wx 0 395 pushall wprom R N B Q 396 pushall bprom r n b q 397 endif 398 break 399 case 1 400 add a a8 401 add e b8 402 add f c8 403 add c d8 404 add f f8 405 add e g8 406 add a h8 407 if != #wx 1 408 pushall wprom A E F C 409 pushall bprom a e f c 410 endif 411 set cdist 3 412 set bcastle b8 g8 413 break 414 case 2 415 add i a8 416 add m b8 417 add d c8 418 add g d8 419 add d f8 420 add m g8 421 add i h8 422 if != #wx 2 423 pushall wprom I M D G 424 pushall bprom i m d g 425 endif 426 break 427 case 3 428 add l a8 429 add w b8 430 add j c8 431 add h d8 432 add j f8 433 add w g8 434 add l h8 435 if != #wx 3 436 pushall wprom L W J H 437 pushall bprom l w j h 438 endif 439 break 440 default 441 break 442 endswitch 443 setglobal piecekeys merge var wprom var bprom 444 endlib 445 lib chess 446 set wpr 2 447 set bpr 7 448 set fps 2 449 set pzs 1 450 set wcastle c1 g1 451 set bcastle c8 g8 452 do 453 local x 454 for x piecekeys 455 if match #x P K p k 456 continue 457 elseif isupper #x 458 push wprom #x 459 elseif islower #x 460 push bprom #x 461 endif 462 next 463 loop never 464 setsystem maxmove 2 465 ban commands allmoves 466 allow moves 1 captures 1 promotions 2 467 def N checkleap #0 #1 1 2 468 def B checkride #0 #1 1 1 469 def R checkride #0 #1 1 0 470 def Q fn B #0 #1 or fn R #0 #1 471 def K checkleap #0 #1 1 1 or checkleap #0 #1 1 0 472 def M fn N #0 #1 or fn R #0 #1 473 def A fn N #0 #1 or fn B #0 #1 474 def n checkleap #0 #1 1 2 475 def b checkride #0 #1 1 1 476 def r checkride #0 #1 1 0 477 def q fn b #0 #1 or fn r #0 #1 478 def k checkleap #0 #1 1 1 or checkleap #0 #1 1 0 479 def m fn n #0 #1 or fn r #0 #1 480 def a fn n #0 #1 or fn b #0 #1 481 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 482 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 483 sub capturep p 484 empty #p 485 return true 486 endsub 487 sub checks king 488 if not dest 489 return false 490 endif 491 my checks c 492 set checks () 493 if fn space dest dest #king 494 setelem checks dest space dest 495 endif 496 set c sub checkedthru #king origin 497 if #c 498 setelem checks #c space #c 499 elseif #epc 500 set c sub checkedthru #king #epc 501 if #c 502 setelem checks #c space #c 503 endif 504 endif 505 return var checks 506 endsub 507 sub checkmated king checks 508 local from piece to key legalmove piece nopawn 509 store 510 if isupper space #king 511 def friends onlyupper 512 def friend isupper #0 513 set attacked ATTACKEDBYB 514 else 515 def friends onlylower 516 def friend islower #0 517 set attacked ATTACKEDBYW 518 endif 519 set kingmoves fn KL #king 520 for to #kingmoves 521 if not fn friend space #to and onboard #to 522 move #king #to 523 set incheck fn var attacked #to 524 restore 525 if not #incheck 526 setlegal #king #to 527 endif 528 endif 529 next 530 if == count var checks 1 531 for (key enemy) var checks 532 set possible path #king #key 533 push possible #key 534 if == #key #ep 535 push possible cond isupper space #ep where #ep 0 -1 where #ep 0 1 536 endif 537 for (from piece) fn friends 538 if == #from #king 539 continue 540 endif 541 for to #possible 542 if fn #piece #from #to 543 move #from #to 544 set incheck fn var attacked #king 545 if not #incheck 546 setlegal #from #to 547 endif 548 endif 549 restore 550 next 551 next 552 next 553 endif 554 return cond count system legalmoves false true and checks 555 endsub 556 def PL array where #0 0 2 where #0 0 1 where #0 -1 1 where #0 1 1 557 def pL array where #0 0 -2 where #0 0 -1 where #0 -1 -1 where #0 1 -1 558 def NL leaps #0 1 2 559 def BL rays #0 1 1 560 def RL rays #0 1 0 561 def VL rays #0 1 1 562 def CL rays #0 1 0 563 def QL merge rays #0 1 0 rays #0 1 1 564 def KL merge leaps #0 1 0 leaps #0 1 1 565 def AL merge leaps #0 1 2 rays #0 1 1 566 def ML merge rays #0 1 0 leaps #0 1 2 567 def nL leaps #0 1 2 568 def bL rays #0 1 1 569 def rL rays #0 1 0 570 def vL rays #0 1 1 571 def cL rays #0 1 0 572 def qL merge rays #0 1 0 rays #0 1 1 573 def kL merge leaps #0 1 0 leaps #0 1 1 574 def aL merge leaps #0 1 2 rays #0 1 1 575 def mL merge rays #0 1 0 leaps #0 1 2 576 sub castlepos from to 577 local c RPOS RDEST xdir safe 578 verify flag #from 579 verify empty #to 580 if isupper space #king 581 def friend isupper #0 582 def friends onlyupper 583 set attacked ATTACKEDBYB 584 else 585 def friend islower #0 586 def friends onlylower 587 set attacked ATTACKEDBYW 588 endif 589 set xdir sign minus file #to file #from 590 verify checkaride #from #to #xdir 0 591 verify not fn var attacked #from 592 set c #to 593 do 594 set c where #c #xdir 0 595 if flag #c 596 break 597 endif 598 verify onboard #c 599 verify empty #c 600 loop 601 verify flag #c 602 set RPOS #c 603 store 604 for c path #from #to 605 move #from #c 606 set safe not fn var attacked #c 607 restore 608 verify #safe 609 next 610 move #from #to 611 set RDEST where #to neg #xdir 0 612 move #RPOS #RDEST 613 return true 614 endsub 615 sub stalemated king 616 local legalmove temp from piece to attacked ra 617 if isupper space #king 618 def friend isupper #0 619 def friends onlyupper 620 set attacked ATTACKEDBYB 621 set cspaces var wcastle 622 else 623 def friend islower #0 624 def friends onlylower 625 set attacked ATTACKEDBYW 626 set cspaces var bcastle 627 endif 628 store 629 set kingmoves fn KL #king 630 for to #kingmoves 631 if not fn friend space #to and onboard #to 632 move #king #to 633 set incheck fn var attacked #to 634 restore 635 if not #incheck 636 setlegal #king #to 637 endif 638 endif 639 next 640 for to var cspaces 641 if sub castlepos #king #to 642 set incheck fn var attacked #to 643 restore 644 if not #incheck 645 setlegal #king #to 646 endif 647 endif 648 next 649 restore 650 for (from piece) fn friends 651 if == #from #king 652 continue 653 endif 654 for to fn join #piece L #from 655 if fn #piece #from #to and not fn friend space #to and onboard #to 656 move #from #to 657 set incheck fn var attacked #king 658 if not #incheck 659 setlegal #from #to 660 endif 661 endif 662 restore 663 next 664 next 665 return cond count system legalmoves false true 666 endsub 667 def WPAWN match P what #0 1 -1 what #0 -1 -1 668 def BPAWN match p what #0 1 1 what #0 -1 1 669 def KNIGHT check what #0 1 2 check what #0 -1 2 check what #0 1 -2 check what #0 -1 -2 check what #0 2 1 check what #0 -2 1 check what #0 2 -1 check what #0 -2 -1 target #1 670 def WAZIR check what #0 0 -1 check what #0 -1 0 check what #0 0 1 check what #0 1 0 target #1 671 def FERZ check what #0 -1 -1 check what #0 -1 1 check what #0 1 -1 check what #0 1 1 target #1 672 def KING fn WAZIR #0 #1 or fn FERZ #0 #1 673 def ROOK check insight #0 0 -1 check insight #0 -1 0 check insight #0 0 1 check insight #0 1 0 target #1 674 def BISHOP check insight #0 -1 -1 check insight #0 -1 1 check insight #0 1 -1 check insight #0 1 1 target #1 675 def ATTACKEDBYB fn KING #0 k or fn BPAWN #0 or fn KNIGHT #0 (n a m) or fn ROOK #0 (r q m) or fn BISHOP #0 (b q a) 676 def ATTACKEDBYW fn KING #0 K or fn WPAWN #0 or fn KNIGHT #0 (N A M) or fn ROOK #0 (R Q M) or fn BISHOP #0 (B Q A) 677 sub P from to 678 local ydir 679 if == file #from file #to and not capture 680 set legal checkaleap #from #to 0 1 681 if var legal 682 set ep false 683 else 684 set legal checkaride #from #to 0 1 and <= distance #from #to #fps and or == rankname #from #wpr < #wpr 0 685 set ep #to 686 endif 687 set epc false 688 elseif capture or #ep 689 set legal checkaleap #from #to -1 1 or checkaleap #from #to 1 1 690 set epc false 691 if not capture and var legal 692 set legal > rank #to rank #ep and < rankname #to #bpr and == file #to file #ep 693 if var legal 694 capture #ep 695 set epc #ep 696 endif 697 endif 698 set ep false 699 endif 700 if != space #to moved and onboard where #to 0 #pzs 701 die "You may not promote a Pawn until it reaches the promotion zone." 702 endif 703 if not onboard where #to 0 1 704 if == P space #to 705 askpromote #wprom 706 elseif not match space #to var wprom 707 set np space #to 708 die "You may not promote your Pawn to a" #np 709 endif 710 endif 711 endsub 712 sub p from to 713 if == file #from file #to and not capture 714 set legal checkaleap #from #to 0 -1 715 if var legal 716 set ep false 717 else 718 set legal checkaride #from #to 0 -1 and <= distance #from #to #fps and or == rankname #from #bpr > #bpr lastrank 719 set ep #to 720 endif 721 set epc false 722 elseif capture or #ep 723 set legal checkaleap #from #to -1 -1 or checkaleap #from #to 1 -1 724 set epc false 725 if not capture and var legal 726 set legal < rank #to rank #ep and > rankname #to #wpr and == file #to file #ep 727 if var legal 728 capture #ep 729 set epc #ep 730 endif 731 endif 732 set ep false 733 endif 734 if != space #to moved and onboard where #to 0 neg #pzs 735 die You may not promote a Pawn until it reaches the promotion zone. 736 endif 737 if not onboard where #to 0 -1 738 if == p space #to 739 askpromote #bprom 740 elseif not match space #to var bprom 741 set np space #to 742 die You may not promote your Pawn to a #np 743 endif 744 endif 745 endsub 746 sub K from to 747 if match #to var wcastle and flag #from 748 set legal sub castle 749 else 750 set legal fn K #from #to 751 endif 752 set K #to 753 unsetflag e1 754 endsub 755 sub k from to 756 if match #to var bcastle and flag #from 757 set legal sub castle 758 else 759 set legal fn k #from #to 760 endif 761 set k #to 762 unsetflag e8 763 endsub 764 sub castle 765 local ATTACKED c RPOS RDEST xdir 766 if not flag #from 767 die A King may not castle after it moves. 768 endif 769 if capture 770 die A King may not castle to an occupied space. 771 endif 772 set xdir sign minus file #to file #from 773 if not checkaride #from #to #xdir 0 774 die A King may not castle across any occupied space. 775 endif 776 set c #to 777 do 778 set c where #c #xdir 0 779 if flag #c 780 break 781 elseif not onboard #c 782 die No piece was found to castle with. 783 elseif not empty #c 784 die The King cannot castle with the piece at #c 785 endif 786 loop 787 set RPOS #c 788 set ATTACKED ATTACKEDBYW unless isupper moved ATTACKEDBYB 789 if fn var ATTACKED #from 790 die A King may not castle out of check. 791 endif 792 for c path #from #to 793 if fn var ATTACKED #c 794 die A King may not castle through check. 795 endif 796 next 797 if == count var subargs 0 798 set RDEST where #to neg #xdir 0 799 else 800 set RDEST elem 0 subarg 801 endif 802 unsetflag #RPOS 803 move #RPOS #RDEST 804 return true 805 endsub 806 sub checkedthru king loc 807 my dir c 808 set c revealed #king #loc 809 verify fn space #c #c #king and not samecase space #king space #c and onboard #c and #c 810 return #c 811 endsub 812 def fn checkedfrom fn space #1 #0 and xor isupper space #0 isupper space #1 and not empty #1 813 sub P1 from to 814 if == file #from file #to 815 return not capture 816 elseif capture 817 return true 818 elseif == file #to file #ep and == rank #from rank #ep and #ep 819 capture #ep 820 return true 821 endif 822 return false 823 endsub 824 sub PP from to 825 if checkatwostep #from #to 0 1 0 1 or checkaleap #from #to 0 1 826 return empty #to 827 elseif not checkaleap #from #to 1 1 and not checkaleap #from #to -1 1 828 return false 829 elseif not empty #to 830 return true 831 elseif == file #to file #ep and == rank #from rank #ep and #ep 832 capture #ep 833 return true 834 endif 835 return false 836 endsub 837 sub pp from to 838 if checkatwostep #from #to 0 -1 0 -1 or checkaleap #from #to 0 -1 839 return empty #to 840 elseif not checkaleap #from #to 1 -1 and not checkaleap #from #to -1 -1 841 return false 842 elseif not empty #to 843 return true 844 elseif == file #to file #ep and == rank #from rank #ep and #ep 845 capture #ep 846 return true 847 endif 848 return false 849 endsub 850 endlib