Please report any bugs or errors to wdtr2

1

BANNED INPUT: H f3-f4 on turn 1:

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