This preset for Euchess enforces rules and spots check, checkmate, and stalemate.

31

BANNED INPUT: K f2-h2; R i2-g2 on turn 16:

MOVE: R i2-g2 and other moves from one space to another are banned here.

Go back and try again.

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

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

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