This preset now uses the new code for identifying check, checkmate, and stalemate. Let me know of any problems with it.
79
BANNED INPUT: d3-b3;won on turn 40:
There is a global ban on commands in user input, and no exception has been made for the won command on the part of the turn indexed 2.
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 File0 echo This preset now uses the new code for identifying check, checkmate, and stalemate. Let me know of any problems with it. 1 setflag a1 a8 h1 h8 e1 e8 2 set K findpiece K spaces 3 set k findpiece k spaces 4 set ep false 5 include chess2 6 def t checkleap #0 #1 0 2 or checkride #0 #1 1 1 and <= distance #0 #1 2 7 def T checkleap #0 #1 0 2 or checkride #0 #1 1 1 and <= distance #0 #1 2 8 def tL merge merge leaps #0 0 2 leaps #0 1 1 leaps #0 2 2 9 def TL merge merge leaps #0 0 2 leaps #0 1 1 leaps #0 2 2 10 sub postauto1 11 if isupper old 12 die You may not capture your own pieces. 13 endif 14 switch moved 15 case P K 16 gosub moved origin dest 17 break 18 case Q R B N T 19 set legal fn moved origin dest 20 set ep false 21 if != space dest moved 22 die You may not change the type of this piece. 23 endif 24 break 25 default 26 set legal false 27 break 28 endswitch 29 if not var legal 30 die You may not move a moved from origin to dest 31 endif 32 if sub checked #K 33 die You may not move into check. 34 endif 35 endsub 36 sub postauto2 37 if islower old 38 die you may not capture your own pieces. 39 endif 40 switch moved 41 case p k 42 gosub moved origin dest 43 break 44 case q r b n t 45 set legal fn moved origin dest 46 set ep false 47 if != space dest moved 48 die you may not change the type of this piece. 49 endif 50 break 51 default 52 set legal false 53 break 54 endswitch 55 if not var legal 56 die you may not move a moved from origin to dest 57 endif 58 if sub checked #k 59 die you may not move into check. 60 endif 61 endsub 62 moveindex 0 63 MOVE: d2-d4 64 postauto1 65 moveindex 1 66 MOVE: e7-e6 67 postauto2 68 moveindex 2 69 MOVE: c2-c4 70 postauto1 71 moveindex 3 72 MOVE: c7-c6 73 postauto2 74 moveindex 4 75 MOVE: c0-c2 76 postauto1 77 moveindex 5 78 MOVE: d7-d5 79 postauto2 80 moveindex 6 81 MOVE: b2-b3 82 postauto1 83 moveindex 7 84 MOVE: g8-f6 85 postauto2 86 moveindex 8 87 MOVE: b1-c3 88 postauto1 89 moveindex 9 90 MOVE: f8-b4 91 postauto2 92 moveindex 10 93 MOVE: c1-d2 94 postauto1 95 moveindex 11 96 MOVE: d5-c4 97 postauto2 98 moveindex 12 99 MOVE: e2-e3 100 postauto1 101 moveindex 13 102 MOVE: c4-b3 103 postauto2 104 moveindex 14 105 MOVE: a2-b3 106 postauto1 107 moveindex 15 108 MOVE: b8-d9 109 postauto2 110 moveindex 16 111 MOVE: a1-a4 112 postauto1 113 moveindex 17 114 MOVE: b4-d6 115 postauto2 116 moveindex 18 117 MOVE: g1-f3 118 postauto1 119 moveindex 19 120 MOVE: e8-e9 121 postauto2 122 moveindex 20 123 MOVE: c3-e4 124 postauto1 125 moveindex 21 126 MOVE: f6-e4 127 postauto2 128 moveindex 22 129 MOVE: c2-e4 130 postauto1 131 moveindex 23 132 MOVE: d8-e7 133 postauto2 134 moveindex 24 135 MOVE: d2-c3 136 postauto1 137 moveindex 25 138 MOVE: d9-c7 139 postauto2 140 moveindex 26 141 MOVE: d4-d5 142 postauto1 143 moveindex 27 144 MOVE: f7-f5 145 postauto2 146 moveindex 28 147 MOVE: d1-d4 148 postauto1 149 moveindex 29 150 MOVE: f5-e4 151 postauto2 152 moveindex 30 153 MOVE: d4-g7 154 postauto1 155 moveindex 31 156 MOVE: h8-f8 157 postauto2 158 moveindex 32 159 MOVE: f3-g5 160 postauto1 161 moveindex 33 162 MOVE: e6-d5 163 postauto2 164 moveindex 34 165 MOVE: f2-f4 166 postauto1 167 moveindex 35 168 MOVE: c7-e6 169 postauto2 170 moveindex 36 171 MOVE: g7-h6 172 postauto1 173 moveindex 37 174 MOVE: e6-g5 175 postauto2 176 moveindex 38 177 MOVE: h6-g5 178 postauto1 179 moveindex 39 180 MOVE: e7-g5 181 postauto2 182 moveindex 40 183 MOVE: f4-g5 184 postauto1 185 moveindex 41 186 MOVE: b7-b5 187 postauto2 188 moveindex 42 189 MOVE: a4-a2 190 postauto1 191 moveindex 43 192 MOVE: c9-e7 193 postauto2 194 moveindex 44 195 MOVE: h2-h4 196 postauto1 197 moveindex 45 198 MOVE: c8-g4 199 postauto2 200 moveindex 46 201 MOVE: f0-f2 202 postauto1 203 moveindex 47 204 MOVE: d6-e5 205 postauto2 206 moveindex 48 207 MOVE: c3-a5 208 postauto1 209 moveindex 49 210 MOVE: e9-d9 211 postauto2 212 moveindex 50 213 MOVE: g2-g3 214 postauto1 215 moveindex 51 216 MOVE: f8-f2 217 postauto2 218 moveindex 52 219 MOVE: e1-f2 220 postauto1 221 moveindex 53 222 MOVE: e7-c5 223 postauto2 224 moveindex 54 225 MOVE: f1-h3 226 postauto1 227 moveindex 55 228 MOVE: a8-f8 229 postauto2 230 moveindex 56 231 MOVE: f2-e1 232 postauto1 233 moveindex 57 234 MOVE: g4-h3 235 postauto2 236 moveindex 58 237 MOVE: h1-h3 238 postauto1 239 moveindex 59 240 MOVE: c5-a5 241 postauto2 242 moveindex 60 243 MOVE: h4-h5 244 postauto1 245 moveindex 61 246 MOVE: a5-c3 247 postauto2 248 moveindex 62 249 MOVE: e1-e0 250 postauto1 251 moveindex 63 252 MOVE: f8-f3 253 postauto2 254 moveindex 64 255 MOVE: a2-c2 256 postauto1 257 moveindex 65 258 MOVE: f3-e3 259 postauto2 260 moveindex 66 261 MOVE: e0-d1 262 postauto1 263 moveindex 67 264 MOVE: e5-g3 265 postauto2 266 moveindex 68 267 MOVE: d1-c0 268 postauto1 269 moveindex 69 270 MOVE: f9-f7 271 postauto2 272 moveindex 70 273 MOVE: c2-a2 274 postauto1 275 moveindex 71 276 MOVE: f7-f5 277 postauto2 278 moveindex 72 279 MOVE: h3-h1 280 postauto1 281 moveindex 73 282 MOVE: f5-f3 283 postauto2 284 moveindex 74 285 MOVE: g5-g6 286 postauto1 287 moveindex 75 288 MOVE: e3-e0 289 postauto2 290 moveindex 76 291 MOVE: c0-b1 292 postauto1 293 moveindex 77 294 MOVE: f3-d3 295 postauto2 296 moveindex 78 297 MOVE: a2-c2 298 postauto1 299 moveindex 79 300 MOVE: d3-b3 301 MOVE: won 302 postauto2 303 if sub checked #K 304 if sub stalemated #K 305 say Checkmate! Black has won! 306 won 307 else 308 say Check! 309 endif 310 elseif sub stalemated #K 311 say Stalemate! The game is drawn. 312 drawn 313 endif 314 end 315 316 lib chess2 317 set wpr 2 318 set bpr 7 319 set fps 2 320 set pzs 1 321 set wcastle c1 g1 322 set bcastle c8 g8 323 setsystem maxmove 2 324 ban commands allmoves 325 allow moves 1 captures 1 promotions 2 326 for x piecekeys 327 if match #x P K p k 328 continue 329 elseif isupper #x 330 push wprom #x 331 elseif islower #x 332 push bprom #x 333 endif 334 next 335 def N checkleap #0 #1 1 2 336 def B checkride #0 #1 1 1 337 def R checkride #0 #1 1 0 338 def Q fn B #0 #1 or fn R #0 #1 339 def K checkleap #0 #1 1 1 or checkleap #0 #1 1 0 340 def M fn N #0 #1 or fn R #0 #1 341 def A fn N #0 #1 or fn B #0 #1 342 def n checkleap #0 #1 1 2 343 def b checkride #0 #1 1 1 344 def r checkride #0 #1 1 0 345 def q fn B #0 #1 or fn R #0 #1 346 def k checkleap #0 #1 1 1 or checkleap #0 #1 1 0 347 def m fn N #0 #1 or fn R #0 #1 348 def a fn N #0 #1 or fn B #0 #1 349 def C cond cond empty #0 capture (not empty #1) (checkhop #0 #1 0 1) (checkride #0 #1 0 1) and #1 350 def V cond cond empty #0 capture (not empty #1) (checkhop #0 #1 1 1) (checkride #0 #1 1 1) and #1 351 def c cond cond empty #0 capture (not empty #1) (checkhop #0 #1 0 1) (checkride #0 #1 0 1) and #1 352 def v cond cond empty #0 capture (not empty #1) (checkhop #0 #1 1 1) (checkride #0 #1 1 1) and #1 353 def P remove var ep and checkleap #0 #1 1 1 and == var ep join filename #1 rankname #0 or and checkride #0 #1 0 1 == rankname #0 var wpr or checkleap #0 #1 0 1 and empty #1 or and islower space #1 checkleap #0 #1 1 1 and <= distance #0 #1 var fps and > rank #1 rank #0 354 def p remove var ep and checkleap #0 #1 1 1 and == var ep join filename #1 rankname #0 or and checkride #0 #1 0 1 == rankname #0 var bpr or checkleap #0 #1 0 1 and empty #1 or and isupper space #1 checkleap #0 #1 1 1 and <= distance #0 #1 var fps and < rank #1 rank #0 355 def PL filter lambda (onboard #1) mergeall where #ori -1 1 where #ori 1 1 values lambda (where #ori 0 #1) range 1 var fps =ori 356 def pL filter lambda (onboard #1) mergeall where #ori -1 -1 where #ori 1 -1 values lambda (where #ori 0 neg #1) range 1 var fps =ori 357 setflag rules 358 def NL leaps #0 1 2 359 def BL rays #0 1 1 360 def RL rays #0 1 0 361 def VL rays #0 1 1 362 def CL rays #0 1 0 363 def QL merge rays #0 1 0 rays #0 1 1 364 def KL merge leaps #0 1 0 leaps #0 1 1 365 def AL merge leaps #0 1 2 rays #0 1 1 366 def ML merge rays #0 1 0 leaps #0 1 2 367 def nL leaps #0 1 2 368 def bL rays #0 1 1 369 def rL rays #0 1 0 370 def vL rays #0 1 1 371 def cL rays #0 1 0 372 def qL merge rays #0 1 0 rays #0 1 1 373 def kL merge leaps #0 1 0 leaps #0 1 1 374 def aL merge leaps #0 1 2 rays #0 1 1 375 def mL merge rays #0 1 0 leaps #0 1 2 376 sub checked king 377 my from piece 378 if isupper cond empty #king moved space #king 379 def enemies onlylower 380 else 381 def enemies onlyupper 382 endif 383 for (from piece) fn enemies 384 if fn #piece #from #king 385 return #from 386 endif 387 next 388 return false 389 endsub 390 sub P from to 391 local ydir 392 if == file #from file #to and not capture 393 set legal checkaleap #from #to 0 1 394 if var legal 395 set ep false 396 else 397 set legal checkaride #from #to 0 1 and <= distance #from #to #fps and == rankname #from #wpr 398 set ep #to 399 endif 400 set epc false 401 elseif capture or #ep 402 set legal checkaleap #from #to -1 1 or checkaleap #from #to 1 1 403 set epc false 404 if not capture and var legal 405 set legal > rank #to rank #ep and < rankname #to #bpr and == file #to file #ep 406 if var legal 407 capture #ep 408 set epc #ep 409 endif 410 endif 411 set ep false 412 endif 413 if != space #to moved and onboard where #to 0 #pzs 414 die "You may not promote a Pawn until it reaches the promotion zone." 415 endif 416 if not onboard where #to 0 #pzs 417 if == P space #to 418 askpromote #wprom 419 elseif not match space #to var wprom 420 set np space #to 421 die "You may not promote your Pawn to a" #np 422 endif 423 endif 424 return true 425 endsub 426 sub p from to 427 if == file #from file #to and not capture 428 set legal checkaleap #from #to 0 -1 429 if var legal 430 set ep false 431 else 432 set legal checkaride #from #to 0 -1 and <= distance #from #to #fps and == rankname #from #bpr 433 set ep #to 434 endif 435 set epc false 436 elseif capture or #ep 437 set legal checkaleap #from #to -1 -1 or checkaleap #from #to 1 -1 438 set epc false 439 if not capture and var legal 440 set legal < rank #to rank #ep and > rankname #to #wpr and == file #to file #ep 441 if var legal 442 capture #ep 443 set epc #ep 444 endif 445 endif 446 set ep false 447 endif 448 if != space #to moved and onboard where #to 0 neg #pzs 449 die You may not promote a Pawn until it reaches the promotion zone. 450 endif 451 if not onboard where #to 0 neg #pzs 452 if == p space #to 453 askpromote #bprom 454 elseif not match space #to var bprom 455 set np space #to 456 die You may not promote your Pawn to a #np 457 endif 458 endif 459 return true 460 endsub 461 sub K from to 462 set legal fn K #from #to 463 if match #to where #from 2 0 where #from -2 0 464 set legal sub castle 465 endif 466 set K #to 467 unsetflag #from 468 endsub 469 sub k from to 470 set legal fn K #from #to 471 if match #to where #from 2 0 where #from -2 0 472 set legal sub castle 473 endif 474 set k #to 475 unsetflag #from 476 endsub 477 sub castle 478 local c RPOS RDEST xdir 479 if not flag #from 480 die A King may not castle after it moves. 481 endif 482 if capture 483 die A King may not castle to an occupied space. 484 endif 485 set xdir sign minus file #to file #from 486 if not checkaride #from #to #xdir 0 487 die A King may not castle across any occupied space. 488 endif 489 set c #to 490 do 491 set c where #c #xdir 0 492 if flag #c 493 break 494 elseif not onboard #c 495 die No piece was found to castle with. 496 elseif not empty #c 497 die The King cannot castle with the piece at #c 498 endif 499 loop 500 set RPOS #c 501 move #to #from 502 if sub checked #from 503 die A King may not castle out of check. 504 endif 505 store 506 for c path #from #to 507 move #from #c 508 if sub checked #c 509 die A King may not castle through check. 510 endif 511 restore 512 next 513 move #from #to 514 if == count var subargs 0 515 set RDEST where #to neg #xdir 0 516 else 517 set RDEST elem 0 subargs 518 endif 519 unsetflag #RPOS 520 move #RPOS #RDEST 521 return true 522 endsub 523 sub castlepos from to 524 local c RPOS RDEST xdir safe 525 verify flag #from 526 verify empty #to 527 set xdir sign minus file #to file #from 528 verify checkaride #from #to #xdir 0 529 verify not sub checked #from 530 set c #to 531 do 532 set c where #c #xdir 0 533 if flag #c 534 break 535 endif 536 verify onboard #c 537 verify empty #c 538 loop 539 verify flag #c 540 set RPOS #c 541 store 542 for c path #from #to 543 move #from #c 544 set safe not sub checked #c 545 restore 546 verify #safe 547 next 548 move #from #to 549 set RDEST where #to neg #xdir 0 550 move #RPOS #RDEST 551 return true 552 endsub 553 sub stalemated kingpos 554 store 555 local from piece to 556 if isupper space #kingpos 557 def friends onlyupper 558 def nofriends noupper 559 def friend isupper #0 560 set cspaces var wcastle 561 else 562 def friends onlylower 563 def nofriends nolower 564 def friend islower #0 565 set cspaces var bcastle 566 endif 567 set royal space var kingpos 568 store 569 for (from piece) fn friends 570 for to fn join #piece L #from 571 if fn #piece #from #to and not fn friend space #to and onboard #to 572 move #from #to 573 if not sub checked cond == #from #kingpos #to #kingpos 574 setlegal #from #to 575 endif 576 endif 577 restore 578 next 579 next 580 for to var cspaces 581 if sub castlepos #kingpos #to 582 if not sub checked #to 583 setlegal #kingpos #to 584 endif 585 endif 586 restore 587 next 588 return cond count system legalmoves false true 589 endsub 590 sub enpassant piece from to 591 local pe 592 verify not capture and #ep 593 verify == P toupper #piece 594 set pe join filename #to rankname #from 595 verify == #ep #pe 596 capture #ep 597 endsub 598 endlib