This preset will spot check, checkmate, and stalemate.

1

BANNED INPUT: pass on turn 1:

There is a global ban on commands in user input, and no exception has been made for the pass 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 set G findpiece G spaces
   1 set g findpiece g spaces
   2 include xiangqi
   3 unsetflag d1 e1 f1 d2 e2 f2 e3 d3 f3 d8 e8 f8 d9 e9 f9 d10 e10 f10
   4 setflag e1 f1 d2 e2 f2 d3 e3 e9 f9 d10 e10 f10 d11 e11
   5 echo This preset will spot check, checkmate, and stalemate.
   6 def N checkatwostep #0 #1 0 1 1 1 or checkatwostep #0 #1 0 1 -1 2 or checkatwostep #0 #1 1 0 1 1 or checkatwostep #0 #1 1 0 2 -1 or checkatwostep #0 #1 1 -1 2 -1 or checkatwostep #0 #1 1 -1 1 -2 or checkatwostep #0 #1 0 -1 1 -2 or checkatwostep #0 #1 0 -1 -1 -1 or checkatwostep #0 #1 -1 0 -1 -1 or checkatwostep #0 #1 -1 0 -2 1 or checkatwostep #0 #1 -1 1 -2 1 or checkatwostep #0 #1 -1 1 -1 2
   7 def P checkaleap #0 #1 -2 1 or checkaleap #0 #1 2 -1 or checkaleap #0 #1 -1 1 or checkaleap #0 #1 1 0 and >= + rank #1 >> file #1 1 7 or checkaleap #0 #1 0 1
   8 def R checkaride #0 #1 1 -1 or checkaride #0 #1 -1 1 or checkride #0 #1 0 1
   9 def C cond cond empty #0 capture (not empty #1) (checkahop #0 #1 1 -1 or checkahop #0 #1 -1 1 or checkhop #0 #1 0 1) (checkaride #0 #1 1 -1 or checkaride #0 #1 -1 1 or checkride #0 #1 0 1) and #1
  10 def G checkride #0 #1 1 0 and == #G #1 or eval (checkaleap #0 #1 1 -1 or checkaleap #0 #1 -1 1 or checkleap #0 #1 0 1) and flag #1
  11 def F eval (checkaleap #0 #1 1 1 or checkaleap #0 #1 -1 -1 or checkaleap #0 #1 -1 2 or checkaleap #0 #1 1 -2 or checkaleap #0 #1 -2 1 or checkaleap #0 #1 2 -1) and flag #1 and #0
  12 def E eval (checkatwostep #0 #1 1 1 1 1 or checkatwostep #0 #1 -1 -1 -1 -1 or checkatwostep #0 #1 2 -1 2 -1 or checkatwostep #0 #1 -2 1 -2 1 or checkatwostep #0 #1 1 -2 1 -2 or checkatwostep #0 #1 -1 2 -1 2) and <= + rank #1 >> + file #1 1 1 7 and #0
  13 def n checkatwostep #0 #1 0 1 1 1 or checkatwostep #0 #1 0 1 -1 2 or checkatwostep #0 #1 1 0 1 1 or checkatwostep #0 #1 1 0 2 -1 or checkatwostep #0 #1 1 -1 2 -1 or checkatwostep #0 #1 1 -1 1 -2 or checkatwostep #0 #1 0 -1 1 -2 or checkatwostep #0 #1 0 -1 -1 -1 or checkatwostep #0 #1 -1 0 -1 -1 or checkatwostep #0 #1 -1 0 -2 1 or checkatwostep #0 #1 -1 1 -2 1 or checkatwostep #0 #1 -1 1 -1 2
  14 def p checkaleap #0 #1 -2 1 or checkaleap #0 #1 2 -1 or checkaleap #0 #1 1 -1 or checkaleap #0 #1 -1 0 and <= + rank #1 >> + file #1 1 1 7 or checkaleap #0 #1 0 -1
  15 def r checkaride #0 #1 1 -1 or checkaride #0 #1 -1 1 or checkride #0 #1 0 1
  16 def c cond cond empty #0 capture (not empty #1) (checkahop #0 #1 1 -1 or checkahop #0 #1 -1 1 or checkhop #0 #1 0 1) (checkaride #0 #1 1 -1 or checkaride #0 #1 -1 1 or checkride #0 #1 0 1) and #1
  17 def g checkride #0 #1 1 0 and == #G #1 or eval (checkaleap #0 #1 1 -1 or checkaleap #0 #1 -1 1 or checkleap #0 #1 0 1) and flag #1
  18 def e eval (checkatwostep #0 #1 1 1 1 1 or checkatwostep #0 #1 -1 -1 -1 -1 or checkatwostep #0 #1 2 -1 2 -1 or checkatwostep #0 #1 -2 1 -2 1 or checkatwostep #0 #1 1 -2 1 -2 or checkatwostep #0 #1 -1 2 -1 2) and >= + rank #1 >> file #1 1 7 and #0
  19 def f eval (checkaleap #0 #1 1 1 or checkaleap #0 #1 -1 -1 or checkaleap #0 #1 -1 2 or checkaleap #0 #1 1 -2 or checkaleap #0 #1 -2 1 or checkaleap #0 #1 2 -1) and flag #1 and #0
  20 def PL merge leaps #0 1 0 array where #0 -2 1 where #0 2 -1 where #0 -1 1 where #0 1 -1
  21 def EL array where #0 2 2 where #0 -2 -2 where #0 4 -2 where #0 -4 2 where #0 2 -4 where #0 -2 4
  22 def RL merge merge ray #0 1 -1 ray #0 -1 1 rays #0 0 1
  23 def CL merge merge ray #0 1 -1 ray #0 -1 1 rays #0 0 1
  24 def GL merge leaps #0 1 0 array where #0 1 -1 where #0 -1 1 cond == #0 var g var G var g
  25 def FL array where #0 1 1 where #0 -1 -1 where #0 2 -1 where #0 -2 1 where #0 1 -2 where #0 -1 2
  26 def NL array where #0 1 2 where #0 -1 3 where #0 2 1 where #0 3 -1 where #0 3 -2 where #0 2 -3 where #0 1 -3 where #0 -1 -2 where #0 -2 -1 where #0 -3 1 where #0 -3 2 where #0 -2 3
  27 sub postauto1
  28   if isupper old
  29     die You may not capture your own pieces.
  30   endif
  31   if not fn moved origin dest
  32     die You may not move a moved from origin to dest
  33   endif
  34   if == moved G
  35     set G dest
  36   endif
  37   if sub checked #G
  38     die You may not move your General into check
  39   endif
  40 endsub
  41 sub postauto2
  42   if islower old
  43     die You may not capture your own pieces.
  44   endif
  45   if not fn moved origin dest
  46     die You may not move a moved from origin to dest
  47   endif
  48   if == moved g
  49     set g dest
  50   endif
  51   if sub checked #g
  52     die You may not move your General into check
  53   endif
  54 endsub
  55 moveindex 0
  56 MOVE: P e4-e5
  57 postauto1
  58 moveindex 1
  59 MOVE: pass
  60 postauto2
  61 if sub stalemated #G
  62   if sub checked #G
  63     say Checkmate! Blue has won!
  64   else
  65     say Stalemate! Blue has won!
  66   endif
  67   won
  68 elseif sub checked #G
  69   say Check!
  70 endif
  71 end
  72 
  73 lib xiangqi
  74 setsystem maxmove 1
  75 ban commands allmoves
  76 allow moves 1 captures 1
  77 setflag d1 e1 f1 d2 e2 f2 e3 d3 f3 d8 e8 f8 d9 e9 f9 d10 e10 f10
  78 def N checktwostep #0 #1 0 1 1 1
  79 def P checkaleap #0 #1 -1 0 or checkaleap #0 #1 1 0 and > rank #0 4 or checkaleap #0 #1 0 1
  80 def R checkride #0 #1 0 1
  81 def E checktwostep #0 #1 1 1 1 1 and < rank #1 5
  82 def C cond cond empty #0 capture (not empty #1) (checkhop #0 #1 0 1) (checkride #0 #1 0 1) and #1
  83 def G checkride #0 #1 1 0 and == space #1 g or checkleap #0 #1 0 1 and flag #1
  84 def F checkleap #0 #1 1 1 and flag #1
  85 def n checktwostep #0 #1 0 1 1 1
  86 def p checkaleap #0 #1 -1 0 or checkaleap #0 #1 1 0 and < rank #0 5 or checkaleap #0 #1 0 -1
  87 def r checkride #0 #1 0 1
  88 def e checktwostep #0 #1 1 1 1 1 and > rank #1 4
  89 def c cond cond empty #0 capture (not empty #1) (checkhop #0 #1 0 1) (checkride #0 #1 0 1) and #1
  90 def g checkride #0 #1 1 0 and == space #1 G or checkleap #0 #1 0 1 and flag #1
  91 def f checkleap #0 #1 1 1 and flag #1
  92 sub checked general
  93   local piece from
  94   if isupper space #general
  95     def enemies onlylower
  96   else
  97     def enemies onlyupper
  98   endif
  99   for (from piece) fn enemies
 100     if fn #piece #from #general
 101       return true
 102     endif
 103   next
 104   return false
 105 endsub
 106 sub stalemated kingpos
 107   store
 108   local from piece to key lglmvs
 109   set lglmvs ()
 110   if isupper space #kingpos
 111     def friends onlyupper
 112     def nofriends noupper
 113     def friend isupper #0
 114   else
 115     def friends onlylower
 116     def nofriends nolower
 117     def friend islower #0
 118   endif
 119   set royal space var kingpos
 120   store
 121   for to fn join #royal L #kingpos
 122     if fn #royal #kingpos #to and not fn friend space #to and onboard #to
 123       move #kingpos #to
 124       set incheck sub checked #to
 125       restore
 126       if not #incheck
 127         setlegal #kingpos #to
 128       endif
 129     endif
 130   next
 131   restore
 132   for (from piece) fn friends
 133     if == #from #kingpos
 134       continue
 135     endif
 136     for to fn join #piece L #from
 137       if fn #piece #from #to and not fn friend space #to and onboard #to
 138         move #from #to
 139         set incheck sub checked #kingpos
 140         restore
 141         if not #incheck
 142           setlegal #from #to
 143         endif
 144       endif
 145     next
 146   next
 147   return cond count system legalmoves false true
 148 endsub
 149 def PL leaps #0 1 0
 150 def EL leaps #0 2 2
 151 def RL rays #0 1 0
 152 def CL rays #0 1 0
 153 def GL merge leaps #0 1 0 (#g #G)
 154 def FL leaps #0 1 1
 155 def NL leaps #0 1 2
 156 def pL leaps #0 -1 0
 157 def eL leaps #0 2 2
 158 def rL rays #0 1 0
 159 def cL rays #0 1 0
 160 def gL merge leaps #0 1 0 (#G #g)
 161 def fL leaps #0 1 1
 162 def nL leaps #0 1 2
 163 endlib