Please report any bugs or errors to Fergus Duniho

33

BANNED INPUT: kr e8-g8 on turn 17:

There is a global ban on commands in user input, and no exception has been made for the kr command on the part of the turn indexed 1.

Go back and try again.

What is otherwise valid user input in Game Courier can be banned in a GAME Code program for the sake of better enforcing the rules. See "Restricting User Input" in the Game Courier Developer's Guide for details on how this is done.

If you believe that your input should not have been banned, contact Fergus Duniho or whoever programmed the rules for this game.

Edit Settings File
   0 echo Please report any bugs or errors to Fergus Duniho
   1 setflag a1 a8 h1 h8 e1 e8
   2 set kpos any lambda (findpiece #0 spaces) (k kr kb kn)
   3 set Kpos any lambda (findpiece #0 spaces) (K KR KB KN)
   4 set ep false
   5 set wpr 2
   6 set bpr 7
   7 set fps 2
   8 set pzs 1
   9 set wprom Q R B N
  10 set bprom q r b n
  11 set wcastle c1 g1
  12 set bcastle c8 g8
  13 alias rb q RB Q
  14 include fairychess
  15 setconst k King
  16 setconst K King
  17 def Cavalier_King sub uncheckedknightleap #0 #1 or == var movetype CHECK and checkleap #0 #1 1 2 or checkleap #0 #1 1 0 or checkleap #0 #1 1 1
  18 copyfn Eques_Rex-Range Cavalier_King-Range
  19 set Cavalier_King-Range "The Cavalier King may move as a King or a Knight. When moving as a Knight, it must have a path to its destination that is unchecked. This may start orthogonally and turn diagonally or vice versa. As long as one path is clear, the Knight leap is legal. If both paths have a checked space, then the Knight leap in that direction is illegal. This restriction on its ability to move as a Knight does not impair its ability to check an opponent's royal piece."
  20 setconst kn Cavalier_King
  21 setconst KN Cavalier_King
  22 def Pontiff sub uncheckedpath #0 #1 or == var movetype CHECK and checkride #0 #1 1 1 or checkleap #0 #1 1 0
  23 copyfn Dragon_Horse-Range Pontiff-Range
  24 set Pontiff-Desc "The Pontiff may move as a Bishop or as a King. When moving as a Bishop, it may not pass through check, though this doesn't hinder its ability to check the opponent's royal piece."
  25 setconst kb Pontiff
  26 setconst KB Pontiff
  27 def Dragon_King sub uncheckedpath #0 #1 or == var movetype CHECK and checkride #0 #1 1 0 or checkleap #0 #1 1 1
  28 set Dragon_King-Desc "The Dragon King may move as a Rook or as a King. When moving as a Rook, it may not pass through check, though this doesn't hinder its ability to check the opponent's royal piece."
  29 setconst kr Dragon_King
  30 setconst KR Dragon_King
  31 setconst rb Queen
  32 setconst RB Queen
  33 setconst rn Marshall
  34 setconst RN Marshall
  35 copyfn Cardinal Paladin
  36 copyfn Cardinal-Range Paladin-Range
  37 set Paladin-Desc var Cardinal-Range
  38 setconst bn Paladin
  39 setconst BN Paladin
  40 setconst r Rook
  41 setconst R Rook
  42 setconst b Bishop
  43 setconst B Bishop
  44 setconst n Knight
  45 setconst N Knight
  46 setconst p Black_Pawn
  47 setconst P White_Pawn
  48 set cap assoc Q 0 M 0 A 0 R 0 B 0 N 0 P 0 q 0 m 0 a 0 r 0 b 0 n 0 p 0
  49 sub postauto1
  50   if not isconst alias $moved
  51     print list "The Piece" alias $moved "is undefined."
  52     die
  53   elseif islower $moved
  54     die You may not move one of your opponent's pieces.
  55   endif
  56   set codename const alias $moved
  57   set name alias #codename
  58   if != alias $moved alias $named
  59     if not isconst alias $named
  60       print alias $moved
  61       die The piece $named is undefined.
  62     elseif islower $named
  63       die "You may not split one of your pieces into one of your opponent's pieces."
  64     elseif capture
  65       die "Fission must be to an empty space."
  66     endif
  67     set codename2 const alias $named
  68     set name2 alias #codename2
  69     if != 1 levenshtein alias $moved alias $named or <= strlen alias $moved strlen alias $named
  70       set errmsg str_replace "_" " " list "Your" #name "cannot split into a" #name2 "component."
  71       die #errmsg
  72     elseif not fn #codename2 $origin $dest and isfunc #codename2
  73       set errmsg list "You may not move a" #name2 "from" $origin "to" join $dest ".
" 74 set desc join #codename2 "-Desc" 75 set errmsg str_replace "_" " " join #errmsg str_replace "%s" #name2 var #desc 76 die #errmsg 77 endif 78 add $named $dest 79 set remainder realname str_replace alias $named "" alias $moved 80 add #remainder $origin 81 if sub fission-attacked $origin $dest 82 die "Fission is legal only for a piece that is not attacked." 83 endif 84 elseif isupper $old 85 if not match alias $moved R B N 86 set errmsg str_replace "_" " " list "Your" $old "may not initiate fusion with your" join #name "." 87 die #errmsg 88 elseif not match alias $old K R B N 89 set errmsg str_replace "_" " " list "You may not force fusion on your" join alias const alias $old "." 90 die #errmsg 91 elseif == alias $moved alias $old 92 die "You may not fuse two pieces of the same type." 93 elseif not fn #codename $origin $dest and isfunc #codename 94 set errmsg list "You may not move a" #name "from" $origin "to" join $dest ".
" 95 set desc join #name "-Desc" 96 set errmsg str_replace "_" " " join #errmsg str_replace "%s" #name var #desc 97 die #errmsg 98 endif 99 set compound join alias $moved alias $old 100 if not isconst #compound 101 set compound join alias $old alias $moved 102 endif 103 set compound realname #compound 104 add #compound $dest 105 elseif sub #codename $origin $dest and issub #codename 106 elseif fn #codename $origin $dest and isfunc #codename and not issub #codename 107 else 108 set errmsg list "You may not move a" #name "from" $origin "to" join $dest ".
" 109 set desc join #codename "-Desc" 110 set errmsg str_replace "_" " " join #errmsg str_replace "%s" #name var #desc 111 die #errmsg 112 endif 113 if != #codename White_Pawn 114 set ep false 115 if capture 116 set nopvc 0 117 else 118 inc nopvc 119 endif 120 endif 121 if match alias $named K KR KB KN 122 set Kpos $dest 123 endif 124 if sub checked var Kpos 125 die You may not move into check. 126 endif 127 unsetflag $origin $dest 128 set posvar join "w" join fencode boardflags 129 inc #posvar 130 if islower $old and capture 131 setelem cap $old + 1 elem $old #cap 132 endif 133 endsub 134 sub postauto2 135 if not isconst alias $moved 136 set errmsg list "The Piece" alias $moved "is undefined." 137 die #errmsg 138 elseif isupper $moved 139 die You may not move one of your opponent's pieces. 140 endif 141 set codename const alias $moved 142 set name alias #codename 143 if != alias $moved alias $named 144 if not isconst alias $named 145 print alias $moved 146 die The piece $named is undefined. 147 elseif isupper $named 148 die "You may not split one of your pieces into one of your opponent's pieces." 149 elseif capture 150 die "Fission must be to an empty space." 151 endif 152 set codename2 const alias $named 153 set name2 alias #codename2 154 if != 1 levenshtein alias $moved alias $named or <= strlen alias $moved strlen alias $named 155 set errmsg str_replace "_" " " list "Your" #name "cannot split into a" #name2 "component." 156 die #errmsg 157 elseif not fn #codename2 $origin $dest and isfunc #codename2 158 set errmsg list "You may not move a" #name2 "from" $origin "to" join $dest ".
" 159 set desc join #codename2 "-Desc" 160 set errmsg str_replace "_" " " join #errmsg str_replace "%s" #name2 var #desc 161 die #errmsg 162 endif 163 add $named $dest 164 set remainder realname str_replace alias $named "" alias $moved 165 add #remainder $origin 166 if sub fission-attacked $origin $dest 167 die "Fission is legal only for a piece that is not attacked." 168 endif 169 elseif islower $old 170 if not match alias $moved r b n 171 set errmsg str_replace "_" " " list "Your" $old "may not initiate fusion with your" join alias #codename "." 172 die #errmsg 173 elseif not match alias $old k r b n 174 set errmsg str_replace "_" " " list "You may not force fusion on your" const alias $old "." 175 die #errmsg 176 elseif == alias $moved alias $old 177 die "You may not fuse two pieces of the same type." 178 elseif not fn #codename $origin $dest and isfunc #codename 179 set errmsg list "You may not move a" #name "from" $origin "to" join $dest ".
" 180 set desc join #name "-Desc" 181 set errmsg str_replace "_" " " join #errmsg str_replace "%s" #name var #desc 182 die #errmsg 183 endif 184 set compound join alias $moved alias $old 185 if not isconst #compound 186 set compound join alias $old alias $moved 187 endif 188 set compound realname #compound 189 add #compound $dest 190 elseif sub #codename $origin $dest and issub #codename 191 elseif fn #codename $origin $dest and isfunc #codename and not issub #codename 192 else 193 set errmsg list "You may not move a" #name "from" $origin "to" join $dest ".
" 194 set desc join #codename "-Desc" 195 set errmsg str_replace "_" " " join #errmsg str_replace "%s" #name var #desc 196 die #errmsg 197 endif 198 if != #codename Black_Pawn 199 set ep false 200 if capture 201 set nopvc 0 202 else 203 inc nopvc 204 endif 205 endif 206 if match alias $named k kr kb kn 207 set kpos $dest 208 endif 209 if sub checked var kpos 210 die You may not move into check. 211 endif 212 unsetflag $origin $dest 213 set posvar join "b" join fencode boardflags 214 inc #posvar 215 if isupper $old and capture 216 setelem cap $old + 1 elem $old #cap 217 endif 218 endsub 219 moveindex 0 220 MOVE: P e2-e4 221 postauto1 222 moveindex 1 223 MOVE: p d7-d5 224 postauto2 225 moveindex 2 226 MOVE: P e4-d5 227 postauto1 228 moveindex 3 229 MOVE: rb d8-d5 230 postauto2 231 moveindex 4 232 MOVE: N b1-c3 233 postauto1 234 moveindex 5 235 MOVE: rb d5-d8 236 postauto2 237 moveindex 6 238 MOVE: RB d1-f3 239 postauto1 240 moveindex 7 241 MOVE: n b8-c6 242 postauto2 243 moveindex 8 244 MOVE: B f1-b5 245 postauto1 246 moveindex 9 247 MOVE: p a7-a6 248 postauto2 249 moveindex 10 250 MOVE: B b5-c6 251 postauto1 252 moveindex 11 253 MOVE: b c8-d7 254 postauto2 255 moveindex 12 256 MOVE: B c6-d7 257 postauto1 258 moveindex 13 259 MOVE: rb d8-d7 260 postauto2 261 moveindex 14 262 MOVE: RB f3-b7 263 postauto1 264 moveindex 15 265 MOVE: rb d7-d8 266 postauto2 267 moveindex 16 268 MOVE: B b7-c6 269 postauto1 270 moveindex 17 271 MOVE: r d8-d7 272 postauto2 273 moveindex 18 274 MOVE: B c6-d7 275 postauto1 276 moveindex 19 277 MOVE: k e8-d7 278 postauto2 279 moveindex 20 280 MOVE: N g1-f3 281 postauto1 282 moveindex 21 283 MOVE: n g8-f6 284 postauto2 285 moveindex 22 286 MOVE: N f3-e5 287 postauto1 288 moveindex 23 289 MOVE: k d7-e8 290 postauto2 291 moveindex 24 292 MOVE: N e5-c6 293 postauto1 294 moveindex 25 295 MOVE: p e7-e6 296 postauto2 297 moveindex 26 298 MOVE: R b7-b8 299 postauto1 300 moveindex 27 301 MOVE: r a8-b8 302 postauto2 303 moveindex 28 304 MOVE: N c6-b8 305 postauto1 306 moveindex 29 307 MOVE: b f8-e7 308 postauto2 309 moveindex 30 310 MOVE: N b8-a6 311 postauto1 312 moveindex 31 313 MOVE: r h8-e8 314 postauto2 315 moveindex 32 316 MOVE: P a2-a3 317 postauto1 318 moveindex 33 319 MOVE: kr e8-g8 320 postauto2 321 moveindex 34 322 MOVE: P b2-b4 323 postauto1 324 moveindex 35 325 MOVE: n f6-d7 326 postauto2 327 moveindex 36 328 MOVE: P d2-d4 329 postauto1 330 moveindex 37 331 MOVE: p e6-e5 332 postauto2 333 moveindex 38 334 MOVE: P d4-e5 335 postauto1 336 moveindex 39 337 MOVE: n d7-e5 338 postauto2 339 moveindex 40 340 MOVE: N c3-d5 341 postauto1 342 moveindex 41 343 MOVE: p c7-c6 344 postauto2 345 moveindex 42 346 MOVE: N d5-e7 347 postauto1 348 moveindex 43 349 MOVE: b d8-e7 350 postauto2 351 moveindex 44 352 MOVE: K e1-g1 353 postauto1 354 moveindex 45 355 MOVE: r g8-d8 356 postauto2 357 moveindex 46 358 MOVE: B c1-b2 359 postauto1 360 moveindex 47 361 MOVE: n e5-c4 362 postauto2 363 moveindex 48 364 MOVE: B b2-c3 365 postauto1 366 moveindex 49 367 MOVE: r d8-d5 368 postauto2 369 moveindex 50 370 MOVE: R f1-e1 371 postauto1 372 moveindex 51 373 MOVE: k g8-f8 374 postauto2 375 moveindex 52 376 MOVE: B c3-g7 377 postauto1 378 moveindex 53 379 MOVE: k f8-g7 380 postauto2 381 moveindex 54 382 MOVE: R e1-e7 383 postauto1 384 moveindex 55 385 MOVE: n c4-d2 386 postauto2 387 moveindex 56 388 MOVE: N a6-c7 389 postauto1 390 moveindex 57 391 MOVE: r d5-g5 392 postauto2 393 moveindex 58 394 MOVE: R e7-e3 395 postauto1 396 moveindex 59 397 MOVE: resign 398 postauto2 399 set posvar join "b" join fencode boardflags 400 if >= var #posvar 3 401 say Three Times Repetition! Drawn Game! 402 drawn 403 elseif sub fusion-stalemated var Kpos 404 if sub checked var Kpos 405 say Checkmate! Black has won! 406 won 407 else 408 say Stalemate! The game is drawn. 409 drawn 410 endif 411 elseif >= #nopvc 100 412 say Fifty Moves Without Moving a Pawn or Capturing! Game Drawn! 413 drawn 414 elseif sub checked var Kpos 415 say Check! 416 endif 417 setsystem capturedpieces var cap 418 end 419 420 lib fairychess 421 if flag use-chess-defaults 422 setconst k King 423 setconst K King 424 setconst q Queen 425 setconst Q Queen 426 setconst r Rook 427 setconst R Rook 428 setconst b Bishop 429 setconst B Bishop 430 setconst n Knight 431 setconst N Knight 432 setconst p Black_Pawn 433 setconst P White_Pawn 434 endif 435 if flag use-chess-defaults 436 set wpr 2 437 set bpr 7 438 set fps 2 439 set pzs 1 440 set wcastle c1 g1 441 set bcastle c8 g8 442 set wprom Q R B N 443 set bprom q r b n 444 set promotable p P 445 elseif not isset wpr 446 set message join "Set the wpr variable to the value of White's Pawn Rank. This is the single rank on which all of White's Pawns start. This would be 2 for Chess.
" var message 447 elseif not isset bpr 448 set message join "Set the bpr variable to the value of Black's Pawn Rank. This is the single rank on which all of Black's Pawns start. This would be 7 for Chess.
" var message 449 elseif not isset fps 450 set message join "Set the fps variable to the value of the maximum number of spaces a Pawn may move on its first move. This would be 2 in Chess.
" var message 451 elseif not isset pzs 452 set message join "Set the pzs variable to the value of the Promotion Zone Size. This is the number of ranks on the opposite side of the board on which Pawns may promote. This would be 1 for Chess.
" var message 453 elseif not isset wcastle 454 set message join "Set the wcastle variable to a space-separated list of the coordinates of the spaces the White King may move to when castling. This would be c1 g1 for Chess.
" var message 455 elseif not isset bcastle 456 set message join "Set the bcastle variable to a space-separated list of the coordinates of the spaces the Black King may move to when castling. This would be c8 g8 for Chess.
" var message 457 elseif not isset wprom 458 set message join "Set the wprom variable to the pieces that a White Pawn may promote to on reaching the Promotion Zone. White's pieces will normally be uppercase, and this would be Q R B N for Chess.
" var message 459 elseif not isset bprom 460 set message join "Set the bprom variable to the pieces that a Black Pawn may promote to on reaching the Promotion Zone. Black's pieces will normally be lowercase, and this would be q r b n for Chess.
" var message 461 endif 462 set ep false 463 setsystem maxmove 2 464 ban commands allmoves 465 allow moves 1 captures 1 promotions 2 466 set Aanca-Desc "The %s may move one space orthgonally, and so long as it is unblocked, it may continue its move in an outward diagonal direction." 467 def Aanca fn (checkride #0 #1 1 1 and empty #0) where #0 0 sign - rank #1 rank #0 #1 or fn (checkride #0 #1 1 1 and empty #0) where #0 sign - file #1 file #0 0 #1 or checkleap #0 #1 1 0 468 def Aanca-Range mergeall leaps #0 1 0 rays where #0 0 1 1 1 rays where #0 0 -1 1 1 rays where #0 1 0 1 1 rays where #0 -1 0 1 1 469 set Amazon-Desc "The %s may move in a straight line in any direction, as a Queen does, or it may leap the the opposite end of a 1x2 rectangle, as a Knight does." 470 def Amazon fn Bishop #0 #1 or fn Rook #0 #1 or fn Knight #0 #1 471 def Amazon-Range merge leaps # 1 2 merge rays #0 1 0 rays #0 1 1 472 set Bede-Desc "The %s may move along any diagonal line, as a Bishop does, or it may leap two spaces away in any orthogonal direction, as a Dabababah does." 473 def Bede checkride #0 #1 1 1 or checkleap #0 #1 0 2 474 def Bede-Range merge rays #0 1 1 leaps #0 0 2 475 def White_Berolina_Pawn remove var epc and checkleap #0 #1 1 0 and == #1 var epp or and checkride #0 #1 1 1 == rankname #0 var wpr or checkleap #0 #1 1 1 and empty #1 or and islower space #1 checkleap #0 #1 1 0 and <= distance #0 #1 var fps and > rank #1 rank #0 476 def Black_Berolina_Pawn remove var epc and checkleap #0 #1 1 0 and == #1 var epp or and checkride #0 #1 1 1 == rankname #0 var bpr or checkleap #0 #1 1 1 and empty #1 or and isupper space #1 checkleap #0 #1 1 0 and <= distance #0 #1 var fps and < rank #1 rank #0 477 def White_Berolina_Pawn-Range filter lambda (onboard #1) mergeall where #ori 0 1 values lambda (where #ori neg #1 #1) range 1 var fps values lambda (where #ori #1 #1) range 1 var fps =ori 478 def Black_Berolina_Pawn-Range filter lambda (onboard #1) mergeall where #ori 0 -1 values lambda (where #ori neg #1 neg #1) range 1 var fps values lambda (where #ori #1 neg #1) range 1 var fps =ori 479 set White_Berolina_Pawn-Desc "The %s may move one space diagonally forward without capturing, or it may move one space straight forward to capture. On its first move, it may move two spaces diagonally forward without capturing so long as it isn't blocked. If this move takes it next to an enemy %s that could have captured it if it had just moved one space, that %s may immediately capture it by en passant, moving to the space it passed over. On reaching the last rank, it may promote." 480 set Black_Berolina_Pawn-Desc var White_Berolina_Pawn-Desc 481 sub White_Berolina_Pawn from to 482 verify > rank #to rank #from 483 verify <= distance #to #from #fps 484 if capture 485 verify checkleap #from #to 1 0 486 set epp false 487 set epc false 488 elseif checkleap #from #to 1 0 and == #to #epp 489 capture #epc 490 set epp false 491 set epc false 492 elseif > distance #to #from 1 493 verify == rankname #from #wpr 494 verify checkride #from #to 1 1 495 set epp elem 0 path #from #to 496 set epc #to 497 else 498 verify checkleap #from #to 1 1 499 set epp false 500 set epc false 501 endif 502 if onboard where #to 0 #pzs 503 if != space #to $moved 504 set name alias const alias $moved 505 die "You may not promote a" #name "until it reaches the promotion zone." 506 endif 507 elseif onboard where #to 0 1 508 if == White_Berolina_Pawn const alias space #to and count var wprom 509 if not $answered and == mln $maxmln 510 push wprom space #to 511 askpromote #wprom 512 endif 513 elseif not match space #to var wprom and != White_Pawn const alias space #to 514 set name alias const alias $moved 515 set newname alias const alias space #to 516 set msg list "You may not promote your" #name "to a" join #newname ".
" 517 set msg str_replace "_" " " var msg 518 die #msg 519 endif 520 elseif count var wprom 521 if == White_Berolina_Pawn const alias space #to 522 if == count var wprom 1 523 set newpiece join list var wprom 524 set newmove join #newpiece "-dest" 525 add #newpiece $dest 526 appendmove #newmove 527 else 528 askpromote #wprom 529 endif 530 elseif not match space #to var wprom 531 set name alias const alias $moved 532 set newname alias const alias space #to 533 set msg list "You may not promote your" #name "to a" join #newname ".
" 534 set msg str_replace "_" " " var msg 535 die #msg 536 endif 537 else 538 set name alias const alias $moved 539 set msg list "You may not advance your" #name "to the last rank, because there is nothing you may promote it to." 540 set msg str_replace "_" " " var msg 541 die #msg 542 endif 543 set nopvc 0 544 return true 545 endsub 546 sub Black_Berolina_Pawn from to 547 verify < rank #to rank #from 548 verify <= distance #to #from #fps 549 if capture 550 verify checkleap #from #to 1 0 551 set epp false 552 set epc false 553 elseif checkleap #from #to 1 0 and == #to #epp 554 capture #epc 555 set epp false 556 set epc false 557 elseif > distance #to #from 1 558 verify == rankname #from #bpr 559 verify checkride #from #to 1 1 560 set epp elem 0 path #from #to 561 set epc #to 562 else 563 verify checkleap #from #to 1 1 564 set epp false 565 set epc false 566 endif 567 if onboard where #to 0 neg #pzs 568 if != space #to $moved 569 set name alias const alias $moved 570 die "You may not promote a" #name "until it reaches the promotion zone." 571 endif 572 elseif onboard where #to 0 -1 573 if == Black_Berolina_Pawn const alias space #to and count var bprom 574 if not $answered and == mln $maxmln 575 push bprom space #to 576 askpromote #bprom 577 endif 578 elseif not match space #to var bprom and != Black_Pawn const alias space #to 579 set name alias const alias $moved 580 set newname alias const alias space #to 581 set msg list "You may not promote your" #name "to a" join #newname ".
" 582 set msg str_replace "_" " " var msg 583 die #msg 584 endif 585 elseif count var bprom 586 if == Black_Berolina_Pawn const alias space #to 587 if == count var bprom 1 588 set newpiece join list var bprom 589 set newmove join #newpiece "-dest" 590 add #newpiece $dest 591 appendmove #newmove 592 else 593 askpromote #bprom 594 endif 595 elseif not match space #to var bprom 596 set name alias const alias $moved 597 set newname alias const alias space #to 598 set msg list "You may not promote your" #name "to a" join #newname ".
" 599 set msg str_replace "_" " " var msg 600 die #msg 601 endif 602 else 603 set name alias const alias $moved 604 set msg list "You may not advance your" #name "to the last rank, because there is nothing you may promote it to." 605 set msg str_replace "_" " " var msg 606 die #msg 607 endif 608 set nopvc 0 609 return true 610 endsub 611 def Bishop checkride #0 #1 1 1 612 def Bishop-Range rays #0 1 1 613 set Bishop-Desc "The %s may move diagonally any number of spaces until it reaches an occupied space." 614 def Cannon cond cond empty #0 capture (not empty #1) (checkhop #0 #1 0 1) (checkride #0 #1 0 1) and #1 615 def Cannon-Range rays #0 1 0 616 set Cannon-Desc "The %s moves any number of spaces orthogonally, as a Rook does, but it must hop over an intervening piece to capture." 617 def Camel checkleap #0 #1 1 3 618 def Camel-Range leaps #0 1 3 619 set Camel-Desc "The %s leaps to any space at the opposite corner of a 1x3 rectangle." 620 def Camelrider checkride #0 #1 1 3 621 def Camelrider-Range rays #0 1 3 622 set Camelrider-Desc "The %s may make any number of Camel moves in the same direction until it lands on an occupied space." 623 def Cardinal fn Bishop #0 #1 or fn Knight #0 #1 624 def Cardinal-Range merge leaps #0 1 2 rays #0 1 1 625 set Cardinal-Desc "The %s may move along diagonals as a Bishop or leap as a Knight." 626 def Centaur checkleap #0 #1 1 1 or checkleap #0 #1 1 0 or checkleap #0 #1 1 2 627 def Centaur-Range merge leaps #0 1 2 merge leaps #0 1 0 leaps #0 1 1 628 set Centaur-Desc "The %s may move to any adjacent space as a King or leap like a Knight." 629 def Champion fn Elephant #0 #1 or fn Dabbabah #0 #1 or fn Wazir #0 #1 630 def Champion-Range mergeall leaps #0 2 2 leaps #0 2 0 leaps #0 1 0 631 set Champion-Desc "The %s may leap one or two spaces orthogonally or two spaces diagonally." 632 def White_Charging_Knight cond < rank #0 rank #1 (checkleap #0 #1 1 2) (checkleap #0 #1 1 1 or checkleap #0 #1 1 0) 633 def White_Charging_Knight-Range mergeall leaps #0 1 2 leaps #0 1 1 leaps #0 1 0 634 set White_Charging_Knight-Desc "The %s may leap forward as a Knight or move one space sideways or backwards like a King." 635 def Black_Charging_Knight cond > rank #0 rank #1 (checkleap #0 #1 1 2) (checkleap #0 #1 1 1 or checkleap #0 #1 1 0) 636 def Black_Charging_Knight-Range mergeall leaps #0 1 2 leaps #0 1 1 leaps #0 1 0 637 set Black_Charging_Knight-Desc "The %s may leap forward as a Knight or move one space sideways or backwards like a King." 638 def White_Charging_Rook checkride #0 #1 1 0 and <= rank #0 rank #1 or checkaleap #0 #1 -1 -1 or checkaleap #0 #1 -1 0 or checkaleap #0 #1 -1 1 639 def White_Charging_Rook-Range mergeall ray #0 0 -1 ray #0 1 0 ray #0 0 1 where #0 -1 1 where #0 1 0 where #0 1 1 640 set White_Charging_Rook-Desc "The %s may move forward or sideways along its file or rank like a Rook, or it may move one space backwards in any direction like a King." 641 def Black_Charging_Rook checkride #0 #1 1 0 and >= rank #0 rank #1 or checkaleap #0 #1 -1 1 or checkaleap #0 #1 1 0 or checkaleap #0 #1 1 1 642 def Black_Charging_Rook-Range mergeall ray #0 0 -1 ray #0 -1 0 ray #0 0 1 where #0 -1 1 where #0 1 0 where #0 1 1 643 set Black_Charging_Rook-Desc "The %s may move forward or sideways along its file or rank like a Rook, or it may move one space backwards in any direction like a King." 644 def Chinese_Elephant checkpath #0 #1 1 1 1 1 645 def Chinese_Elephant-Range leaps #0 2 2 646 set Chinese_Elephant-Desc "The %s may move two spaces diagonally so long as the space in between is empty." 647 def White_Chinese_Elephant checkpath #0 #1 1 1 1 1 and < rank #1 + 1 / lastrank 2 648 def White_Chinese_Elephant-Range leaps #0 2 2 649 set White_Chinese_Elephant-Desc "The %s may move two spaces diagonally so long as the space in between is empty, but it is confined to the ranks on its own side of the board." 650 def Black_Chinese_Elephant checkpath #0 #1 1 1 1 1 and >= rank #1 + 1 / lastrank 2 651 def Black_Chinese_Elephant-Range leaps #0 2 2 652 set Black_Chinese_Elephant-Desc "The %s may move two spaces diagonally so long as the space in between is empty, but it is confined to the ranks on its own side of the board." 653 def Chinese_General checkride #0 #1 1 0 and == Chinese_General const alias cond empty #0 capture space #1 or checkleap #0 #1 0 1 and flag #1 654 def Chinese_General checkride #0 #1 1 0 and == Chinese_General const alias cond empty #0 capture space #1 or checkleap #0 #1 0 1 and flag #1 655 def Chinese_General == distance #0 #1 1 or == var movetype CHECK and checkride #0 #1 1 0 and flag #1 656 def Chinese_General-Range leaps #0 1 0 657 set Chinese_General-Desc "The %s may move one space orthogonally within the confines of the Palace, but it may not face the opponent's %s along an open file." 658 def Chinese_Guard checkleap #0 #1 1 1 and flag #1 659 def Chinese_Guard-Range leaps #0 1 1 660 set Chinese_Guard-Desc "The %s may move one space diagonally within the confines of the palace." 661 def White_Chinese_Pawn checkaleap #0 #1 -1 0 or checkaleap #0 #1 1 0 and >= rank #0 + 1 / lastrank 2 or checkaleap #0 #1 0 1 662 def Black_Chinese_Pawn checkaleap #0 #1 -1 0 or checkaleap #0 #1 1 0 and < rank #0 + 1 / lastrank 2 or checkaleap #0 #1 0 -1 663 def White_Chinese_Pawn-Range leaps #0 1 0 664 def Black_Chinese_Pawn-Range leaps #0 1 0 665 set White_Chinese_Pawn-Desc "The %s may move one space forward. Once it has reached the other side of the board, it may also move one space sideways." 666 set Black_Chinese_Pawn-Desc "The %s may move one space forward. Once it has reached the other side of the board, it may also move one space sideways." 667 def White_Colonel checkride #0 #1 1 0 or checkleap #0 #1 1 2 and >= rank #1 rank #0 or checkleap #0 #1 1 1 or checkleap #0 #1 1 0 668 def White_Colonel mergeall rays #0 1 0 leaps #0 1 2 leaps #0 1 1 669 set White_Colonel-Desc "The %s may move forward or sideways as a Rook, forward as a Knight, and one space in any direction as a King." 670 def Black_Colonel checkride #0 #1 1 0 or checkleap #0 #1 1 2 and <= rank #1 rank #0 or checkleap #0 #1 1 1 or checkleap #0 #1 1 0 671 def Black_Colonel mergeall rays #0 1 0 leaps #0 1 2 leaps #0 1 1 672 set Black_Colonel-Desc "The %s may move forward or sideways as a Rook, forward as a Knight, and one space in any direction as a King." 673 def Dabbabah checkleap #0 #1 0 2 674 def Dabbabah-Range leaps #0 0 2 675 set Dabbabah-Desc "The %s may leap two spaces vertically or horizontally." 676 def Dabbabahrider checkride #0 #1 0 2 677 def Dabbabahrider-Range rays #0 0 2 678 set Dabbabahrider-Desc "The %s may make any number of two space orthogonal leaps in the same direction until it reaches an occupied space." 679 def Dragon_Horse checkride #0 #1 1 1 or checkleap #0 #1 1 0 680 def Dragon_Horse-Range merge leaps #0 1 0 rays #0 1 1 681 set Dragon_Horse-Desc "The %s may move along diagonals as a Bishop or move one space orthogonally as a Wazir." 682 def Dragon_King checkride #0 #1 1 0 or checkleap #0 #1 1 1 683 def Dragon_King-Range merge leaps #0 1 1 rays #0 1 0 684 set Dragon_King-Desc "The %s may move along its rank or file as a Rook or one space diagonally as a Ferz." 685 def Elephant checkleap #0 #1 2 2 686 def Elephant-Range leaps #0 2 2 687 set Elephant-Desc "The %s may leap two spaces in any diagonal direction." 688 def Elephantrider checkride #0 #1 2 2 689 def Elephantrider-Range rays #0 2 2 690 set Elephantrider-Desc "The %s may make a series of two-space diagonal leaps in the same direction. Each leap but the last must be to an empty space, though a leap may take it over an intervening piece." 691 def Eques_Rex checkleap #0 #1 1 1 or checkleap #0 #1 1 0 or checkleap #0 #1 1 2 692 def Eques_Rex-Range merge leaps #0 1 2 merge leaps #0 1 0 leaps #0 1 1 693 set Eques_Rex-Desc "The %s may move to any adjacent space as a King or leap like a Knight." 694 def Fad checkleap #0 #1 1 1 or checkleap #0 #1 2 2 or checkleap #0 #1 2 0 695 def Fad-Range mergeall leaps #0 1 1 leaps #0 2 2 leaps #0 2 0 696 set Fad-Desc "The %s may move one space diagonally, or it may leap two spaces diagonally or orthogonally." 697 def Ferz checkleap #0 #1 1 1 698 def Ferz-Range leaps #0 1 1 699 set Ferz-Desc "The %s may move one space diagonally." 700 def Fibnif checkleap #0 #1 1 2 or checkleap #0 #1 1 1 and == 1 abs - file #0 file #1 701 def Fibnif-Range merge leaps #0 1 2 leaps #0 1 1 702 set Fibnif-Desc "The %s may move one space diagonally or leap as a Knight to any space that is one file and two ranks away." 703 def Giraffe checkleap #0 #1 1 4 704 def Giraffe-Range leaps #0 1 4 705 set Giraffe-Desc "The %s may leap to any space that is one file and four ranks or one rank and four files away." 706 def White_Gold_General checkaleap #0 #1 1 1 or checkaleap #0 #1 -1 1 or checkleap #0 #1 0 1 707 def White_Gold_General-Range mergeall leaps #0 1 0 where #0 1 1 where #0 -1 1 708 set White_Gold_General-Desc "The %s may move one space in any orthgonal direction or one space diagonally forward." 709 def Black_Gold_General checkaleap #0 #1 1 -1 or checkaleap #0 #1 -1 -1 or checkleap #0 #1 0 1 710 def Black_Gold_General-Range mergeall leaps #0 1 0 where #0 1 -1 where #0 -1 -1 711 set Black_Gold_General-Desc "The %s may move one space in any orthgonal direction or one space diagonally forward." 712 def Grasshopper checkgrasshop #0 #1 1 1 or checkgrasshop #0 #1 1 0 713 def Grasshopper-Range merge rays #0 1 0 rays #0 1 1 714 set "The %s moves any number of spaces orthogonally or diagonally like a Queen except that it must hop over exactly one piece, and it must end its move immediately after the piece it hopped over." 715 def Griffon fn (checkride #0 #1 1 0 and empty #0) where #0 sign - file #1 file #0 sign - rank #1 rank #0 #1 and != file #1 file #0 and != rank #1 rank #0 or checkleap #0 #1 1 1 716 def Griffon-Range mergeall leaps #0 1 1 rays where #0 1 1 1 0 rays where #0 1 -1 1 0 rays where #0 -1 -1 1 0 rays where #0 -1 1 1 0 717 set Griffon-Desc "The %s may move one space diagonally, and it may continue its move by moving as a Rook in an outward orthogonal direction. It may not pass over other pieces." 718 def King checkleap #0 #1 1 1 or checkleap #0 #1 1 0 719 def King-Range merge leaps #0 1 0 leaps #0 1 1 720 set King-Desc "The %s leaps one space in any direction. It may castle with a Rook on its first move so long as it is not in check, there is nothing in between it and the Rook, it doesn't pass through check while castling, and the Rook hasn't moved. In castling, it moves two spaces toward the Rook, and the Rook moves to the space the %s passed over." 721 sub King from to 722 if not fn King #from #to 723 verify sub castle #from #to and match #to var cond isupper space #to wcastle bcastle 724 endif 725 if isupper space #to 726 set Kpos #to 727 else 728 set kpos #to 729 endif 730 return true 731 endsub 732 def Knight checkleap #0 #1 1 2 733 def Knight-Range leaps #0 1 2 734 set Knight-Desc "The %s may leap to any space that is one rank and two files away or two ranks and one file away." 735 def Korean_Elephant checkpath #0 #1 1 0 1 1 1 1 736 def Korean_Elephant-Range leaps #0 2 3 737 set "The %s may move one space orthogonally, followed by two more spaces in the same outward diagonal direction. It must complete every part of its move, and it may not pass over an occupied space." 738 def White_Lance checkaride #0 #1 0 1 739 def White_Lance-Range ray #0 0 1 740 set "The %s may move forward in its file as a Rook." 741 def Black_Lance checkaride #0 #1 0 -1 742 def Black_Lance-Range ray #0 0 -1 743 set "The %s may move forward in its file as a Rook." 744 def Leo fn Vao #0 #1 or fn Cannon #0 #1 745 def Leo-Range merge rays #0 1 0 rays #0 1 1 746 set Leo-Desc "The %s may move any number of spaces diagonally or orthogonally, as a Queen does, but it must hop over one intervening piece when it captures." 747 def Mao checktwostep #0 #1 0 1 1 1 748 def Mao-Range leaps #0 1 2 749 set Mao-Desc "The %s moves one space orthogonally, followed by one more space in an outward diagonal direction. It must complete both parts of its move, and it may not pass over an occupied space. It can reach the same spaces as a Knight except that it can be blocked on the first step of its two-space move." 750 def Marshall fn Knight #0 #1 or fn Rook #0 #1 751 def Marshall-Range merge rays #0 1 0 leaps #0 1 2 752 set Marshall-Desc "The %s moves orthogonally as a Rook or leaps as a Knight." 753 def Moa checktwostep #0 #1 1 1 0 1 754 def Moa-Range leaps #0 1 2 755 set Moa-Desc "The %s moves one space diagonally, followed by one more space in an outward orthogonal direction. It must complete both parts of its move, and it may not pass over an occupied space. It can reach the same spaces as a Knight except that it can be blocked on the first step of its two-space move." 756 def Murray_Lion checkleap #0 #1 1 0 or checkleap #0 #1 1 1 and cond empty #0 capture (not empty #1) or checkleap #0 #1 2 2 or checkleap #0 #1 0 2 757 def Murray_Lion-Range merge merge leaps #0 2 0 leaps #0 2 2 merge leaps #0 1 0 leaps #0 1 1 758 set Murray_Lion-Desc "The %s may leap two spaces in any diagonal or orthogonal direction, and it may capture (but not otherwise move) one space in any direction." 759 def Nightrider checkride #0 #1 1 2 760 def Nightrider-Range rays #0 1 2 761 set Nightrider-Desc "The %s may leap as a Knight any number of times in the same direction. While each Knight leap may take it over other pieces, each leap but the last must be to an empty space." 762 set White_Pawn-Desc "The %s may move one space straight forward without capturing, or it may move one space diagonally forward to capture. On its first move, it may move two spaces forward without capturing so long as it isn't blocked. If this move takes it over a space an enemy %s could have captured it on if it had moved there, that %s may immediately capture it by en passant by moving to that space. On reaching the last rank, it must promote to any other piece except the King." 763 set Black_Pawn-Desc var White_Pawn-Desc 764 def White_Pawn remove var ep and < rankname #1 var bpr and < rankname var ep rankname #1 and == filename var ep filename #1 and checkleap #0 #1 1 1 and var ep or and checkride #0 #1 0 1 == rankname #0 var wpr or checkleap #0 #1 0 1 and empty #1 and != var movetype CHECK or and not empty #1 checkleap #0 #1 1 1 and any onboard where #1 0 1 == var movetype CHECK count var wprom and <= distance #0 #1 var fps and > rank #1 rank #0 765 def Black_Pawn remove var ep and > rankname #1 var wpr and > rankname var ep rankname #1 and == filename var ep filename #1 and checkleap #0 #1 1 1 and var ep or and checkride #0 #1 0 1 == rankname #0 var bpr or checkleap #0 #1 0 1 and empty #1 and != var movetype CHECK or and not empty #1 checkleap #0 #1 1 1 and any count var bprom onboard where #1 0 -1 == var movetype CHECK and <= distance #0 #1 var fps and < rank #1 rank #0 766 def White_Pawn-Range filter lambda (onboard #1) mergeall where #ori -1 1 where #ori 1 1 values lambda (where #ori 0 #1) range 1 var fps =ori 767 def Black_Pawn-Range 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 768 def White_Pawn-Promote var wprom 769 def Black_Pawn-Promote var bprom 770 sub White_Pawn from to 771 my newpiece 772 my newmove 773 my prom 774 verify > rank #to rank #from 775 verify <= distance #to #from #fps 776 if capture 777 verify checkleap #from #to 1 1 778 set ep false 779 elseif checkleap #from #to 1 1 and #ep 780 verify == filename var ep filename #to 781 verify < rankname var ep rankname #to 782 verify < rankname #to var bpr 783 capture #ep 784 set ep false 785 elseif > distance #to #from 1 786 verify == rankname #from #wpr 787 verify checkride #from #to 0 1 788 set ep #to 789 else 790 verify checkleap #from #to 0 1 791 set ep false 792 endif 793 set prom fn White_Pawn-Promote #to 794 if onboard where #to 0 #pzs 795 if != space #to $moved 796 set name alias const alias $moved 797 die "You may not promote a" #name "until it reaches the promotion zone." 798 endif 799 elseif onboard where #to 0 1 800 if == White_Pawn const alias space #to and count var prom 801 if not $answered and == mln $maxmln and not strstr thismove chr 59 802 if not match alias space #to var prom 803 push prom space #to 804 endif 805 askpromote #prom 806 endif 807 elseif not match space #to var prom and != White_Pawn const alias space #to 808 set name alias const alias $moved 809 set newname alias const alias space #to 810 set msg list "You may not promote your" #name "to a" join #newname ".
" 811 set msg str_replace "_" " " var msg 812 die #msg 813 endif 814 elseif count var prom 815 if == White_Pawn const alias space #to 816 if == count var prom 1 817 set newpiece alias list var prom 818 set pieceid realname #newpiece 819 set newmove join #newpiece "-dest" 820 add #pieceid $dest 821 appendmove #newmove 822 else 823 askpromote #prom 824 endif 825 elseif not match alias space #to var prom 826 set name alias const alias $moved 827 set newname alias const alias space #to 828 set msg list "You may not promote your" #name "to a" join #newname ".
" 829 set msg str_replace "_" " " var msg 830 die #msg 831 endif 832 else 833 set name alias const alias $moved 834 set msg list "You may not advance your" #name "to the last rank, because there is nothing you may promote it to." 835 set msg str_replace "_" " " var msg 836 die #msg 837 endif 838 set nopvc 0 839 return true 840 endsub 841 sub Black_Pawn from to 842 my newpiece, pieceid 843 my newmove 844 my prom 845 verify < rank #to rank #from 846 verify <= distance #to #from #fps 847 if capture 848 verify checkleap #from #to 1 1 849 set ep false 850 elseif checkleap #from #to 1 1 and #ep 851 verify == filename var ep filename #to 852 verify > rankname var ep rankname #to 853 verify > rankname #to var wpr 854 capture #ep 855 set ep false 856 elseif > distance #to #from 1 857 verify == rankname #from #bpr 858 verify checkride #from #to 0 1 859 set ep #to 860 else 861 verify checkleap #from #to 0 1 862 set ep false 863 endif 864 set prom fn Black_Pawn-Promote #to 865 if onboard where #to 0 neg #pzs 866 if != space #to $moved 867 set name alias const alias $moved 868 die "You may not promote a" #name "until it reaches the promotion zone." 869 endif 870 elseif onboard where #to 0 -1 871 if == Black_Pawn const alias space #to and count var prom 872 if not $answered and == mln $maxmln and not strstr thismove chr 59 873 push prom space #to 874 askpromote #prom 875 endif 876 elseif not match space #to var prom and != Black_Pawn const alias space #to 877 set name alias const alias $moved 878 set newname alias const alias space #to 879 set msg list "You may not promote your" #name "to a" join #newname ".
" 880 set msg str_replace "_" " " var msg 881 die #msg 882 endif 883 elseif count var prom 884 if == Black_Pawn const alias space #to 885 if == count var prom 1 886 set newpiece alias list var prom 887 set newmove join #newpiece "-dest" 888 set pieceid realname var newpiece 889 add #pieceid $dest 890 appendmove #newmove 891 else 892 askpromote #prom 893 endif 894 elseif not match alias space #to var prom 895 set name alias const alias $moved 896 set newname alias const alias space #to 897 set msg list "You may not promote your" #name "to a" join #newname ".
" 898 set msg str_replace "_" " " var msg 899 die #msg 900 endif 901 else 902 set name alias const alias $moved 903 set msg list "You may not advance your" #name "to the last rank, because there is nothing you may promote it to." 904 set msg str_replace "_" " " var msg 905 die #msg 906 endif 907 set nopvc 0 908 return true 909 endsub 910 set White_Quick_Pawn-Desc "The %s may move one or two spaces straight forward without capturing, or it may move one space diagonally forward to capture. If its two-space move takes it over a space an enemy %s could have captured it on if it had moved there, that %s may immediately capture it by en passant by moving to that space. On reaching the last rank, it must promote to any other piece except the King." 911 set Black_Quick_Pawn-Desc var White_Quick_Pawn-Desc 912 def White_Quick_Pawn remove var ep and < rankname #1 rankname var epf and < rankname var ep rankname #1 and == filename var ep filename #1 and checkleap #0 #1 1 1 and var ep or checkride #0 #1 0 1 and empty #1 and != var movetype CHECK or and or not empty #1 == var movetype CHECK checkleap #0 #1 1 1 and any onboard where #1 0 1 == var movetype CHECK count var wprom and <= distance #0 #1 var fps and > rank #1 rank #0 913 def Black_Quick_Pawn remove var ep and > rankname #1 rankname var epf and > rankname var ep rankname #1 and == filename var ep filename #1 and checkleap #0 #1 1 1 and var ep or checkride #0 #1 0 1 and empty #1 and != var movetype CHECK or and or not empty #1 == var movetype CHECK checkleap #0 #1 1 1 and any count var bprom onboard where #1 0 -1 == var movetype CHECK and <= distance #0 #1 var fps and < rank #1 rank #0 914 def White_Quick_Pawn-Range filter lambda (onboard #1) mergeall where #ori -1 1 where #ori 1 1 values lambda (where #ori 0 #1) range 1 var fps =ori 915 def Black_Quick_Pawn-Range 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 916 def White_Quick_Pawn-Promote var wprom 917 def Black_Quick_Pawn-Promote var bprom 918 sub White_Quick_Pawn from to 919 my newpiece 920 my newmove 921 my prom 922 verify > rank #to rank #from 923 verify <= distance #to #from #fps 924 if capture 925 verify checkleap #from #to 1 1 926 set epf false 927 set ep false 928 elseif checkleap #from #to 1 1 and #ep 929 verify == filename var ep filename #to 930 verify < rankname var ep rankname #to 931 verify < rankname #to rankname var epf 932 capture #ep 933 set epf false 934 set ep false 935 elseif > distance #to #from 1 936 verify checkride #from #to 0 1 937 set epf #from 938 set ep #to 939 else 940 verify checkleap #from #to 0 1 941 set epf false 942 set ep false 943 endif 944 set prom fn White_Quick_Pawn-Promote #to 945 if onboard where #to 0 #pzs 946 if != space #to $moved 947 set name alias const alias $moved 948 die "You may not promote a" #name "from" $moved "to" {space #to} "until it reaches the promotion zone." 949 endif 950 elseif onboard where #to 0 1 951 if == White_Quick_Pawn const alias space #to and count var prom 952 if not $answered and == mln $maxmln and not strstr thismove chr 59 953 if not match alias space #to var prom 954 push prom space #to 955 endif 956 askpromote #prom 957 endif 958 elseif not match space #to var prom and != White_Quick_Pawn const alias space #to 959 set name alias const alias $moved 960 set newname alias const alias space #to 961 set msg list "You may not promote your" #name "to a" join #newname ".
" 962 set msg str_replace "_" " " var msg 963 die #msg 964 endif 965 elseif count var prom 966 if == White_Quick_Pawn const alias space #to 967 if == count var prom 1 968 set newpiece alias list var prom 969 set pieceid realname #newpiece 970 set newmove join #newpiece "-dest" 971 add #pieceid $dest 972 appendmove #newmove 973 else 974 askpromote #prom 975 endif 976 elseif not match alias space #to var prom 977 set name alias const alias $moved 978 set newname alias const alias space #to 979 set msg list "You may not promote your" #name "to a" join #newname ".
" 980 set msg str_replace "_" " " var msg 981 die #msg 982 endif 983 else 984 set name alias const alias $moved 985 set msg list "You may not advance your" #name "to the last rank, because there is nothing you may promote it to." 986 set msg str_replace "_" " " var msg 987 die #msg 988 endif 989 set nopvc 0 990 return true 991 endsub 992 sub Black_Quick_Pawn from to 993 my newpiece, pieceid 994 my newmove 995 my prom 996 verify < rank #to rank #from 997 verify <= distance #to #from #fps 998 if capture 999 verify checkleap #from #to 1 1 1000 set ep false 1001 set epf false 1002 elseif checkleap #from #to 1 1 and #ep 1003 verify == filename var ep filename #to 1004 verify > rankname var ep rankname #to 1005 verify > rankname #to rankname var epf 1006 capture #ep 1007 set ep false 1008 set epf false 1009 elseif > distance #to #from 1 1010 verify checkride #from #to 0 1 1011 set ep #to 1012 set epf #from 1013 else 1014 verify checkleap #from #to 0 1 1015 set ep false 1016 set epf false 1017 endif 1018 set prom fn Black_Quick_Pawn-Promote #to 1019 if onboard where #to 0 neg #pzs 1020 if != space #to $moved 1021 set name alias const alias $moved 1022 die "You may not promote a" #name "until it reaches the promotion zone." 1023 endif 1024 elseif onboard where #to 0 -1 1025 if == Black_Quick_Pawn const alias space #to and count var prom 1026 if not $answered and == mln $maxmln and not strstr thismove chr 59 1027 push prom space #to 1028 askpromote #prom 1029 endif 1030 elseif not match space #to var prom and != Black_Quick_Pawn const alias space #to 1031 set name alias const alias $moved 1032 set newname alias const alias space #to 1033 set msg list "You may not promote your" #name "to a" join #newname ".
" 1034 set msg str_replace "_" " " var msg 1035 die #msg 1036 endif 1037 elseif count var prom 1038 if == Black_Quick_Pawn const alias space #to 1039 if == count var prom 1 1040 set newpiece alias list var prom 1041 set newmove join #newpiece "-dest" 1042 set pieceid realname var newpiece 1043 add #pieceid $dest 1044 appendmove #newmove 1045 else 1046 askpromote #prom 1047 endif 1048 elseif not match alias space #to var prom 1049 set name alias const alias $moved 1050 set newname alias const alias space #to 1051 set msg list "You may not promote your" #name "to a" join #newname ".
" 1052 set msg str_replace "_" " " var msg 1053 die #msg 1054 endif 1055 else 1056 set name alias const alias $moved 1057 set msg list "You may not advance your" #name "to the last rank, because there is nothing you may promote it to." 1058 set msg str_replace "_" " " var msg 1059 die #msg 1060 endif 1061 set nopvc 0 1062 return true 1063 endsub 1064 def Queen fn Bishop #0 #1 or fn Rook #0 #1 1065 def Queen-Range merge rays #0 1 0 rays #0 1 1 1066 set Queen-Desc "The %s may move as a Rook or a Bishop." 1067 def Rhino windingride #0 #1 1 0 1 1 or windingride #0 #1 0 1 1 1 1068 def Rhino-Range merge eval (windingrays #0 1 0 1 1) windingrays #0 0 1 1 1 1069 set Rhino-Desc "The %s moves along a winding path that alternates between the same one-space orthogonal move and the same one-space diagonal move both in the same general direction." 1070 def Rook checkride #0 #1 1 0 1071 def Rook-Range rays #0 1 0 1072 set Rook-Desc "The %s may move any number of spaces in any vertical or horizontal direction until it reaches an occupied space." 1073 def Short_Rook checkride #0 #1 1 0 and <= distance #0 #1 4 1074 def Short_Rook-Range merge merge leaps #0 1 0 leaps #0 2 0 merge leaps #0 3 0 leaps #0 4 0 1075 set "The %s may move up to four spaces along its rank or file as a Rook." 1076 def White_Shogi_Knight checkaleap #0 #1 1 2 or checkaleap #0 #1 -1 2 1077 def White_Shogi_Knight-Range array where #0 1 2 where #0 -1 2 1078 set White_Shogi_Knight-Desc "The %s may leap to either space that is two ranks ahead and one file to the side." 1079 def Black_Shogi_Knight checkaleap #0 #1 1 -2 or checkaleap #0 #1 -1 -2 1080 def Black_Shogi_Knight-Range array where #0 1 -2 where #0 -1 -2 1081 set Black_Shogi_Knight-Desc "The %s may leap to either space that is two ranks ahead and one file to the side." 1082 def White_Shogi_Pawn checkaleap #0 #1 0 1 1083 def White_Shogi_Pawn-Range array where #0 0 1 1084 set White_Shogi_Pawn-Desc "The %s map move one space forward in the same file." 1085 def Black_Shogi_Pawn checkaleap #0 #1 0 -1 1086 def Black_Shogi_Pawn-Range array where #0 0 -1 1087 set Black_Shogi_Pawn-Desc "The %s map move one space forward in the same file." 1088 def White_Silver_General checkaleap #0 #1 0 1 or checkleap #0 #1 1 1 1089 def White_Silver_General-Range mergeall leaps #0 1 1 where #0 0 1 1090 set White_Silver_General-Desc "The %s may move one space in any diagonal direction or one space vertically foward." 1091 def Black_Silver_General checkaleap #0 #1 0 -1 or checkleap #0 #1 1 1 1092 def Black_Silver_General-Range mergeall leaps #0 1 1 where #0 0 -1 1093 set Black_Silver_General-Desc "The %s may move one space in any diagonal direction or one space vertically foward." 1094 def Squirrel fn Elephant #0 #1 or fn Dabbabah #0 #1 or fn Knight #0 #1 1095 def Squirrel-Range mergeall leaps #0 2 2 leaps #0 2 0 leaps #0 1 2 1096 set Squirrel-Desc "The %s may leap any non-adjacent space that is no more than two spaces away." 1097 def Spider fn Dabbabah #0 #1 or fn Elephant #0 #1 1098 def Spider-Range merge leaps #0 2 2 leaps #0 0 2 1099 set Spider-Desc "The %s may leap to any space that is two spaces away orthogonally or diagonally." 1100 def Spider-rider fn Dabbabahrider #0 #1 or fn Elephantrider #0 #1 1101 def Spider-rider-Range merge rays #0 2 2 rays #0 0 2 1102 set Spider-rider-Desc "The %s may make any number of two-space leaps in a single orthogonal or diagonal direction. While each leap may take it over an occupied space, each leap but the last must be to an empty space." 1103 def Squire checktwostep #0 #1 0 1 1 1 or checktwostep #0 #1 1 1 0 1 1104 def Squire-Range leaps #0 1 2 1105 set Squire-Desc "The %s may move one space orthogonally, followed by one more space in an outward diagonal direction, or it may move one space diagonally, followed by one more space in an outward orthogonal direction. It must complete both parts of its move, and it may not pass over an occupied space. It can reach the same spaces as a Knight except that it can be blocked on the first step of its two-space move." 1106 def Unicorn fn Nightrider #0 #1 or fn Bishop #0 #1 1107 def Unicorn-Range merge rays #0 1 2 rays #0 1 1 1108 set Unicorn-Desc "The %s may make consecutive Knight moves in the same direction, as a Nightrider does, or it may move diagonally as a Bishop." 1109 def Vao cond cond empty #0 capture (not empty #1) (checkhop #0 #1 1 1) (checkride #0 #1 1 1) and #1 1110 def Vao-Range rays #0 1 1 1111 set Vao-Desc "The %s may move diagonally as a Bishop, but it must hop over exactly one intervening piece when it captures." 1112 def Wazir checkleap #0 #1 1 0 1113 def Wazir-Range leaps #0 1 0 1114 set Wazir-Desc "The %s may move one space horizontally or vertically." 1115 def Wizard fn Ferz #0 #1 or fn Camel #0 #1 1116 def Wizard-Range merge leaps #0 1 1 leaps #0 1 3 1117 set Wizard-Desc "The %s may move one space diagonally, or it may leap to a space three ranks and one file or three files and one rank away, as a Camel does." 1118 def Woody_Rook checkleap #0 #1 0 2 or checkleap #0 #1 0 1 1119 def Woody_Rook-Range merge leaps #0 0 1 leaps #0 0 2 1120 set Woody_Rook-Desc "The %s may leap one or two spaces orthogonally. It may pass over another piece when moving two spaces." 1121 def Zebra checkleap #0 #1 2 3 1122 def Zebra-Range leaps #0 2 3 1123 set Zebra-Desc "The %s may leap to any space that is 2 ranks and 3 files or 2 files and 3 ranks away." 1124 def Elephant_Ferz fn Ferz #0 #1 or fn Elephant #0 #1 1125 def Elephant_Ferz-Range merge leaps #0 2 2 leaps #0 1 1 1126 set Elephant_Ferz-Desc "The %s may leap one or two spaces diagonally. It may pass over another piece when moving two spaces." 1127 def Elephant_Wazir fn Wazir #0 #1 or fn Elephant #0 #1 1128 def Elephant_Wazir-Range merge leaps #0 2 2 leaps #0 1 0 1129 set Elephant_Wazir-Desc "The %s may move one space orthogonally, as a Wazir, or leap two spaces diagonally, as an Elephant." 1130 def Kylin fn Ferz #0 #1 or fn Dabbabah #0 #1 1131 def Kylin-Range mergeall leaps #0 1 1 leaps #0 2 0 1132 set Kylin-Desc "The %s may move one space diagonally, or it may leap 2 spaces orthogonally, passing over any pieces in the way." 1133 def Half_Duck fn Ferz #0 #1 or fn Dabbabah #0 #1 or checkleap #0 #1 3 0 1134 def Half_Duck-Range mergeall leaps #0 1 1 leaps #0 2 0 leaps #0 3 0 1135 set Half_Duck-Desc "The %s may move one space diagonally, or it may leap 2 or 3 spaces orthogonally, passing over any pieces in the way." 1136 def Knight_Wazir fn Knight #0 #1 or fn Wazir #0 #1 1137 def Knight_Wazir-Range merge leaps #0 1 2 leaps #0 1 0 1138 set Knight_Wazir-Desc "The %s may move one space orthogonally, as a Wazir, or it may leap as a Knight to any space one file and two ranks or two files and one rank away." 1139 def Frog fn Ferz #0 #1 or checkleap #0 #1 3 0 1140 def Frog-Range merge leaps #0 1 1 leaps #0 3 0 1141 set Frog-Desc "The %s may move one space diagonally or directly leap 3 spaces orthogonally." 1142 def Buffalo fn Knight #0 #1 or fn Camel #0 #1 or fn Zebra #0 #1 1143 def Buffalo-Range mergeall leaps #0 1 2 leaps #0 1 3 leaps #0 2 3 1144 set Buffalo-Desc "The %s Buffalo may leap (1, 2) as a Knight, (1, 3) as a Camel, or (2, 3) as a Zebra." 1145 def @ false 1146 sub attacked start finish 1147 my from piece actual 1148 local movetype 1149 set movetype MOVE 1150 if empty #start 1151 set actual true 1152 move #finish #start 1153 add $old #finish 1154 endif 1155 if isupper space #start 1156 def enemies onlylower 1157 else 1158 def enemies onlyupper 1159 endif 1160 for (from piece) fn enemies 1161 if fn const alias #piece #from #to 1162 if #actual 1163 move #start #finish 1164 endif 1165 return #from 1166 endif 1167 next 1168 if #actual 1169 move #start #finish 1170 endif 1171 return false 1172 endsub 1173 sub fission-attacked start finish 1174 my from piece p1 p2 1175 local movetype 1176 set p1 space #start 1177 set p2 space #finish 1178 set movetype CHECK 1179 if isupper #p1 1180 def enemies onlylower 1181 else 1182 def enemies onlyupper 1183 endif 1184 empty #finish 1185 for (from piece) fn enemies 1186 if fn const alias #piece #from #start 1187 add #p2 #finish 1188 return #from 1189 endif 1190 next 1191 add #p2 #finish 1192 return false 1193 endsub 1194 sub checked king 1195 my from piece 1196 local movetype 1197 set movetype CHECK 1198 if isupper cond empty var king $moved space var king 1199 def enemies onlylower 1200 else 1201 def enemies onlyupper 1202 endif 1203 for (from piece) fn enemies 1204 if fn const alias #piece #from var king and isfunc const alias #piece 1205 return #from 1206 endif 1207 next 1208 return false 1209 endsub 1210 def checked anytrue lambda (fn const alias #0 var key var king) cond isupper space var king (onlylower) (onlyupper) =movetype CHECK =king 1211 def threatened anytrue lambda (fn const alias space #0 #0 var king) elem var king threats =movetype CHECK =king 1212 sub uncheckedpath start finish 1213 my from to piece kingpos 1214 local movetype 1215 set movetype CHECK 1216 if empty #finish 1217 set kingpos #start 1218 else 1219 set kingpos #finish 1220 endif 1221 if isupper space #kingpos 1222 def enemies onlylower 1223 else 1224 def enemies onlyupper 1225 endif 1226 for to path #start #finish 1227 move #kingpos #to 1228 for (from piece) fn enemies 1229 if fn const alias #piece #from #to 1230 move #to #kingpos 1231 return false 1232 endif 1233 next 1234 move #to #kingpos 1235 next 1236 return true 1237 endif 1238 sub uncheckedknightleap start finish 1239 my from to piece kingpos kingpiece checkedpaths 1240 local movetype 1241 set movetype CHECK 1242 if empty #start 1243 set kingpos #finish 1244 else 1245 set kingpos #start 1246 endif 1247 if isupper space #kingpos 1248 def enemies onlylower 1249 else 1250 def enemies onlyupper 1251 endif 1252 set kingpiece space #kingpos 1253 set avenues merge intersection leaps #start 1 0 leaps #finish 1 1 intersection leaps #start 1 1 leaps #finish 1 0 1254 set checkdpaths 0 1255 for to #avenues 1256 if empty #to 1257 move #kingpos #to 1258 else 1259 empty #kingpos 1260 endif 1261 for (from piece) fn enemies 1262 if fn const alias #piece #from #to 1263 inc checkedpaths 1264 break 1265 endif 1266 next 1267 if == space #to #kingpiece 1268 move #to #kingpos 1269 else 1270 add #kingpiece #kingpos 1271 endif 1272 if == checkedpaths 0 1273 break 1274 endif 1275 next 1276 return < var checkedpaths 2 1277 endif 1278 sub castle from to 1279 local coord RPOS RDEST xdir 1280 if not flag #from 1281 die A King may not castle after it moves. 1282 endif 1283 if capture 1284 die A King may not castle to an occupied space. 1285 endif 1286 set xdir sign minus file #to file #from 1287 if not checkaride #from #to #xdir 0 1288 die A King may not castle across any occupied space. 1289 endif 1290 set coord #to 1291 do 1292 set coord where #coord #xdir 0 1293 if flag #coord 1294 break 1295 elseif not onboard #coord 1296 die No piece was found to castle with. 1297 elseif not empty #coord 1298 die The King cannot castle with the piece at #coord 1299 endif 1300 loop 1301 set RPOS #coord 1302 move #to #from 1303 if sub checked #from 1304 die A King may not castle out of check. 1305 endif 1306 store 1307 for coord path #from #to 1308 move #from #coord 1309 if sub checked #coord 1310 die A King may not castle through check. 1311 endif 1312 restore 1313 next 1314 move #from #to 1315 set RDEST where #to neg #xdir 0 1316 move #RPOS #RDEST 1317 return true 1318 endsub 1319 sub castlepos from to 1320 local coord RPOS RDEST xdir safe 1321 verify flag #from 1322 verify empty #to 1323 set xdir sign minus file #to file #from 1324 verify checkaride #from #to #xdir 0 1325 verify not sub checked #from 1326 set coord #to 1327 do 1328 set coord where #coord #xdir 0 1329 if flag #coord 1330 break 1331 endif 1332 verify onboard #coord 1333 verify empty #coord 1334 loop 1335 verify flag #coord 1336 set RPOS #coord 1337 store 1338 for coord path #from #to 1339 move #from #coord 1340 set safe not sub checked #coord 1341 restore 1342 verify #safe 1343 next 1344 move #from #to 1345 set RDEST where #to neg #xdir 0 1346 move #RPOS #RDEST 1347 set safe not sub checked #to 1348 restore 1349 return #safe 1350 endsub 1351 sub castle2 kingfrom kingto rookfrom rookto 1352 local coord xdir king rook 1353 if not flag #kingfrom 1354 die A King may not castle after it moves. 1355 endif 1356 if not flag #rookfrom 1357 die A King may not castle with a piece that has already moved. 1358 endif 1359 if not match @ $lastcaptured $prevcaptured 1360 die Castling to an occupied space is not allowed. 1361 endif 1362 if empty #kingto 1363 die There is nothing on #kingto. Did you move a piece there and then move it away? 1364 endif 1365 if empty #rookto 1366 die There is nothing on #rookto. Did you move a piece there and then move it away? 1367 endif 1368 set king space #kingto 1369 set rook space #rookto 1370 if == #king #rook 1371 die "Castling must be between different pieces. These two are both {#king}. What happened?" 1372 endif 1373 empty #kingto 1374 empty #rookto 1375 add #king #kingfrom 1376 add #rook #rookfrom 1377 set xdir sign minus file #kingto file #kingfrom 1378 if not checkaride #kingfrom #kingto #xdir 0 1379 die A King may not castle across any occupied space. 1380 endif 1381 if not checkaride #rookto #rookfrom #xdir 0 1382 die A Rook may not castle across an occupied space. 1383 endif 1384 if sub checked #kingfrom 1385 die A King may not castle out of check. 1386 endif 1387 store 1388 for coord path #kingfrom #kingto 1389 move #kingfrom #coord 1390 if sub checked #coord 1391 die A King may not castle through check. 1392 endif 1393 restore 1394 next 1395 empty #kingfrom 1396 empty #rookfrom 1397 add #king #kingto 1398 add #rook #rookto 1399 unsetflag #kingfrom #rookfrom 1400 if isupper space #kingto 1401 set Kpos #kingto 1402 else 1403 set kpos #kingto 1404 endif 1405 return true 1406 endsub 1407 sub castlepos2 kingfrom kingto rookfrom rookto 1408 echo "Calling castlepos2" #kingfrom #kingto #rookfrom #rookto 1409 local coord xdir safe 1410 verify flag #kingfrom and flag #rookfrom 1411 echo "Verified flags" 1412 verify empty #kingto or == #kingto #rookfrom 1413 verify empty #rookto or == #rookto #kingfrom 1414 echo "Verified empty destinations" 1415 set xdir sign minus file #kingto file #kingfrom 1416 echo "xdir is {#xdir}" 1417 verify checkride #kingfrom #kingto #xdir 0 1418 echo "Verified checkride {#kingfrom} {#kingto} {#xdir} 0" 1419 verify checkride #rookto #rookfrom #xdir 0 1420 echo "Verified checkride {#kingto} {#kingfrom} {#xdir} 0" 1421 verify not sub checked #kingfrom 1422 echo "Verified not checked" 1423 store 1424 for coord path #kingfrom #kingto 1425 move #kingfrom #coord 1426 set safe not sub checked #coord 1427 restore 1428 verify #safe 1429 next 1430 move #kingfrom #kingto 1431 move #rookfrom #rookto 1432 set safe not sub checked #kingto 1433 restore 1434 return #safe 1435 endsub 1436 sub stalemated kingpos 1437 store 1438 local cspaces friend friends from king piece to movetype np prom promfn 1439 set movetype MOVE 1440 set king alias space #kingpos 1441 if hasupper #king 1442 set friends lambda (onlyupper) 1443 set free lambda (haslower #0 or not hasupper #0) 1444 set pzone lambda (not onboard where #0 0 var pzs) 1445 set cspaces var wcastle 1446 set prom var wprom 1447 else 1448 set friends lambda (onlylower) 1449 set free lambda (hasupper #0 or not haslower #0) 1450 set pzone lambda (not onboard where #0 0 neg var pzs) 1451 set cspaces var bcastle 1452 set prom var bprom 1453 endif 1454 store 1455 for (from piece) fn #friends 1456 set af alias #from 1457 for to fn join const alias #piece "-Range" #from 1458 set at alias #to 1459 if fn const alias #piece #from #to and fn #free alias space #to and onboard #to 1460 set ap alias #piece 1461 move #from #to 1462 if not sub checked cond == #from #kingpos #to #kingpos 1463 set promfn join const alias #piece "-Promote" 1464 if fn #pzone #to and match #piece #promotable 1465 if > count var prom 0 1466 for np var prom 1467 setlegal "{#ap} {#af}-{#at}; {#np}-{#at}" 1468 next 1469 endif 1470 elseif fn #pzone #to and isfunc var promfn 1471 set prom fn var promfn #to 1472 if > count var prom 0 1473 for np var prom 1474 setlegal "{#ap} {#af}-{#at}; {#np}-{#at}" 1475 next 1476 endif 1477 elseif fn #pzone #to and match #piece #promotable 1478 if > count var prom 0 1479 for np var prom 1480 setlegal "{#ap} {#af}-{#at}; {#np}-{#at}" 1481 next 1482 endif 1483 else 1484 setlegal "{#ap} {#af}-{#at}" 1485 endif 1486 endif 1487 endif 1488 restore 1489 next 1490 next 1491 if > count var cspaces 0 1492 for to var cspaces 1493 if sub castlepos #kingpos #to 1494 setlegal "{#king} {#kingpos}-{#to}" 1495 endif 1496 next 1497 endif 1498 setsystem autorules sub describe_rules 1499 return cond count system legalmoves false true 1500 endsub 1501 sub stalemated-quick kingpos 1502 store 1503 local checked checkpos cspaces enemies friend friends from in king piece threats to movetype np prom promfn 1504 set movetype MOVE 1505 set king alias space #kingpos 1506 if hasupper #king 1507 set friends lambda (onlyupper) 1508 set enemies lambda (onlylower) 1509 set free lambda (haslower #0 or not hasupper #0) 1510 set pzone lambda (not onboard where #0 0 var pzs) 1511 set cspaces var wcastle 1512 set prom var wprom 1513 else 1514 set friends lambda (onlylower) 1515 set enemies lambda (onlyupper) 1516 set free lambda (hasupper #0 or not haslower #0) 1517 set pzone lambda (not onboard where #0 0 neg var pzs) 1518 set cspaces var bcastle 1519 set prom var bprom 1520 endif 1521 set krange merge fn join const alias space #kingpos "-Range" #kingpos #kingpos 1522 set threats () 1523 for to #krange 1524 set threats.{#to} () 1525 next 1526 for (from piece) fn #enemies 1527 set in intersection var krange fn join const alias var piece "-Range" var from 1528 for to #in 1529 push threats.{#to} #from 1530 next 1531 next 1532 store 1533 for (from piece) fn #friends 1534 set af alias #from 1535 for to fn join const alias #piece "-Range" #from 1536 set at alias #to 1537 if fn const alias #piece #from #to and fn #free alias space #to and onboard #to 1538 set ap alias #piece 1539 set checkpos cond == #from #kingpos #to #kingpos 1540 set checked false 1541 if count elem var checkpos threats 1542 move #from #to 1543 set checked fn threatened #checkpos 1544 restore 1545 endif 1546 if not #checked 1547 set promfn join const alias #piece "-Promote" 1548 if fn #pzone #to and match #piece #promotable 1549 if > count var prom 0 1550 for np var prom 1551 setlegal "{#ap} {#af}-{#at}; {#np}-{#at}" 1552 next 1553 endif 1554 elseif fn #pzone #to and isfunc var promfn 1555 set prom fn var promfn #to 1556 if > count var prom 0 1557 for np var prom 1558 setlegal "{#ap} {#af}-{#at}; {#np}-{#at}" 1559 next 1560 endif 1561 elseif fn #pzone #to and match #piece #promotable 1562 if > count var prom 0 1563 for np var prom 1564 setlegal "{#ap} {#af}-{#at}; {#np}-{#at}" 1565 next 1566 endif 1567 else 1568 setlegal "{#ap} {#af}-{#at}" 1569 endif 1570 endif 1571 endif 1572 restore 1573 next 1574 next 1575 if > count var cspaces 0 1576 for to var cspaces 1577 if sub castlepos #kingpos #to 1578 setlegal "{#king} {#kingpos}-{#to}" 1579 endif 1580 next 1581 endif 1582 setsystem autorules sub describe_rules 1583 return cond count system legalmoves false true 1584 endsub 1585 sub stalemated2 kingpos 1586 store 1587 local cspaces friend friends from piece to movetype 1588 set movetype MOVE 1589 if isupper space #kingpos 1590 set friends (onlyupper) 1591 set friend (isupper #0) 1592 set cspaces var wcastle 1593 else 1594 set friends (onlylower) 1595 set friend (islower #0) 1596 set cspaces var bcastle 1597 endif 1598 set royal space var kingpos 1599 store 1600 for (from piece) fn #friends 1601 for to fn join const alias #piece "-Range" #from 1602 if fn const alias #piece #from #to and not fn #friend space #to and onboard #to 1603 move #from #to 1604 if not sub checked cond == #from #kingpos #to #kingpos 1605 set ap alias #piece 1606 setlegal "{#ap} {#from}-{#to}" 1607 endif 1608 endif 1609 restore 1610 next 1611 next 1612 if > count var cspaces 0 and flag #kingpos 1613 for mvs var cspaces 1614 if sub castlepos2 #mvs.0 #mvs.1 #mvs.2 #mvs.3 and == #kingpos #mvs.0 1615 set pk alias space #mvs.0 1616 set pr alias space #mvs.2 1617 setlegal "{#pk} {#mvs.0}-{#mvs.1}; {#pr} {#mvs.2}-{#mvs.3}" 1618 endif 1619 next 1620 endif 1621 setsystem autorules sub describe_rules 1622 return cond count system legalmoves false true 1623 endsub 1624 sub fusion-stalemated kingpos 1625 store 1626 local cspaces friend friends from piece to movetype mv ss 1627 set movetype MOVE 1628 set ss join chr 47 chr 47 1629 if isupper space #kingpos 1630 set friends (onlyupper) 1631 set friend (isupper #0) 1632 set cspaces var wcastle 1633 else 1634 set friends (onlylower) 1635 set friend (islower #0) 1636 set cspaces var bcastle 1637 endif 1638 set royal space var kingpos 1639 store 1640 set kp #kingpos 1641 for (from piece) fn #friends 1642 set ap alias #piece 1643 for to fn join const #ap "-Range" #from 1644 if != space #to #piece and match toupper alias space #to K R B N and match toupper alias #piece R B N or not fn #friend space #to and fn const alias #piece #from #to and onboard #to 1645 move #from #to 1646 if match #ap K KR KB KN k kr kb kn 1647 set kp #to 1648 endif 1649 if not sub checked #kp 1650 setlegal "{#ap} {#from}-{#to}" 1651 endif 1652 restore 1653 set kp #kingpos 1654 endif 1655 if not sub checked #from and empty #to and == strlen alias #piece 2 1656 set compound alias #piece 1657 set simple1 leftstr #compound 1 1658 set simple2 rightstr #compound 1 1659 if != not fn #friend space #to and fn const alias #simple1 #from #to 1660 add #simple1 #to 1661 add #simple2 #from 1662 if match #simple1 K k 1663 set kp #to 1664 endif 1665 if not sub checked #kp 1666 setlegal "{#simple1} {#from}-{#to}; {#ss} {#simple2}-{#from}" 1667 endif 1668 restore 1669 set kp #kingpos 1670 endif 1671 if != not fn #friend space #to and fn const alias #simple2 #from #to 1672 add #simple2 #to 1673 add #simple1 #from 1674 if match #simple1 K k 1675 set kp #from 1676 endif 1677 if not sub checked #kp 1678 setlegal "{#simple2} {#from}-{#to}; {#ss} {#simple1}-{#from}" 1679 endif 1680 restore 1681 set kp #kingpos 1682 endif 1683 endif 1684 next 1685 next 1686 if > count var cspaces 0 1687 for to var cspaces 1688 if sub castlepos #kingpos #to 1689 setlegal (#kingpos #to) 1690 endif 1691 next 1692 endif 1693 setsystem autorules sub describe_rules 1694 return cond count system legalmoves false true 1695 endsub 1696 sub describe_rules 1697 my c piecenames notation values val id ref rules desc name codename rangefn 1698 set c.0 join filename 0 rankname 0 1699 set c.1 join filename >> lastfile 1 rankname 1 1700 set c.2 join filename inc >> lastfile 1 rankname 1 1701 set c.3 join filename >> lastfile 1 rankname inc >> lastrank 1 1702 set c.4 join filename inc >> lastfile 1 rankname >> lastrank 1 1703 set c.5 join filename >> lastfile 1 rankname dec lastrank 1704 set c.6 join filename inc >> lastfile 1 rankname dec lastrank 1705 set c.7 join filename lastfile rankname lastrank 1706 foreach p keys $pieces 1707 if isconst alias #p 1708 set codename const alias #p 1709 set name alias #codename 1710 set notation.{#name} alias #p 1711 if match #codename const alias space #kpos const alias space #Kpos 1712 set values.{#name} * 8 count spaces 1713 else 1714 set rangefn join #codename "-Range" 1715 set values.{#name} sum lambda (count fn #rangefn #0) #c 1716 endif 1717 endif 1718 next 1719 set values reverse asort #values 1720 set rules "
" 1721 foreach (name val) #values 1722 set codename realname #name 1723 if == null var #codename 1724 set codename #name 1725 endif 1726 set ref join #codename "-Desc" 1727 set desc str_replace "%s" #name var #ref 1728 set desc str_replace "_" " " #desc 1729 set id realname #notation.{#name} 1730 set rules join #rules "
[pc {#id} {#name}]{#desc}[/pc]
" 1731 next 1732 set rules join #rules "
" 1733 return #rules 1734 endsub 1735 sub findmates side 1736 local enemyking king mates moves mv 1737 if match #side 1 white White first 1738 set king #Kpos 1739 set enemyking #kpos 1740 else 1741 set king #kpos 1742 set enemyking #Kpos 1743 endif 1744 set mates () 1745 ban none 1746 setsystem maxmove 0 1747 store main 1748 setsystem legalmoves () 1749 if not sub stalemated #king 1750 set lglmvs $legalmoves 1751 foreach move #lglmvs 1752 set moves explode chr 59 #move 1753 foreach mv #moves 1754 set mv trim #mv 1755 eval "MOVE: {#mv}" 1756 next 1757 if sub checked #enemyking 1758 setsystem legalmoves () 1759 if sub stalemated #enemyking 1760 push mates #move 1761 endif 1762 endif 1763 restore main 1764 next 1765 endif 1766 setsystem legalmoves #mates 1767 endsub 1768 endlib