This preset has now been updated to spot check, checkmate, and stalemate.
You may not move a E from c1 to d3
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. c1-d3 1... h10-g8 2. b3-e3 2... b10-c8 3. h1-g3 3... c10-d8 4. b1-c3 4... h8-e8 5. g4-h4 5... f10-f9 6. c4-d4 6... c7-d7 7. a1-c1 7... a7-a6 8. c3-b5 8... c8-b6 9. c1-b1 9... a10-b10 10. d4-c4 10... d7-d6 11. h3-f3 11... b6-c8 12. b1-c1 12... i7-i6 13. c4-c5 13... g7-g6 14. h4-h5 14... c8-b6 15. g1-h3 15... i10-h10 16. i4-h4If this is your settings file, you may edit it at https://www.chessvariants.com/play/pbm/play.php?game=Korean+Chess&settings=default&submit=Edit
Here is a code listing:
0 set G findpiece G spaces 1 set g findpiece g spaces 2 include janggi 3 setflag firstturn 4 echo This preset has now been updated to spot check, checkmate, and stalemate. 5 setsystem maxmove 2 6 sub postauto1 7 if flag firstturn 8 if == origin b1 and == dest c1 or and == origin c1 == dest b1 9 setsystem moves "swap b1 c1" 10 add E b1 N c1 11 extendmove 12 return 13 elseif == origin g1 and == dest h1 or and == origin h1 == dest g1 14 setsystem moves "swap g1 h1" 15 add N g1 E h1 16 extendmove 17 return 18 elseif == moved N and == old E or and == moved E == old N 19 setsystem moves "swap b1 c1 g1 h1" 20 add E b1 N c1 N g1 E h1 21 extendmove 22 return 23 endif 24 endif 25 if isupper old 26 die You may not capture your own pieces. 27 endif 28 if not fn moved origin dest 29 die You may not move a moved from origin to dest 30 endif 31 if == moved G 32 set G dest 33 endif 34 if sub checked #G 35 die You may not move your General into check 36 endif 37 set OG checkride #g #G 1 0 38 endsub 39 sub postauto2 40 if flag firstturn 41 if == origin b10 and == dest c10 or and == origin c10 == dest b10 42 setsystem moves "swap b10 c10" 43 add e b10 n c10 44 extendmove 45 return 46 elseif == origin g10 and == dest h10 or and == origin h10 == dest g10 47 setsystem moves "swap g10 h10" 48 add n g10 e h10 49 extendmove 50 return 51 elseif == moved n and == old e or and == moved e == old n 52 setsystem moves "swap b10 c10 g10 h10" 53 add e b10 n c10 n g10 e h10 54 extendmove 55 return 56 endif 57 endif 58 if islower old 59 die You may not capture your own pieces. 60 endif 61 if not fn moved origin dest 62 die You may not move a moved from origin to dest 63 endif 64 if == moved g 65 set g dest 66 endif 67 if sub checked #g 68 die You may not move your General into check 69 endif 70 set og checkride #g #G 1 0 71 if flag firstturn 72 unsetflag firstturn 73 unallow swap 1 74 setsystem maxmove 1 75 endif 76 endsub 77 moveindex 0 78 MOVE: c1-d3 79 postauto1 80 moveindex 1 81 MOVE: h10-g8 82 postauto2 83 moveindex 2 84 MOVE: b3-e3 85 postauto1 86 moveindex 3 87 MOVE: b10-c8 88 postauto2 89 moveindex 4 90 MOVE: h1-g3 91 postauto1 92 moveindex 5 93 MOVE: c10-d8 94 postauto2 95 moveindex 6 96 MOVE: b1-c3 97 postauto1 98 moveindex 7 99 MOVE: h8-e8 100 postauto2 101 moveindex 8 102 MOVE: g4-h4 103 postauto1 104 moveindex 9 105 MOVE: f10-f9 106 postauto2 107 moveindex 10 108 MOVE: c4-d4 109 postauto1 110 moveindex 11 111 MOVE: c7-d7 112 postauto2 113 moveindex 12 114 MOVE: a1-c1 115 postauto1 116 moveindex 13 117 MOVE: a7-a6 118 postauto2 119 moveindex 14 120 MOVE: c3-b5 121 postauto1 122 moveindex 15 123 MOVE: c8-b6 124 postauto2 125 moveindex 16 126 MOVE: c1-b1 127 postauto1 128 moveindex 17 129 MOVE: a10-b10 130 postauto2 131 moveindex 18 132 MOVE: d4-c4 133 postauto1 134 moveindex 19 135 MOVE: d7-d6 136 postauto2 137 moveindex 20 138 MOVE: h3-f3 139 postauto1 140 moveindex 21 141 MOVE: b6-c8 142 postauto2 143 moveindex 22 144 MOVE: b1-c1 145 postauto1 146 moveindex 23 147 MOVE: i7-i6 148 postauto2 149 moveindex 24 150 MOVE: c4-c5 151 postauto1 152 moveindex 25 153 MOVE: g7-g6 154 postauto2 155 moveindex 26 156 MOVE: h4-h5 157 postauto1 158 moveindex 27 159 MOVE: c8-b6 160 postauto2 161 moveindex 28 162 MOVE: g1-h3 163 postauto1 164 moveindex 29 165 MOVE: i10-h10 166 postauto2 167 moveindex 30 168 MOVE: i4-h4 169 postauto1 170 if checkride #g #G 1 0 and var og 171 say Mutual Opposing Generals! Game Drawn! 172 drawn 173 elseif sub checked #g 174 if sub stalemated #g 175 say Checkmate! Red has won! 176 won 177 else 178 say Check! 179 endif 180 endif 181 end 182 183 lib janggi 184 include xiangqi 185 allow swap 1 swap 2 moves 2 moves 3 186 set many d1 1 f1 1 e2 1 d3 1 f3 1 d8 1 f8 1 e9 1 d10 1 f10 1 187 def c != tolower space screen c and checkhop #0 #1 1 1 and var #0 and var #1 or and != tolower space screen c checkhop #0 #1 0 1 and != C cond empty #0 captured space #1 188 def C != toupper space screen C and checkhop #0 #1 1 1 and var #0 and var #1 or and != toupper space screen C checkhop #0 #1 0 1 and != c cond empty #0 captured space #1 189 def e checkpath #0 #1 1 0 1 1 1 1 190 def E checkpath #0 #1 1 0 1 1 1 1 191 def r checkride #0 #1 1 1 and var #0 and var #1 or checkride #0 #1 1 0 192 def R checkride #0 #1 1 1 and var #0 and var #1 or checkride #0 #1 1 0 193 def f checkleap #0 #1 1 1 and var #0 and var #1 or or checkleap #0 #1 1 0 and flag #1 194 def F checkleap #0 #1 1 1 and var #0 and var #1 or or checkleap #0 #1 1 0 and flag #1 195 def p checkleap #0 #1 1 1 and var #0 and var #1 or checkleap #0 #1 1 0 and >= rank #0 rank #1 196 def P checkleap #0 #1 1 1 and var #0 and var #1 or checkleap #0 #1 1 0 and <= rank #0 rank #1 197 def g checkleap #0 #1 1 1 and var #0 and var #1 or or checkleap #0 #1 1 0 and flag #1 198 def G checkleap #0 #1 1 1 and var #0 and var #1 or or checkleap #0 #1 1 0 and flag #1 199 def EL leaps #0 2 3 200 def eL leaps #0 2 3 201 def fL merge leaps #0 1 1 leaps #0 1 0 202 def FL merge leaps #0 1 1 leaps #0 1 0 203 def gL merge leaps #0 1 1 leaps #0 1 0 204 def GL merge leaps #0 1 1 leaps #0 1 0 205 endlib 206 lib xiangqi 207 setsystem maxmove 1 208 ban commands allmoves 209 allow moves 1 captures 1 210 setflag d1 e1 f1 d2 e2 f2 e3 d3 f3 d8 e8 f8 d9 e9 f9 d10 e10 f10 211 def N checktwostep #0 #1 0 1 1 1 212 def P checkaleap #0 #1 -1 0 or checkaleap #0 #1 1 0 and > rank #0 4 or checkaleap #0 #1 0 1 213 def R checkride #0 #1 0 1 214 def E checktwostep #0 #1 1 1 1 1 and < rank #1 5 215 def C cond cond empty #0 capture (not empty #1) (checkhop #0 #1 0 1) (checkride #0 #1 0 1) and #1 216 def G checkride #0 #1 1 0 and == space #1 g or checkleap #0 #1 0 1 and flag #1 217 def F checkleap #0 #1 1 1 and flag #1 218 def n checktwostep #0 #1 0 1 1 1 219 def p checkaleap #0 #1 -1 0 or checkaleap #0 #1 1 0 and < rank #0 5 or checkaleap #0 #1 0 -1 220 def r checkride #0 #1 0 1 221 def e checktwostep #0 #1 1 1 1 1 and > rank #1 4 222 def c cond cond empty #0 capture (not empty #1) (checkhop #0 #1 0 1) (checkride #0 #1 0 1) and #1 223 def g checkride #0 #1 1 0 and == space #1 G or checkleap #0 #1 0 1 and flag #1 224 def f checkleap #0 #1 1 1 and flag #1 225 sub checked general 226 local piece from 227 if isupper space #general 228 def enemies onlylower 229 else 230 def enemies onlyupper 231 endif 232 for (from piece) fn enemies 233 if fn #piece #from #general 234 return true 235 endif 236 next 237 return false 238 endsub 239 sub stalemated kingpos 240 store 241 local from piece to key lglmvs 242 set lglmvs () 243 if isupper space #kingpos 244 def friends onlyupper 245 def nofriends noupper 246 def friend isupper #0 247 else 248 def friends onlylower 249 def nofriends nolower 250 def friend islower #0 251 endif 252 set royal space var kingpos 253 store 254 for to fn join #royal L #kingpos 255 if fn #royal #kingpos #to and not fn friend space #to and onboard #to 256 move #kingpos #to 257 set incheck sub checked #to 258 restore 259 if not #incheck 260 setlegal #kingpos #to 261 endif 262 endif 263 next 264 restore 265 for (from piece) fn friends 266 if == #from #kingpos 267 continue 268 endif 269 for to fn join #piece L #from 270 if fn #piece #from #to and not fn friend space #to and onboard #to 271 move #from #to 272 set incheck sub checked #kingpos 273 restore 274 if not #incheck 275 setlegal #from #to 276 endif 277 endif 278 next 279 next 280 return cond count system legalmoves false true 281 endsub 282 def PL leaps #0 1 0 283 def EL leaps #0 2 2 284 def RL rays #0 1 0 285 def CL rays #0 1 0 286 def GL merge leaps #0 1 0 (#g #G) 287 def FL leaps #0 1 1 288 def NL leaps #0 1 2 289 def pL leaps #0 -1 0 290 def eL leaps #0 2 2 291 def rL rays #0 1 0 292 def cL rays #0 1 0 293 def gL merge leaps #0 1 0 (#G #g) 294 def fL leaps #0 1 1 295 def nL leaps #0 1 2 296 endlib