Please report any bugs or errors to H.G. Muller
d1 is empty
Use your browser's BACK button to go back to the previous page, then reload if necessary.
For general reference, here is the complete list of moves:
1. SL d1-b3 1... n g8-f6 2. N g1-f3 2... p e7-e6 3. P d2-d4 3... p b7-b6 4. B c1-g5 4... p h7-h6 5. B g5-h4 5... b c8-a6 6. N b1-d2 6... b f8-e7 7. P c2-c4 7... k e8-g8;h8-f8 8. P e2-e3 8... p d7-d5 9. B f1-d3 9... r f8-e8 10. K e1-g1;h1-f1 10... p d5-c4 11. B d3-c4 11... b a6-c4 12. N d2-c4 12... sl d8-c6 13. N c4-e5 13... sl c6-e4 14. R a1-c1 14... p c7-c5 15. P d4-c5 15... b e7-c5 16. R f1-d1 16... n b8-c6 17. N e5-c6 17... sl e4-c6 18. N f3-d4 18... sl c6-e4 19. P f2-f3 19... sl e4-g6 20. B h4-g3 20... n f6-d5 21. K g1-f2 21... p e6-e5 22. N d4-c6 22... n d5-e3 23. R d1-d5 23... n e3-d5 24. R c1-c5 24... p b6-c5If this is your settings file, you may edit it at https://www.chessvariants.com/play/pbm/play.php?game=Squirrel+Chess&settings=def02&submit=Edit
Here is a code listing:
0 include /membergraphics/MSgame-code-generation/betza.txt 1 set legdefs (0 1 1 0 1 1 1 1 1 1 2 1 1 -1 1 2 1 1 0 2 16577 1 1 1 1 4 1 1 -1 1 4 0 1 1 0 -1 1 1 1 -1 -1 2 1 1 1 -1 2 1 1 0 -2 16577 1 1 -1 -1 4 1 1 1 -1 4 0 1 1 1 2 3 1 1 2 1 3 1 1 2 -1 3 1 1 1 -2 3 1 1 -1 -2 3 1 1 -2 -1 3 1 1 -2 1 3 1 1 -1 2 3 0 1 99 1 1 3 1 99 1 -1 3 1 99 -1 -1 3 1 99 -1 1 3 0 1 99 0 1 3 1 99 1 0 3 1 99 0 -1 3 1 99 -1 0 3 0 1 1 0 1 3 1 1 1 1 3 1 1 1 0 3 1 1 1 -1 3 1 1 0 -1 3 1 1 -1 -1 3 1 1 -1 0 3 1 1 -1 1 3 2 99 1 0 72 1 2 0 9 2 99 -1 0 72 1 -2 0 9 0 1 1 1 2 3 1 1 2 1 3 1 1 2 -1 3 1 1 1 -2 3 1 1 -1 -2 3 1 1 -2 -1 3 1 1 -2 1 3 1 1 -1 2 3 1 1 2 2 3 1 1 2 -2 3 1 1 -2 -2 3 1 1 -2 2 3 1 1 0 2 3 1 1 2 0 3 1 1 0 -2 3 1 1 -2 0 3 0) 2 def P cond #0 1 16 3 def p cond #0 32 47 4 def N cond #0 63 0 5 def n cond #0 63 0 6 def B cond #0 104 0 7 def b cond #0 104 0 8 def R cond #0 125 0 9 def r cond #0 125 0 10 def K cond #0 146 186 11 def k cond #0 146 186 12 def SL cond #0 205 0 13 def sl cond #0 205 0 14 set extinction 1 15 set partners (a1 h1 a8 h8) 16 set promotables (P p) 17 set supply (N n B b R r SL sl) 18 set promotab ( (n b r sl) 0 0 0 0 0 0 (N B R SL) ) 19 sub postauto1 20 gosub HandleMove false 21 endsub 22 sub postauto2 23 gosub HandleMove true 24 endsub 25 moveindex 0 26 MOVE: SL d1-b3 27 postauto1 28 moveindex 1 29 MOVE: n g8-f6 30 postauto2 31 moveindex 2 32 MOVE: N g1-f3 33 postauto1 34 moveindex 3 35 MOVE: p e7-e6 36 postauto2 37 moveindex 4 38 MOVE: P d2-d4 39 postauto1 40 moveindex 5 41 MOVE: p b7-b6 42 postauto2 43 moveindex 6 44 MOVE: B c1-g5 45 postauto1 46 moveindex 7 47 MOVE: p h7-h6 48 postauto2 49 moveindex 8 50 MOVE: B g5-h4 51 postauto1 52 moveindex 9 53 MOVE: b c8-a6 54 postauto2 55 moveindex 10 56 MOVE: N b1-d2 57 postauto1 58 moveindex 11 59 MOVE: b f8-e7 60 postauto2 61 moveindex 12 62 MOVE: P c2-c4 63 postauto1 64 moveindex 13 65 MOVE: k e8-g8 66 MOVE: h8-f8 67 postauto2 68 moveindex 14 69 MOVE: P e2-e3 70 postauto1 71 moveindex 15 72 MOVE: p d7-d5 73 postauto2 74 moveindex 16 75 MOVE: B f1-d3 76 postauto1 77 moveindex 17 78 MOVE: r f8-e8 79 postauto2 80 moveindex 18 81 MOVE: K e1-g1 82 MOVE: h1-f1 83 postauto1 84 moveindex 19 85 MOVE: p d5-c4 86 postauto2 87 moveindex 20 88 MOVE: B d3-c4 89 postauto1 90 moveindex 21 91 MOVE: b a6-c4 92 postauto2 93 moveindex 22 94 MOVE: N d2-c4 95 postauto1 96 moveindex 23 97 MOVE: sl d8-c6 98 postauto2 99 moveindex 24 100 MOVE: N c4-e5 101 postauto1 102 moveindex 25 103 MOVE: sl c6-e4 104 postauto2 105 moveindex 26 106 MOVE: R a1-c1 107 postauto1 108 moveindex 27 109 MOVE: p c7-c5 110 postauto2 111 moveindex 28 112 MOVE: P d4-c5 113 postauto1 114 moveindex 29 115 MOVE: b e7-c5 116 postauto2 117 moveindex 30 118 MOVE: R f1-d1 119 postauto1 120 moveindex 31 121 MOVE: n b8-c6 122 postauto2 123 moveindex 32 124 MOVE: N e5-c6 125 postauto1 126 moveindex 33 127 MOVE: sl e4-c6 128 postauto2 129 moveindex 34 130 MOVE: N f3-d4 131 postauto1 132 moveindex 35 133 MOVE: sl c6-e4 134 postauto2 135 moveindex 36 136 MOVE: P f2-f3 137 postauto1 138 moveindex 37 139 MOVE: sl e4-g6 140 postauto2 141 moveindex 38 142 MOVE: B h4-g3 143 postauto1 144 moveindex 39 145 MOVE: n f6-d5 146 postauto2 147 moveindex 40 148 MOVE: K g1-f2 149 postauto1 150 moveindex 41 151 MOVE: p e6-e5 152 postauto2 153 moveindex 42 154 MOVE: N d4-c6 155 postauto1 156 moveindex 43 157 MOVE: n d5-e3 158 postauto2 159 moveindex 44 160 MOVE: R d1-d5 161 postauto1 162 moveindex 45 163 MOVE: n e3-d5 164 postauto2 165 moveindex 46 166 MOVE: R c1-c5 167 postauto1 168 moveindex 47 169 MOVE: p b6-c5 170 postauto2 171 gosub GameEnd true 172 end 173 174 lib /membergraphics/MSgame-code-generation/betza.txt 175 if == thismove null 176 say This rule-enforcing preset was created through the Play-Test Applet 177 endif 178 echo Please report any bugs or errors to H.G. Muller 179 setsystem maxmove 4 180 setsystem omitmoves 1 181 ban commands 182 allow pass 2 pass 3 183 set pseudo 0 184 set zonal 0 185 set repeats 3 186 set reploses 0 187 set rulemoves 100 188 set resetpieces (P p) 189 set staledraw 1 190 set checkrule 1 191 set extinction 0 192 set nullban 1 193 set wroyal (K) 194 set broyal (k) 195 set iron array 196 set protected array 197 set restricted array 198 set counterstrike array 199 set negligible array 200 set opaque array 201 set brouhaha array 202 set imitators array 203 set inducers array 204 set shooters array 205 set morphers array 206 set promotables array 207 set inocheck (K k) 208 set conversion array 209 set method 1 210 set dropdown 1 211 set crappy 0 212 set cap array 213 set tempiron array 214 set epsqrs 0 215 set strike 0 216 set traded 0 217 set nopvc 0 218 set toimitate p 219 set lastfen 0 220 set epmask 4 221 set many ep 0 suicide 0 freedrop 0 222 set converted 0 223 set hist . "zzz," fencode 224 def friends cond #0 (onlylower) (onlyupper) 225 sub FastCastle start dx dy 226 verify not flag #start 227 my k r sqr cornr rook 228 set r ray #start #dx #dy 229 set k dec count #r 230 set cornr elem #k #r 231 set rook space #cornr 232 verify != @ #rook and not flag #cornr 233 do while #k 234 dec k 235 set sqr elem #k #r 236 if == @ space #sqr 237 if == 0 #k 238 set realto #sqr 239 set sqr #cornr 240 endif 241 gosub GotMove #start #sqr #cornr #start #rook 1 242 endif 243 loop 244 endsub 245 sub Promote player piece desti 246 my choice r across 247 verify mln 248 set r rank #desti 249 set across - lastrank * 2 #r 250 if == #player < #across 0 251 return 252 endif 253 if match #piece #promotables 254 set choice elem #r #promotab 255 if #choice 256 if match self #choice 257 push choice #piece 258 endif 259 set cap mergeall #cap #supply 260 set choice intersection #cap #choice 261 endif 262 else 263 set choice 0 264 endif 265 if #promo 266 if not #choice 267 die "You cannot promote on this move" 268 elseif not match #promo #choice 269 die "You cannot promote to such a piece" 270 endif 271 elseif #choice and not $answered 272 askpromote #choice 273 endif 274 endsub 275 sub GotMove orisqr destsqr locustsqr dropsqr unload implied 276 if == 2 #zonal 277 set k space #orisqr 278 gosub GetMorph #k #destsqr 279 verify != barred #k 280 endif 281 switch #task 282 case 1 283 set halfhit or #halfhit and #crappy and == #orisqr #ori == #locustsqr #desti 284 verify == #orisqr #ori and == #destsqr #desti 285 if == 1 #zonal 286 verify not fn BadZone #orisqr #destsqr #locustsqr #dropsqr #unload 287 endif 288 if != 1 #implied 289 if #firstpart 290 set pseudohit + #pseudohit #crappy 291 set autolocust #locustsqr 292 set autodrop #dropsqr 293 set dropped #unload 294 endif 295 if #sideeffect 296 verify == #sideeffect #dropsqr or == #sideeffect #locustsqr 297 set suicide #locustsqr 298 set freedrop #dropsqr 299 set dropped #unload 300 else 301 verify == #locustsqr #suicide 302 verify == #dropsqr #freedrop 303 verify == #unload #dropped or not #dropsqr 304 endif 305 else 306 verify not #suicide and not #freedrop 307 if #locustsqr 308 capture #locustsqr 309 set imp 1 310 endif 311 set impliedkill #locustsqr 312 set implieddrop #dropsqr 313 set dropped #unload 314 endif 315 set neweps #eps 316 set ep #destsqr 317 set ok 1 318 set desc #mv 319 break 320 case 2 321 if == 1 #zonal 322 verify not fn BadZone #orisqr #destsqr #locustsqr #dropsqr #unload 323 endif 324 if #locustsqr or #dropsqr and #dropdown and not #implied 325 set m . space #orisqr . ws . #orisqr . chr 45 . #destsqr . chr 59 ws 326 if #locustsqr 327 set m . #m . "@-" #locustsqr 328 elseif #dropsqr 329 set m . #m . #unload . chr 45 #dropsqr 330 endif 331 push xtl #m 332 else 333 setlegal #orisqr #destsqr 334 endif 335 break 336 case 9 337 if == #locustsqr #kpos 338 push checks #ss 339 push checks #mv 340 setelem #locustsqr 0 1 341 endif 342 break 343 case 10 344 case 7 345 case 3 346 set hit cond match space #destsqr #royal #orisqr #hit 347 if != Xdummy space #locustsqr and #locustsqr 348 set hit cond match space #locustsqr #royal Ughh #hit 349 endif 350 break 351 case 12 352 verify count var #orisqr 353 case 11 354 if & 1 elem 0 var #destsqr and == #orisqr #kpos 355 break 356 endif 357 case 4 358 case 8 359 if == 1 #zonal 360 verify not fn BadZone #orisqr #destsqr #locustsqr #dropsqr #unload 361 endif 362 my victim locustvictim 363 set victim space #destsqr 364 set locustvictim space #locustsqr 365 if #locustsqr 366 empty #locustsqr 367 endif 368 move #orisqr #destsqr 369 if #dropsqr 370 add #unload #dropsqr 371 endif 372 dec task 373 set hit 0 374 if == 10 #task 375 if #checked 376 gosub GenAttacks checks 377 endif 378 gosub GenAttacks #orisqr 379 gosub GenAttacks #destsqr 380 if #locustsqr 381 gosub GenAttacks #locustsqr 382 endif 383 if #dropsqr 384 gosub GenAttacks #dropsqr 385 endif 386 else 387 if #threat and != #threat Ughh 388 set checker space #threat 389 if cond #xside islower #checker isupper #checker 390 gosub GenMoves #checker #threat 1 391 endif 392 endif 393 if not #hit 394 gosub GenAll #xside 395 endif 396 endif 397 inc task 398 move #destsqr #orisqr 399 if != #dropsqr #orisqr and #dropsqr 400 empty #dropsqr 401 endif 402 if #locustsqr 403 add #locustvictim #locustsqr 404 endif 405 add #victim #destsqr 406 if == 4 #task 407 set threat #hit 408 set hit not #hit 409 elseif #hit 410 set hit 0 411 elseif #locustsqr or #dropsqr and #dropdown and not #implied 412 set m . space #orisqr . ws . #orisqr . chr 45 . #destsqr . chr 59 ws 413 if #locustsqr 414 if match #mover #shooters 415 set m . #m . "@-" #locustsqr 416 else 417 set m . space #orisqr . ws . #orisqr . chr 45 . #locustsqr . chr 59 ws 418 set m . #m . space #orisqr . ws . #locustsqr . chr 45 #destsqr 419 endif 420 elseif #dropsqr 421 set m . #m . #unload . chr 45 #dropsqr 422 endif 423 push xtl #m 424 else 425 setlegal #orisqr #destsqr 426 endif 427 break 428 case 5 429 verify == #locustsqr #desti 430 setlegal #locustsqr #destsqr 431 break 432 case 6 433 verify == #ori #orisqr and == #desti #destsqr 434 if #dropsqr 435 setlegal #desti #dropsqr 436 elseif #locustsqr 437 setlegal #desti #locustsqr 438 endif 439 break 440 case 13 441 verify not #dropsqr and #locustsqr or not empty #destsqr 442 set hit 1 443 break 444 endswitch 445 endsub 446 sub NextLeg togo legindex startsqr cursqr locustsqr dropsqr iso 447 my rng dx dy mode to tosqrs k len newindex hx hy side r fratricide stopper 448 set rng elem #legindex #legdefs 449 set dx elem + 1 #legindex #legdefs 450 set dy elem + 2 #legindex #legdefs 451 set mode elem + 3 #legindex #legdefs 452 if & 64 #mode 453 verify not flag #startsqr 454 if match space #startsqr #inocheck 455 verify != #task 11 or not #checked 456 push eps #startsqr 457 endif 458 endif 459 if > 0 #rng 460 switch #rng 461 case -1 462 set rng cond < 0 #dy rank #cursqr - lastrank rank #cursqr 463 set rng - >> lastrank 1 #rng 464 set rng max 1 #rng 465 set eps array 466 set mode | << 1 23 #mode 467 break 468 case -2 469 gosub GenMoves #toimitate #startsqr 1 470 return 471 case -3 472 gosub #mode #startsqr #dx #dy 473 return 474 endswitch 475 endif 476 set tosqrs ride #cursqr #dx #dy 477 set r count #tosqrs 478 if not #r 479 if & #mode << 1 27 480 gosub GotMove #startsqr #cursqr #locustsqr #dropsqr 0 0 481 else 482 return 483 endif 484 endif 485 set r min #rng #r 486 if & 128 #mode 487 set hx >> + 8 * 5 #dx 4 488 set hy >> + 8 * 5 #dy 4 489 set k ride #startsqr #hx #hy 490 set len count #k 491 set len * #len + abs #hx abs #hy 492 set len / #len + abs #dx abs #dy 493 if < #len #r 494 set r #len 495 if == 9 #task 496 pop k to 497 push #to #ss 498 push #to #mv 499 endif 500 endif 501 verify #len 502 if & << 1 14 #mode 503 set eps array 504 set to where #cursqr #dx #dy 505 set k #cursqr 506 do while != #to #k and onboard #k 507 set k where #k #hx #hy 508 if != #k #to 509 push eps #k 510 endif 511 loop 512 endif 513 endif 514 dec togo 515 if & << 1 21 #mode 516 set dropsqr #cursqr 517 endif 518 if & << 1 15 #mode 519 verify >= #r #iso 520 set r #iso 521 elseif < 1 #r 522 if & 1 #mode 523 set k 1 524 do while < #k #r 525 set to elem dec #k #tosqrs 526 if #togo 527 set newindex + 4 #legindex 528 gosub NextLeg #togo #newindex #startsqr #to #locustsqr #dropsqr #k 529 else 530 gosub GotMove #startsqr #to #locustsqr #dropsqr 0 0 531 endif 532 if & << 1 23 #mode 533 push eps #to 534 endif 535 inc k 536 verify not #hit 537 loop 538 endif 539 if & #epmask #mode 540 set k 1 541 do while < #k #r 542 set to elem dec #k #tosqrs 543 if match #to #epsqrs 544 if #togo 545 set newindex + 4 #legindex 546 gosub NextLeg #togo #newindex #startsqr #to #ep #dropsqr #k 547 else 548 gosub GotMove #startsqr #to #ep #dropsqr 0 1 549 endif 550 endif 551 inc k 552 loop 553 endif 554 if & 18 #mode and == 9 #task 555 set k 1 556 do while < #k #r 557 set to elem dec #k #tosqrs 558 if #togo 559 push #to #ss 560 push #to #mv 561 endif 562 if & 2 #mode 563 if #togo 564 if == #to #kpos 565 set newindex + 4 #legindex 566 gosub NextLeg #togo #newindex #startsqr #to #to #dropsqr #k 567 endif 568 else 569 setelem #to 0 | 1 elem 0 var #to 570 if == #to #kpos 571 push checks #ss 572 push checks #mv 573 endif 574 endif 575 endif 576 inc k 577 loop 578 endif 579 endif 580 set len cond == 1 #rng #iso #r 581 set to elem dec #r #tosqrs 582 if == 9 #task 583 if cond empty #to (& 18 #mode and #togo) (not & << 1 15 #mode and != #r #rng and or & 2 #mode #togo or and & 1 #mode #togo) 584 push #to #ss 585 push #to #mv 586 endif 587 if & + 2 << 1 13 #mode and == #to #kpos 588 if #togo 589 set newindex + 4 #legindex 590 gosub NextLeg #togo #newindex #startsqr #to #to #dropsqr #len 591 else 592 push checks #ss 593 push checks #mv 594 endif 595 endif 596 if & 2 #mode and not #togo 597 setelem #to 0 | 1 elem 0 var #to 598 endif 599 endif 600 if match #to #epsqrs and & #epmask #mode 601 if #togo 602 set newindex + 4 #legindex 603 gosub NextLeg #togo #newindex #startsqr #to #ep #dropsqr #len 604 else 605 gosub GotMove #startsqr #to #ep 0 0 1 606 endif 607 endif 608 set stopper cond != #to #startsqr space #to @ 609 if == @ #stopper 610 verify & 1 #mode 611 else 612 if & 16 #mode 613 if not match #stopper #opaque or not match space #startsqr #opaque 614 set newindex + 4 #legindex 615 gosub NextLeg #togo #newindex #startsqr #to #locustsqr #dropsqr #len 616 endif 617 endif 618 set side islower space #startsqr 619 set fratricide cond #side islower #stopper isupper #stopper 620 if #fratricide 621 if & 8 #mode 622 verify match #to #partners 623 verify not flag #to 624 set locustsqr #to 625 set to where #startsqr elem + 5 #legindex #legdefs 0 626 set dropsqr where #to - 0 #dx #dy 627 set eps array 628 set k #startsqr 629 do while != #k #to 630 push eps #k 631 set k where #k #dx 0 632 loop 633 set realto #to 634 gosub GotMove #startsqr #to #locustsqr #dropsqr #stopper 1 635 return 636 elseif & 2048 #mode 637 if #togo 638 set newindex + 4 #legindex 639 gosub NextLeg #togo #newindex #to #to 0 0 #len 640 elseif != #stopper space #startsqr 641 gosub GenMoves #stopper #startsqr 1 642 endif 643 endif 644 verify & 4096 #mode 645 else 646 verify match #stopper #royal and & << 1 13 #mode or & 2 #mode 647 verify not match #stopper #tempiron 648 endif 649 if #togo 650 set locustsqr #to 651 endif 652 endif 653 if #togo 654 set newindex + 4 #legindex 655 gosub NextLeg #togo #newindex #startsqr #to #locustsqr #dropsqr #len 656 else 657 gosub GotMove #startsqr #to #locustsqr #dropsqr #stopper 0 658 endif 659 endsub 660 sub GenMoves piece sqr all 661 my index legcount startindex 662 set side islower #piece 663 set ss #sqr 664 set index fn #piece #all 665 do 666 set legcount elem #index #legdefs 667 verify #legcount 668 set mv #index 669 inc index 670 if flag #sqr or not match #piece #conversion or not & cond #side #converted << #converted 2 + 64 & 64 elem + 3 #index #legdefs 671 set eps 0 672 gosub NextLeg #legcount #index #sqr #sqr 0 0 1 673 endif 674 set index + #index * 4 #legcount 675 loop until #hit 676 endsub 677 sub GenAttacks sqr 678 my k n togo leg piece 679 set k 1 680 set n count var #sqr 681 do while < #k #n 682 set start elem #k var #sqr 683 inc k 684 set leg elem #k var #sqr 685 inc k 686 set piece space #start 687 if not cond #xside (islower #piece) (isupper #piece) 688 continue 689 endif 690 set togo elem #leg #legdefs 691 inc leg 692 gosub NextLeg #togo #leg #start #start 0 0 1 693 loop 694 endsub 695 sub GenAll player 696 my from piece 697 set hit false 698 for (from piece) fn friends #player 699 gosub GenMoves #piece #from 1 700 verify not #hit 701 next 702 endsub 703 sub GetRoyals player 704 my i nr type myroyal cnt 705 set myroyal cond #player (#broyal) (#wroyal) 706 set many i 0 nr 0 hit 0 707 set royal array 708 set troy array 709 do while < #i count #myroyal 710 set type elem #i #myroyal 711 set cnt elem #type piececount 712 if + 0 #cnt 713 set nr + #nr #cnt 714 push royal #type 715 push troy #cnt 716 endif 717 inc i 718 loop 719 set dead count #royal and not #nr 720 if < 1 #nr and #extinction 721 set royal array 722 endif 723 endsub 724 sub InCheck player 725 GetRoyals #player 726 set task 3 727 verify count #royal 728 if #traded 729 add Xdummy #desti 730 push royal Xdummy 731 endif 732 if count #epsqrs and match space #ep #royal 733 set epmask 6 734 endif 735 set player not #player 736 gosub GenAll #player 737 set epmask 4 738 if #traded 739 add #traded #desti 740 endif 741 endsub 742 sub ParseMove player 743 my i j parts sqrs sqr 744 set many suicide 0 freedrop 0 promo 0 sideeffect 0 745 set mvs explode chr 59 thismove 746 set parts explode ws trim elem 0 #mvs 747 set i count #parts 748 if > #i 2 749 die "move must be piece ID plus board step" 750 endif 751 set sqrs explode chr 45 trim elem dec #i #parts 752 if != 2 count #sqrs 753 if == resign thismove 754 resign 755 elseif == drawn thismove 756 drawn 757 endif 758 die "board step does not mention two squares" 759 endif 760 set ori elem 0 #sqrs 761 set desti elem 1 #sqrs 762 if not onboard #desti 763 set msg join #desti " is not a valid square" 764 die #msg 765 endif 766 if not onboard #ori 767 set msg join #ori " is not a valid square" 768 die #msg 769 endif 770 set mover space #ori 771 if not cond #player islower #mover isupper #mover 772 set msg cond == @ #mover (. #ori " is empty") ("you cannot move opponent pieces") 773 die #msg 774 endif 775 set firstpart 1 776 set j 1 777 do while < #j count #mvs 778 set parts trim elem #j #mvs 779 if == "pass" #parts or == "skip" #parts 780 set firstpart 0 781 inc j 782 continue 783 endif 784 set parts explode ws trim #parts 785 set i dec count #parts 786 set sqrs explode chr 45 trim elem #i #parts 787 if != 2 count #sqrs 788 set msg join elem #i #parts " is malformed" 789 die #msg 790 endif 791 set sqr elem 1 #sqrs 792 set sqr cond == "dest" #sqr #desti #sqr 793 if not onboard #sqr 794 set msg join #sqr " is not a valid square" 795 die #msg 796 elseif onboard elem 0 #sqrs 797 if != #desti elem 0 #sqrs 798 die "you can only continue with same piece" 799 endif 800 set firstpart 0 801 if match #mover #shooters 802 set sideeffect #sqr 803 return 804 endif 805 if #suicide 806 die "cannot have more than one locust victim" 807 endif 808 set suicide #desti 809 set desti #sqr 810 elseif == #desti #sqr 811 set promo elem 0 #sqrs 812 elseif == @ elem 0 #sqrs 813 if empty #sqr 814 set msg . "there is nothing on " . #sqr " to capture" 815 die #msg 816 endif 817 if #suicide 818 die "cannot have more than one locust victim" 819 endif 820 set suicide #sqr 821 set firstpart 0 822 else 823 if #freedrop 824 die "cannot kick more than one piece" 825 endif 826 set dropped elem 0 #sqrs 827 set freedrop #sqr 828 set firstpart 0 829 endif 830 inc j 831 loop 832 endsub 833 sub HandleMove player 834 set stm #player 835 gosub ParseMove #player 836 set all == mln $maxmln 837 set many ok 0 hit 0 task 1 halfhit 0 implieddrop 0 imp 0 neweps 0 838 set pseudohit 0 839 set realto 0 840 set k #all or not flag #ori and match #mover #conversion 841 gosub GenMoves #mover #ori #k 842 if not match #mover #shooters and #firstpart and #halfhit 843 set ok 2 844 set task 5 845 gosub GenMoves #mover #ori 1 846 set msg . "Enter second leg or pass" 847 remind #msg 848 elseif #all 849 set cap unique keys capturedpieces 850 set lastfen fencode 851 if not #ok 852 set pseudohit 0 853 gosub GenAll #player 854 endif 855 if #sideeffect 856 rewritemove . elem 0 #mvs . "; " . cond #freedrop #dropped @ . chr 45 #sideeffect 857 set sideeffect 0 858 gosub ParseMove #player 859 endif 860 if match #mover #shooters and < 1 #pseudohit 861 set ok 2 862 set task 6 863 gosub GenAll #player 864 if #hit 865 set msg . "Type side effect of move, or pass" 866 else 867 set msg . "Type side effect of move" 868 endif 869 remind #msg 870 elseif not #ok 871 if == 1 #pseudohit 872 if #autolocust 873 appendmove join "@-" #autolocust 874 endif 875 if #autodrop 876 appendmove join #dropped join chr 45 #autodrop 877 endif 878 gosub ParseMove #player 879 elseif #pseudohit 880 set msg . "Type side effects of move" 881 remind #msg 882 continuemove 883 return 884 else 885 set msg . thismove . " is not even pseudo-legal for a " toupper #mover 886 die #msg 887 endif 888 endif 889 endif 890 set victim cond != #desti #ori space #desti @ 891 set traded cond and or match space #suicide #negligible not #suicide and match #victim #protected match #mover #restricted #mover 0 892 set strike and match #victim #counterstrike not match #mover #counterstrike 893 set k 0 894 do while < var k count var mvs 895 eval join "MOVE: " trim elem var k var mvs 896 inc k 897 loop 898 if != #ori #freedrop and match #ori #brouhaha 899 delete #ori 900 endif 901 if #implieddrop 902 add #dropped #implieddrop 903 if == #desti #impliedkill 904 move #desti #realto 905 endif 906 endif 907 set tempiron #iron 908 if #strike 909 set tempiron mergeall #tempiron #counterstrike 910 endif 911 set toimitate flipcase cond match #mover #imitators #toimitate #mover 912 setflag #desti 913 set posvar join cond #player "w" "b" fencode 914 inc #posvar 915 inc nopvc 916 if #imp 917 set hist . #hist . "," mln 918 endif 919 if #suicide and not #freedrop or #promo or != @ #victim or match #mover #resetpieces 920 set nopvc 0 921 endif 922 set epsqrs #neweps 923 if not flag #ori and match #mover #conversion 924 set k + 64 & 64 elem + 4 #desc #legdefs 925 set k cond #player #k >> #k 2 926 if & #k #converted 927 die This move violates the conversion rule that applies to this piece. 928 endif 929 set converted + #converted #k 930 endif 931 gosub GetMorph #mover #desti 932 if #k 933 add #k #desti 934 endif 935 endsub 936 sub GetMorph piece sqr 937 set k 0 938 if match #piece #morphers 939 set i elem #piece #morphs 940 set j rank #sqr 941 if not islower #piece 942 set j - lastrank #j 943 endif 944 if >= #j count #i 945 return 946 endif 947 set i elem #j #i 948 if #i 949 if == All elem 0 #i 950 set k elem 1 #i 951 else 952 set k elem file #sqr #i 953 endif 954 endif 955 endif 956 endsub 957 sub GameEnd player 958 my side 959 if == 2 #ok 960 continuemove 961 return 962 endif 963 set side not #player 964 gosub GetRoyals #side 965 if #dead 966 set msg join cond #player "White" "Black" " lost by absence of royalty!" 967 say #msg 968 won 969 elseif == #lastfen fencode and #nullban 970 die "This is a null move!" 971 endif 972 gosub InCheck #player 973 if == #hit Xdummy 974 die "Trading of this piece is not allowed" 975 elseif #checkrule and #hit 976 if == #hit Ughh 977 die "That moves through or out of check" 978 else 979 die "This exposes your royal piece to capture" 980 endif 981 endif 982 if >= 1 count fn friends #player and #baring 983 if >= 1 count fn friends #side 984 say Draw by mutual baring 985 drawn 986 else 987 set msg . cond #player "Black" "White" " loses by baring" 988 say #msg 989 lost 990 endif 991 return 992 endif 993 gosub Promote #player #mover #desti 994 gosub GetRoyals #side 995 if count #royal and #checkrule 996 set task 4 997 set xside #player 998 set threat 0 999 gosub GenAll #side 1000 if not #hit 1001 if #staledraw 1002 dec task 1003 gosub GenAll #player 1004 if #hit 1005 say Checkmate! 1006 won 1007 else 1008 say Stalemate! 1009 drawn 1010 endif 1011 else 1012 say Mate! 1013 won 1014 endif 1015 return 1016 endif 1017 endif 1018 set posvar join cond #player "w" "b" fencode 1019 if >= var #posvar #repeats 1020 if #reploses 1021 set msg join cond #player "Black" "White" " loses by repetition!" 1022 say #msg 1023 lost 1024 else 1025 say "Draw by repetition!" 1026 drawn 1027 endif 1028 elseif >= #nopvc #rulemoves 1029 say "Game declared draw due to prolongued lack of progress!" 1030 drawn 1031 endif 1032 set ltst #checkrule and count #royal and not #pseudo 1033 set xtl array 1034 if == 1 #method and #ltst 1035 for sqr spaces 1036 set #sqr array 0 1037 next 1038 set task 9 1039 set king elem 0 #royal 1040 set kpos search #king $space 1041 empty #kpos 1042 set checks array 0 1043 gosub GenAll #player 1044 add #king #kpos 1045 set checked & 1 elem 0 var #kpos 1046 if #checked 1047 say "check!" 1048 endif 1049 set task 11 1050 gosub GenAll #side 1051 else 1052 set task cond #ltst 8 2 1053 gosub GenAll #side 1054 endif 1055 setjsvar impmoves #hist 1056 setsystem legalmoves merge $legalmoves #xtl 1057 endsub 1058 set posvar join "w" fencode 1059 inc #posvar 1060 endlib