25

BANNED INPUT: resigns on turn 13:

There is a global ban on commands in user input, and no exception has been made for the resigns 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 include chess
   1 set wcastle c0 h0
   2 set bcastle c9 h9
   3 set K findpiece K spaces
   4 set k findpiece k spaces
   5 set ep false
   6 setflag b0 f0 i0 b9 f9 i9
   7 set names assoc p "Black Pawn" P "White Pawn" n "Black Knight" N "White Knight" b "Black Bishop" B "White Bishop" w "Black Wizard" W "White Wizard" s "Black Champion" S "White Champion" r "Black Rook" R "White Rook" q "Black Queen" Q "White Queen" k "Black King" K "White King"
   8 set fps 3
   9 set wpr 1
  10 set bpr 8
  11 alias c s C S w1 !x!1 w2 !y!1 w3 !y!2 w4 !x!2
  12 def s checkleap #0 #1 0 1 or checkleap #0 #1 0 2 or checkleap #0 #1 2 2
  13 def S checkleap #0 #1 0 1 or checkleap #0 #1 0 2 or checkleap #0 #1 2 2
  14 def w checkleap #0 #1 1 1 or checkleap #0 #1 1 3
  15 def W checkleap #0 #1 1 1 or checkleap #0 #1 1 3
  16 def CAMEL check what #0 1 3 check what #0 -1 3 check what #0 1 -3 check what #0 -1 -3 check what #0 3 1 check what #0 -3 1 check what #0 3 -1 check what #0 -3 -1 target #1
  17 def DABBABAH check what #0 0 -2 check what #0 -2 0 check what #0 0 2 check what #0 2 0 target #1
  18 def ALFIL check what #0 -2 -2 check what #0 -2 2 check what #0 2 -2 check what #0 2 2 target #1
  19 def ATTACKEDBYB fn CAMEL #0 w or fn ALFIL #0 s or fn DABBABAH #0 s or fn WAZIR #0 (k s) or fn FERZ #0 (k w) or fn BPAWN #0 or fn KNIGHT #0 n or fn ROOK #0 (r q) or fn BISHOP #0 (b q)
  20 def ATTACKEDBYW fn CAMEL #0 W or fn ALFIL #0 S or fn DABBABAH #0 S or fn WAZIR #0 (K S) or fn FERZ #0 (K W) or fn WPAWN #0 or fn KNIGHT #0 N or fn ROOK #0 (R Q) or fn BISHOP #0 (B Q)
  21 def PL array where #0 0 3 where #0 0 2 where #0 0 1 where #0 -1 1 where #0 1 1
  22 def pL array where #0 0 -3 where #0 0 -2 where #0 0 -1 where #0 -1 -1 where #0 1 -1
  23 def SL merge merge leaps #0 0 1 leaps #0 0 2 leaps #0 2 2
  24 def WL merge leaps #0 1 1 leaps #0 1 3
  25 def sL merge merge leaps #0 0 1 leaps #0 0 2 leaps #0 2 2
  26 def wL merge leaps #0 1 1 leaps #0 1 3
  27 sub postauto1
  28   if isupper old
  29     die You may not capture your own pieces.
  30   endif
  31   if == moved P
  32     set nopvc 0
  33   else
  34     set ep false
  35     if capture
  36       set nopvc 0
  37     else
  38       inc nopvc
  39     endif
  40     if unequal space dest moved
  41       die You may not change the type of this piece.
  42     endif
  43   endif
  44   set legal false
  45   if match moved P K
  46     gosub moved origin dest
  47     if equal moved K
  48       set K dest
  49     endif
  50   elseif match moved Q R B N S W
  51     set legal fn moved origin dest
  52     if == moved R
  53       unsetflag origin
  54     else
  55       unsetflag dest
  56     endif
  57   endif
  58   if not var legal
  59     set ori alias origin
  60     set dst alias dest
  61     set name elem moved names
  62     die You may not move a #name from #ori to #dst
  63   endif
  64   if fn ATTACKEDBYB #K
  65     die You may not move into check.
  66   endif
  67   set posvar join "w" join fencode boardflags
  68   inc #posvar
  69 endsub
  70 sub postauto2
  71   if islower old
  72     die You may not capture your own pieces.
  73   endif
  74   if == moved p
  75     set nopvc 0
  76   else
  77     set ep false
  78     if capture
  79       set nopvc 0
  80     else
  81       inc nopvc
  82     endif
  83     if unequal space dest moved
  84       die You may not change the type of this piece.
  85     endif
  86   endif
  87   set legal false
  88   if match moved p k
  89     gosub moved origin dest
  90     if equal moved k
  91       set k dest
  92     endif
  93   elseif match moved q r b n s w
  94     set legal fn toupper moved origin dest
  95     if == moved r
  96       unsetflag origin
  97     else
  98       unsetflag dest
  99     endif
 100   endif
 101   if not var legal
 102     set ori alias origin
 103     set dst alias dest
 104     set name elem moved names
 105     die You may not move a #name from #ori to #dst
 106   endif
 107   if fn ATTACKEDBYW #k
 108     die You may not move into check.
 109   endif
 110   set posvar join "b" join fencode boardflags
 111   inc #posvar
 112 endsub
 113 moveindex 0
 114 MOVE: f1-f4
 115 postauto1
 116 moveindex 1
 117 MOVE: f8-f5
 118 postauto2
 119 moveindex 2
 120 MOVE: e1-e3
 121 postauto1
 122 moveindex 3
 123 MOVE: h9-g7
 124 postauto2
 125 moveindex 4
 126 MOVE: a0-c2
 127 postauto1
 128 moveindex 5
 129 MOVE: g9-d6
 130 postauto2
 131 moveindex 6
 132 MOVE: j0-h2
 133 postauto1
 134 moveindex 7
 135 MOVE: f9-h9
 136 postauto2
 137 moveindex 8
 138 MOVE: h0-g2
 139 postauto1
 140 moveindex 9
 141 MOVE: c9-d7
 142 postauto2
 143 moveindex 10
 144 MOVE: c0-d2
 145 postauto1
 146 moveindex 11
 147 MOVE: e8-e5
 148 postauto2
 149 moveindex 12
 150 MOVE: d0-g3
 151 postauto1
 152 moveindex 13
 153 MOVE: e5-e4
 154 postauto2
 155 moveindex 14
 156 MOVE: h2-h4
 157 postauto1
 158 moveindex 15
 159 MOVE: w3-j7
 160 postauto2
 161 moveindex 16
 162 MOVE: w2-j2
 163 postauto1
 164 moveindex 17
 165 MOVE: g7-i6
 166 postauto2
 167 moveindex 18
 168 MOVE: h4-f2
 169 postauto1
 170 moveindex 19
 171 MOVE: g8-g5
 172 postauto2
 173 moveindex 20
 174 MOVE: j2-i3
 175 postauto1
 176 moveindex 21
 177 MOVE: g5-f4
 178 postauto2
 179 moveindex 22
 180 MOVE: g0-c4
 181 postauto1
 182 moveindex 23
 183 MOVE: h9-i9
 184 postauto2
 185 moveindex 24
 186 MOVE: i3-j6
 187 postauto1
 188 moveindex 25
 189 MOVE: resigns
 190 postauto2
 191 set posvar join "b" join fencode boardflags
 192 if >= var #posvar 3
 193   say Three Times Repetition! Drawn Game!
 194   drawn
 195 endif
 196 set checks sub checks #K
 197 if var checks
 198   if sub checkmated #K #checks
 199     say Checkmate! Black has won!
 200     won
 201   else
 202     say Check!
 203   endif
 204 elseif sub stalemated #K
 205   say Stalemate! The game is drawn.
 206   drawn
 207 endif
 208 if >= #nopvc 100
 209   say Fifty Moves Without Moving a Pawn or Capturing! Game Drawn!
 210   drawn
 211 endif
 212 end
 213 
 214 lib chess
 215 set wpr 2
 216 set bpr 7
 217 set fps 2
 218 set pzs 1
 219 set wcastle c1 g1
 220 set bcastle c8 g8
 221 do
 222   local x
 223   for x piecekeys
 224     if match #x P K p k
 225       continue
 226     elseif isupper #x
 227       push wprom #x
 228     elseif islower #x
 229       push bprom #x
 230     endif
 231   next
 232 loop never
 233 setsystem maxmove 2
 234 ban commands allmoves
 235 allow moves 1 captures 1 promotions 2
 236 def N checkleap #0 #1 1 2
 237 def B checkride #0 #1 1 1
 238 def R checkride #0 #1 1 0
 239 def Q fn B #0 #1 or fn R #0 #1
 240 def K checkleap #0 #1 1 1 or checkleap #0 #1 1 0
 241 def M fn N #0 #1 or fn R #0 #1
 242 def A fn N #0 #1 or fn B #0 #1
 243 def n checkleap #0 #1 1 2
 244 def b checkride #0 #1 1 1
 245 def r checkride #0 #1 1 0
 246 def q fn b #0 #1 or fn r #0 #1
 247 def k checkleap #0 #1 1 1 or checkleap #0 #1 1 0
 248 def m fn n #0 #1 or fn r #0 #1
 249 def a fn n #0 #1 or fn b #0 #1
 250 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
 251 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
 252 sub capturep p
 253   empty #p
 254   return true
 255 endsub
 256 sub checks king
 257   if not dest
 258     return false
 259   endif
 260   my checks c
 261   set checks ()
 262   if fn space dest dest #king
 263     setelem checks dest space dest
 264   endif
 265   set c sub checkedthru #king origin
 266   if #c
 267     setelem checks #c space #c
 268   elseif #epc
 269     set c sub checkedthru #king #epc
 270     if #c
 271       setelem checks #c space #c
 272     endif
 273   endif
 274   return var checks
 275 endsub
 276 sub checkmated king checks
 277   local from piece to key legalmove piece nopawn
 278   store
 279   if isupper space #king
 280     def friends onlyupper
 281     def friend isupper #0
 282     set attacked ATTACKEDBYB
 283   else
 284     def friends onlylower
 285     def friend islower #0
 286     set attacked ATTACKEDBYW
 287   endif
 288   set kingmoves fn KL #king
 289   for to #kingmoves
 290     if not fn friend space #to and onboard #to
 291       move #king #to
 292       set incheck fn var attacked #to
 293       restore
 294       if not #incheck
 295         setlegal #king #to
 296       endif
 297     endif
 298   next
 299   if == count var checks 1
 300     for (key enemy) var checks
 301       set possible path #king #key
 302       push possible #key
 303       if == #key #ep
 304         push possible cond isupper space #ep where #ep 0 -1 where #ep 0 1
 305       endif
 306       for (from piece) fn friends
 307         if == #from #king
 308           continue
 309         endif
 310         for to #possible
 311           if fn #piece #from #to
 312             move #from #to
 313             set incheck fn var attacked #king
 314             if not #incheck
 315               setlegal #from #to
 316             endif
 317           endif
 318           restore
 319         next
 320       next
 321     next
 322   endif
 323   return cond count system legalmoves false true and checks
 324 endsub
 325 def PL array where #0 0 2 where #0 0 1 where #0 -1 1 where #0 1 1
 326 def pL array where #0 0 -2 where #0 0 -1 where #0 -1 -1 where #0 1 -1
 327 def NL leaps #0 1 2
 328 def BL rays #0 1 1
 329 def RL rays #0 1 0
 330 def VL rays #0 1 1
 331 def CL rays #0 1 0
 332 def QL merge rays #0 1 0 rays #0 1 1
 333 def KL merge leaps #0 1 0 leaps #0 1 1
 334 def AL merge leaps #0 1 2 rays #0 1 1
 335 def ML merge rays #0 1 0 leaps #0 1 2
 336 def nL leaps #0 1 2
 337 def bL rays #0 1 1
 338 def rL rays #0 1 0
 339 def vL rays #0 1 1
 340 def cL rays #0 1 0
 341 def qL merge rays #0 1 0 rays #0 1 1
 342 def kL merge leaps #0 1 0 leaps #0 1 1
 343 def aL merge leaps #0 1 2 rays #0 1 1
 344 def mL merge rays #0 1 0 leaps #0 1 2
 345 sub castlepos from to
 346   local c RPOS RDEST xdir safe
 347   verify flag #from
 348   verify empty #to
 349   if isupper space #king
 350     def friend isupper #0
 351     def friends onlyupper
 352     set attacked ATTACKEDBYB
 353   else
 354     def friend islower #0
 355     def friends onlylower
 356     set attacked ATTACKEDBYW
 357   endif
 358   set xdir sign minus file #to file #from
 359   verify checkaride #from #to #xdir 0
 360   verify not fn var attacked #from
 361   set c #to
 362   do
 363     set c where #c #xdir 0
 364     if flag #c
 365       break
 366     endif
 367     verify onboard #c
 368     verify empty #c
 369   loop
 370   verify flag #c
 371   set RPOS #c
 372   store
 373   for c path #from #to
 374     move #from #c
 375     set safe not fn var attacked #c
 376     restore
 377     verify #safe
 378   next
 379   move #from #to
 380   set RDEST where #to neg #xdir 0
 381   move #RPOS #RDEST
 382   return true
 383 endsub
 384 sub stalemated king
 385   local legalmove temp from piece to attacked ra
 386   if isupper space #king
 387     def friend isupper #0
 388     def friends onlyupper
 389     set attacked ATTACKEDBYB
 390     set cspaces var wcastle
 391   else
 392     def friend islower #0
 393     def friends onlylower
 394     set attacked ATTACKEDBYW
 395     set cspaces var bcastle
 396   endif
 397   store
 398   set kingmoves fn KL #king
 399   for to #kingmoves
 400     if not fn friend space #to and onboard #to
 401       move #king #to
 402       set incheck fn var attacked #to
 403       restore
 404       if not #incheck
 405         setlegal #king #to
 406       endif
 407     endif
 408   next
 409   for to var cspaces
 410     if sub castlepos #king #to
 411       set incheck fn var attacked #to
 412       restore
 413       if not #incheck
 414         setlegal #king #to
 415       endif
 416     endif
 417   next
 418   restore
 419   for (from piece) fn friends
 420     if == #from #king
 421       continue
 422     endif
 423     for to fn join #piece L #from
 424       if fn #piece #from #to and not fn friend space #to and onboard #to
 425         move #from #to
 426         set incheck fn var attacked #king
 427         if not #incheck
 428           setlegal #from #to
 429         endif
 430       endif
 431       restore
 432     next
 433   next
 434   return cond count system legalmoves false true
 435 endsub
 436 def WPAWN match P what #0 1 -1 what #0 -1 -1
 437 def BPAWN match p what #0 1 1 what #0 -1 1
 438 def KNIGHT check what #0 1 2 check what #0 -1 2 check what #0 1 -2 check what #0 -1 -2 check what #0 2 1 check what #0 -2 1 check what #0 2 -1 check what #0 -2 -1 target #1
 439 def WAZIR check what #0 0 -1 check what #0 -1 0 check what #0 0 1 check what #0 1 0 target #1
 440 def FERZ check what #0 -1 -1 check what #0 -1 1 check what #0 1 -1 check what #0 1 1 target #1
 441 def KING fn WAZIR #0 #1 or fn FERZ #0 #1
 442 def ROOK check insight #0 0 -1 check insight #0 -1 0 check insight #0 0 1 check insight #0 1 0 target #1
 443 def BISHOP check insight #0 -1 -1 check insight #0 -1 1 check insight #0 1 -1 check insight #0 1 1 target #1
 444 def ATTACKEDBYB fn KING #0 k or fn BPAWN #0 or fn KNIGHT #0 (n a m) or fn ROOK #0 (r q m) or fn BISHOP #0 (b q a)
 445 def ATTACKEDBYW fn KING #0 K or fn WPAWN #0 or fn KNIGHT #0 (N A M) or fn ROOK #0 (R Q M) or fn BISHOP #0 (B Q A)
 446 sub P from to
 447   local ydir
 448   if == file #from file #to and not capture
 449     set legal checkaleap #from #to 0 1
 450     if var legal
 451       set ep false
 452     else
 453       set legal checkaride #from #to 0 1 and <= distance #from #to #fps and or == rankname #from #wpr < #wpr 0
 454       set ep #to
 455     endif
 456     set epc false
 457   elseif capture or #ep
 458     set legal checkaleap #from #to -1 1 or checkaleap #from #to 1 1
 459     set epc false
 460     if not capture and var legal
 461       set legal > rank #to rank #ep and < rankname #to #bpr and == file #to file #ep
 462       if var legal
 463         capture #ep
 464         set epc #ep
 465       endif
 466     endif
 467     set ep false
 468   endif
 469   if != space #to moved and onboard where #to 0 #pzs
 470     die "You may not promote a Pawn until it reaches the promotion zone."
 471   endif
 472   if not onboard where #to 0 1
 473     if == P space #to
 474       askpromote #wprom
 475     elseif not match space #to var wprom
 476       set np space #to
 477       die "You may not promote your Pawn to a" #np
 478     endif
 479   endif
 480 endsub
 481 sub p from to
 482   if == file #from file #to and not capture
 483     set legal checkaleap #from #to 0 -1
 484     if var legal
 485       set ep false
 486     else
 487       set legal checkaride #from #to 0 -1 and <= distance #from #to #fps and or == rankname #from #bpr > #bpr lastrank
 488       set ep #to
 489     endif
 490     set epc false
 491   elseif capture or #ep
 492     set legal checkaleap #from #to -1 -1 or checkaleap #from #to 1 -1
 493     set epc false
 494     if not capture and var legal
 495       set legal < rank #to rank #ep and > rankname #to #wpr and == file #to file #ep
 496       if var legal
 497         capture #ep
 498         set epc #ep
 499       endif
 500     endif
 501     set ep false
 502   endif
 503   if != space #to moved and onboard where #to 0 neg #pzs
 504     die You may not promote a Pawn until it reaches the promotion zone.
 505   endif
 506   if not onboard where #to 0 -1
 507     if == p space #to
 508       askpromote #bprom
 509     elseif not match space #to var bprom
 510       set np space #to
 511       die You may not promote your Pawn to a #np
 512     endif
 513   endif
 514 endsub
 515 sub K from to
 516   if match #to var wcastle and flag #from
 517     set legal sub castle
 518   else
 519     set legal fn K #from #to
 520   endif
 521   set K #to
 522   unsetflag e1
 523 endsub
 524 sub k from to
 525   if match #to var bcastle and flag #from
 526     set legal sub castle
 527   else
 528     set legal fn k #from #to
 529   endif
 530   set k #to
 531   unsetflag e8
 532 endsub
 533 sub castle
 534   local ATTACKED c RPOS RDEST xdir
 535   if not flag #from
 536     die A King may not castle after it moves.
 537   endif
 538   if capture
 539     die A King may not castle to an occupied space.
 540   endif
 541   set xdir sign minus file #to file #from
 542   if not checkaride #from #to #xdir 0
 543     die A King may not castle across any occupied space.
 544   endif
 545   set c #to
 546   do
 547     set c where #c #xdir 0
 548     if flag #c
 549       break
 550     elseif not onboard #c
 551       die No piece was found to castle with.
 552     elseif not empty #c
 553       die The King cannot castle with the piece at #c
 554     endif
 555   loop
 556   set RPOS #c
 557   set ATTACKED ATTACKEDBYW unless isupper moved ATTACKEDBYB
 558   if fn var ATTACKED #from
 559     die A King may not castle out of check.
 560   endif
 561   for c path #from #to
 562     if fn var ATTACKED #c
 563       die A King may not castle through check.
 564     endif
 565   next
 566   if == count var subargs 0
 567     set RDEST where #to neg #xdir 0
 568   else
 569     set RDEST elem 0 subarg
 570   endif
 571   unsetflag #RPOS
 572   move #RPOS #RDEST
 573   return true
 574 endsub
 575 sub checkedthru king loc
 576   my dir c
 577   set c revealed #king #loc
 578   verify fn space #c #c #king and not samecase space #king space #c and onboard #c and #c
 579   return #c
 580 endsub
 581 def fn checkedfrom fn space #1 #0 and xor isupper space #0 isupper space #1 and not empty #1
 582 sub P1 from to
 583   if == file #from file #to
 584     return not capture
 585   elseif capture
 586     return true
 587   elseif == file #to file #ep and == rank #from rank #ep and #ep
 588     capture #ep
 589     return true
 590   endif
 591   return false
 592 endsub
 593 sub PP from to
 594   if checkatwostep #from #to 0 1 0 1 or checkaleap #from #to 0 1
 595     return empty #to
 596   elseif not checkaleap #from #to 1 1 and not checkaleap #from #to -1 1
 597     return false
 598   elseif not empty #to
 599     return true
 600   elseif == file #to file #ep and == rank #from rank #ep and #ep
 601     capture #ep
 602     return true
 603   endif
 604   return false
 605 endsub
 606 sub pp from to
 607   if checkatwostep #from #to 0 -1 0 -1 or checkaleap #from #to 0 -1
 608     return empty #to
 609   elseif not checkaleap #from #to 1 -1 and not checkaleap #from #to -1 -1
 610     return false
 611   elseif not empty #to
 612     return true
 613   elseif == file #to file #ep and == rank #from rank #ep and #ep
 614     capture #ep
 615     return true
 616   endif
 617   return false
 618 endsub
 619 endlib