You may not drop a p onto 7c
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. p 6h-6g 1... N 10a-7c 2. p 6g-6f 2... P 8d-8e 3. b 2j-8g 3... S 9b-8c 4. p 5h-5g 4... P 11d-10e 5. s 5j-5i 5... P 10d-9e 6. p 5g-5f 6... N 7c-6f 7. p 4h-5g 7... N 6f-5i; +N-5i 8. s 3j-5i 8... R 10b-10c 9. n 5k-4i 9... S 7b-6c 10. n 2k-4h 10... P 4d-4e 11. p 1h-2g 11... P 3d-3e 12. l 1k-1g 12... L 6a-3d 13. p 2g-2f 13... P 3e-2f 14. l 1g-2f 14... P*3e 15. n*1g 15... P*4c 16. p 5g-6f 16... P 3e-2f 17. n 1g-3d 17... P 4c-3d 18. n 4i-3g 18... N*7b 19. b 8g-4i 19... P 8e-7f 20. n 4h-7f 20... S 8c-8d 21. p*7c 21... B 6b-7c 22. b 4i-7c; +b-7c 22... K 8b-7c 23. b*4i 23... K 7c-8b 24. p 3h-4g 24... B*3i 25. k 4j-3i 25... S 8d-7f 26. p 2h-2g 26... P 2f-1g 27. p 2g-3f 27... P 4e-3f 28. b*2g 28... R 10c-8c 29. b 2g-1i 29... S 7f-8d 30. r 6j-6g 30... S 8d-10c 31. p*10d 31... N 7b-8d 32. r 6g-5h 32... L*8e 33. l*6g 33... N*8f 34. r 5h-5g 34... S 10c-10d 35. p 7h-7g 35... N 8f-7i; +N-7i 36. l 6k-6h 36... L 8e-8h; +L-8h 37. l 6g-9d; +l-9d 37... S 10d-9f 38. +l 9d-8c 38... G 9a-8c 39. n 3g-5d 39... S 6c-5d 40. r*5b 40... N*6b 41. p 7g-8f 41... G 8a-7b 42. p 8f-8e 42... S 9f-8e 43. l 6h-9e 43... P*10c 44. r 5g-6g 44... N 8d-6g 45. s 5i-6g 45... P*7f 46. n*2f 46... S 5d-7c 47. p 5f-5e 47... P 6d-5e 48. p*5c 48... N 6b-4e 49. p 5c-6b; +p-6b 49... G 7b-6b 50. r 5b-5e 50... S 8e-7g 51. p*5d 51... L*6d 52. l 9e-9a; +l-9a 52... K 8b-9a 53. r 5e-9e 53... P*9c 54. b 1i-7f 54... L 6d-2h; +L-2h 55. k 3i-3j 55... N 4e-3h; +N-3h 56. p*8d 56... +L 2h-3i 57. resignIf this is your settings file, you may edit it at https://www.chessvariants.com/play/pbm/play.php?game=Hex+Shogi+91&settings=default&submit=Edit
Here is a code listing:
0 set K findpiece K spaces 1 set k findpiece k spaces 2 set promote assoc p t n y l m s v g g r d b h k k P T N Y L M S V G G R D B H K K 3 alias +p t +n y +l m +s v +r d +b h +P T +N Y +L M +S V +R D +B H 4 setflag !Ck !Bk !Ak !Cj !Bj !Ci !Bi !Ch !Cg 1e 2d 3c 2c 4b 3b 5a 4a 3a 9k 8k 7k 9j 8j 10h 11g !De !Dd !Ec !Dc !Eb !Db !Fa !Ea !Da 5 include hexshogi 6 allow skip 2 7 setsystem starpath array (first !Ck !Bk !Ak !Cj !Bj !Ci !Bi !Ch !Cg 1e 2d 3c 2c 4b 3b 5a 4a 3a 9k 8k 7k 9j 8j 10h 11g !De !Dd !Ec !Dc !Eb !Db !Fa !Ea !Da) (last !Ck !Bk !Ak !Cj !Bj !Ci !Bi !Ch !Cg 1e 2d 3c 2c 4b 3b 5a 4a 3a 9k 8k 7k 9j 8j 10h 11g !De !Dd !Ec !Dc !Eb !Db !Fa !Ea !Da) 8 setsystem capturedpieces false 9 sub postauto1 10 if isupper moved 11 die You may not move any enemy pieces. 12 endif 13 if islower old 14 die You may not capture your own pieces. 15 endif 16 set pp space dest 17 if flag origin 18 if != moved space dest 19 die You may not promote a piece when dropping it. 20 elseif not sub legaldrop origin dest 21 die You may not drop a moved onto dest 22 endif 23 else 24 if not fn moved origin dest or flag dest 25 die You may not move a moved from origin to dest 26 elseif == moved k 27 set k dest 28 elseif != #pp moved 29 if < rank origin 7 and < rank dest 7 30 die You may not promote any piece without moving from or to the last three ranks. 31 elseif != #pp elem moved promote 32 set mvd moved 33 set prm elem moved promote 34 set ssb testelem moved promote 35 dump 36 die You may not promote your moved to a #pp 37 endif 38 elseif == rank dest 10 and match moved p n l 39 set pp elem moved promote 40 add #pp dest 41 appendmove join join chr 43 moved "-dest" 42 elseif == rank dest 9 and == moved n 43 add y dest 44 appendmove "+n-dest" 45 elseif >= rank dest 7 or >= rank origin 7 and match moved p n l s b r and not fnmatch *skip* thismove and >= mln system maxmln 46 echo "You moved a" moved "into the promotion zone, and it is still a" #pp 47 set pm join join chr 43 moved "-dest" 48 ask "Will you promote this piece?" "Yes" #pm "No" "skip" 49 endif 50 endif 51 if sub checked #k 52 die You may not move into check. 53 endif 54 verify capture 55 set p old 56 set c dest 57 drop old first !Ck !Bk !Ak !Cj !Bj !Ci !Bi !Ch !Cg 1e 2d 3c 2c 4b 3b 5a 4a 3a 9k 8k 7k 9j 8j 10h 11g !De !Dd !Ec !Dc !Eb !Db !Fa !Ea !Da 58 flip dest 59 convert dest d r h b v s m l y n t p 60 setglobal lastcaptured #p 61 setglobal "dest" #c 62 endsub 63 sub postauto2 64 if islower moved 65 die You may not move any enemy pieces. 66 endif 67 if isupper old 68 die You may not capture your own pieces. 69 endif 70 set pp space dest 71 if flag origin 72 if != moved space dest 73 die You may not promote a piece when dropping it. 74 elseif not sub legaldrop origin dest 75 die You may not drop a moved onto dest 76 endif 77 else 78 if not fn moved origin dest or flag dest 79 die You may not move a moved from origin to dest 80 elseif == moved K 81 set K dest 82 elseif != #pp moved 83 if > rank origin 3 and > rank dest 3 84 die You may not promote any piece without moving from or to the last three ranks. 85 elseif != #pp elem moved promote 86 die You may not promote your moved to a #pp 87 endif 88 elseif == rank dest 0 and match moved P N L 89 set pp elem moved promote 90 add #pp dest 91 appendmove join join chr 43 moved "-dest" 92 elseif == rank dest 1 and == moved N 93 add Y dest 94 appendmove "+N-dest" 95 elseif <= rank dest 3 or <= rank origin 3 and match moved P N L S B R and not fnmatch *skip* thismove and >= mln system maxmln 96 echo "You moved a" moved "into the promotion zone, and it is still a" #pp 97 set pm join join chr 43 moved "-dest" 98 ask "Will you promote this piece?" "Yes" #pm "No" "skip" 99 endif 100 endif 101 if sub checked #K 102 die You may not move into check. 103 endif 104 verify capture 105 set p old 106 set c dest 107 drop old last !Ck !Bk !Ak !Cj !Bj !Ci !Bi !Ch !Cg 1e 2d 3c 2c 4b 3b 5a 4a 3a 9k 8k 7k 9j 8j 10h 11g !De !Dd !Ec !Dc !Eb !Db !Fa !Ea !Da 108 flip dest 109 convert dest D R H B V S M L Y N T P 110 setglobal lastcaptured #p 111 setglobal "dest" #c 112 endsub 113 moveindex 1 114 MOVE: p 6h-6g 115 postauto1 116 moveindex 2 117 MOVE: N 10a-7c 118 postauto2 119 moveindex 3 120 MOVE: p 6g-6f 121 postauto1 122 moveindex 4 123 MOVE: P 8d-8e 124 postauto2 125 moveindex 5 126 MOVE: b 2j-8g 127 postauto1 128 moveindex 6 129 MOVE: S 9b-8c 130 postauto2 131 moveindex 7 132 MOVE: p 5h-5g 133 postauto1 134 moveindex 8 135 MOVE: P 11d-10e 136 postauto2 137 moveindex 9 138 MOVE: s 5j-5i 139 postauto1 140 moveindex 10 141 MOVE: P 10d-9e 142 postauto2 143 moveindex 11 144 MOVE: p 5g-5f 145 postauto1 146 moveindex 12 147 MOVE: N 7c-6f 148 postauto2 149 moveindex 13 150 MOVE: p 4h-5g 151 postauto1 152 moveindex 14 153 MOVE: N 6f-5i 154 MOVE: +N-5i 155 postauto2 156 moveindex 15 157 MOVE: s 3j-5i 158 postauto1 159 moveindex 16 160 MOVE: R 10b-10c 161 postauto2 162 moveindex 17 163 MOVE: n 5k-4i 164 postauto1 165 moveindex 18 166 MOVE: S 7b-6c 167 postauto2 168 moveindex 19 169 MOVE: n 2k-4h 170 postauto1 171 moveindex 20 172 MOVE: P 4d-4e 173 postauto2 174 moveindex 21 175 MOVE: p 1h-2g 176 postauto1 177 moveindex 22 178 MOVE: P 3d-3e 179 postauto2 180 moveindex 23 181 MOVE: l 1k-1g 182 postauto1 183 moveindex 24 184 MOVE: L 6a-3d 185 postauto2 186 moveindex 25 187 MOVE: p 2g-2f 188 postauto1 189 moveindex 26 190 MOVE: P 3e-2f 191 postauto2 192 moveindex 27 193 MOVE: l 1g-2f 194 postauto1 195 moveindex 28 196 MOVE: P*3e 197 postauto2 198 moveindex 29 199 MOVE: n*1g 200 postauto1 201 moveindex 30 202 MOVE: P*4c 203 postauto2 204 moveindex 31 205 MOVE: p 5g-6f 206 postauto1 207 moveindex 32 208 MOVE: P 3e-2f 209 postauto2 210 moveindex 33 211 MOVE: n 1g-3d 212 postauto1 213 moveindex 34 214 MOVE: P 4c-3d 215 postauto2 216 moveindex 35 217 MOVE: n 4i-3g 218 postauto1 219 moveindex 36 220 MOVE: N*7b 221 postauto2 222 moveindex 37 223 MOVE: b 8g-4i 224 postauto1 225 moveindex 38 226 MOVE: P 8e-7f 227 postauto2 228 moveindex 39 229 MOVE: n 4h-7f 230 postauto1 231 moveindex 40 232 MOVE: S 8c-8d 233 postauto2 234 moveindex 41 235 MOVE: p*7c 236 postauto1 237 moveindex 42 238 MOVE: B 6b-7c 239 postauto2 240 moveindex 43 241 MOVE: b 4i-7c 242 MOVE: +b-7c 243 postauto1 244 moveindex 44 245 MOVE: K 8b-7c 246 postauto2 247 moveindex 45 248 MOVE: b*4i 249 postauto1 250 moveindex 46 251 MOVE: K 7c-8b 252 postauto2 253 moveindex 47 254 MOVE: p 3h-4g 255 postauto1 256 moveindex 48 257 MOVE: B*3i 258 postauto2 259 moveindex 49 260 MOVE: k 4j-3i 261 postauto1 262 moveindex 50 263 MOVE: S 8d-7f 264 postauto2 265 moveindex 51 266 MOVE: p 2h-2g 267 postauto1 268 moveindex 52 269 MOVE: P 2f-1g 270 postauto2 271 moveindex 53 272 MOVE: p 2g-3f 273 postauto1 274 moveindex 54 275 MOVE: P 4e-3f 276 postauto2 277 moveindex 55 278 MOVE: b*2g 279 postauto1 280 moveindex 56 281 MOVE: R 10c-8c 282 postauto2 283 moveindex 57 284 MOVE: b 2g-1i 285 postauto1 286 moveindex 58 287 MOVE: S 7f-8d 288 postauto2 289 moveindex 59 290 MOVE: r 6j-6g 291 postauto1 292 moveindex 60 293 MOVE: S 8d-10c 294 postauto2 295 moveindex 61 296 MOVE: p*10d 297 postauto1 298 moveindex 62 299 MOVE: N 7b-8d 300 postauto2 301 moveindex 63 302 MOVE: r 6g-5h 303 postauto1 304 moveindex 64 305 MOVE: L*8e 306 postauto2 307 moveindex 65 308 MOVE: l*6g 309 postauto1 310 moveindex 66 311 MOVE: N*8f 312 postauto2 313 moveindex 67 314 MOVE: r 5h-5g 315 postauto1 316 moveindex 68 317 MOVE: S 10c-10d 318 postauto2 319 moveindex 69 320 MOVE: p 7h-7g 321 postauto1 322 moveindex 70 323 MOVE: N 8f-7i 324 MOVE: +N-7i 325 postauto2 326 moveindex 71 327 MOVE: l 6k-6h 328 postauto1 329 moveindex 72 330 MOVE: L 8e-8h 331 MOVE: +L-8h 332 postauto2 333 moveindex 73 334 MOVE: l 6g-9d 335 MOVE: +l-9d 336 postauto1 337 moveindex 74 338 MOVE: S 10d-9f 339 postauto2 340 moveindex 75 341 MOVE: +l 9d-8c 342 postauto1 343 moveindex 76 344 MOVE: G 9a-8c 345 postauto2 346 moveindex 77 347 MOVE: n 3g-5d 348 postauto1 349 moveindex 78 350 MOVE: S 6c-5d 351 postauto2 352 moveindex 79 353 MOVE: r*5b 354 postauto1 355 moveindex 80 356 MOVE: N*6b 357 postauto2 358 moveindex 81 359 MOVE: p 7g-8f 360 postauto1 361 moveindex 82 362 MOVE: G 8a-7b 363 postauto2 364 moveindex 83 365 MOVE: p 8f-8e 366 postauto1 367 moveindex 84 368 MOVE: S 9f-8e 369 postauto2 370 moveindex 85 371 MOVE: l 6h-9e 372 postauto1 373 moveindex 86 374 MOVE: P*10c 375 postauto2 376 moveindex 87 377 MOVE: r 5g-6g 378 postauto1 379 moveindex 88 380 MOVE: N 8d-6g 381 postauto2 382 moveindex 89 383 MOVE: s 5i-6g 384 postauto1 385 moveindex 90 386 MOVE: P*7f 387 postauto2 388 moveindex 91 389 MOVE: n*2f 390 postauto1 391 moveindex 92 392 MOVE: S 5d-7c 393 postauto2 394 moveindex 93 395 MOVE: p 5f-5e 396 postauto1 397 moveindex 94 398 MOVE: P 6d-5e 399 postauto2 400 moveindex 95 401 MOVE: p*5c 402 postauto1 403 moveindex 96 404 MOVE: N 6b-4e 405 postauto2 406 moveindex 97 407 MOVE: p 5c-6b 408 MOVE: +p-6b 409 postauto1 410 moveindex 98 411 MOVE: G 7b-6b 412 postauto2 413 moveindex 99 414 MOVE: r 5b-5e 415 postauto1 416 moveindex 100 417 MOVE: S 8e-7g 418 postauto2 419 moveindex 101 420 MOVE: p*5d 421 postauto1 422 moveindex 102 423 MOVE: L*6d 424 postauto2 425 moveindex 103 426 MOVE: l 9e-9a 427 MOVE: +l-9a 428 postauto1 429 moveindex 104 430 MOVE: K 8b-9a 431 postauto2 432 moveindex 105 433 MOVE: r 5e-9e 434 postauto1 435 moveindex 106 436 MOVE: P*9c 437 postauto2 438 moveindex 107 439 MOVE: b 1i-7f 440 postauto1 441 moveindex 108 442 MOVE: L 6d-2h 443 MOVE: +L-2h 444 postauto2 445 moveindex 109 446 MOVE: k 3i-3j 447 postauto1 448 moveindex 110 449 MOVE: N 4e-3h 450 MOVE: +N-3h 451 postauto2 452 moveindex 111 453 MOVE: p*8d 454 postauto1 455 moveindex 112 456 MOVE: +L 2h-3i 457 postauto2 458 moveindex 113 459 MOVE: resign 460 postauto1 461 set checks sub checks #K 462 if var checks 463 if sub checkmated #K #checks 464 restore 465 if == moved p and not isalnum origin 466 die You may not checkmate a King by dropping a Pawn. 467 endif 468 say Checkmate! Black has won! 469 won 470 else 471 say Check! 472 endif 473 elseif sub stalemated #K 474 say Stalemate! Black has won. 475 won 476 endif 477 end 478 479 lib hexshogi 480 setsystem maxmove 2 481 ban commands allmoves 482 allow moves 1 captures 1 drops 1 promotions 2 skip 2 483 def k checkaleap #0 #1 -2 1 or checkaleap #0 #1 -1 2 or checkaleap #0 #1 1 -2 or checkaleap #0 #1 2 -1 or checkleap #0 #1 1 1 or checkleap #0 #1 1 0 484 def r checkride #0 #1 1 1 and < slope #0 #1 0 or checkride #0 #1 1 0 485 def b cond < slope #0 #1 0 (checkride #0 #1 1 2) (checkride #0 #1 1 1) 486 def n checkaleap #0 #1 -3 2 or checkaleap #0 #1 -2 3 or checkaleap #0 #1 -1 3 or checkaleap #0 #1 1 2 487 def p checkaleap #0 #1 -1 1 or checkaleap #0 #1 0 1 488 def g checkaleap #0 #1 -2 1 or checkaleap #0 #1 -1 2 or checkaleap #0 #1 1 1 or checkaleap #0 #1 -1 1 or checkaleap #0 #1 1 -1 or checkleap #0 #1 1 0 489 def s checkaleap #0 #1 -2 1 or checkaleap #0 #1 -1 2 or checkaleap #0 #1 1 1 or checkaleap #0 #1 -1 -1 or checkaleap #0 #1 1 -2 or checkaleap #0 #1 2 -1 or checkaleap #0 #1 -1 1 or checkaleap #0 #1 0 1 490 def l checkaride #0 #1 -1 1 or checkaride #0 #1 0 1 491 copyfn g t 492 copyfn g y 493 copyfn g m 494 copyfn g v 495 def d checkleap #0 #1 1 2 or checkride #0 #1 1 1 and < slope #0 #1 0 or checkleap #0 #1 1 1 or checkride #0 #1 1 0 496 def h checkleap #0 #1 1 1 or checkleap #0 #1 1 0 or cond < slope #0 #1 0 (checkride #0 #1 1 2) (checkride #0 #1 1 1) 497 def K checkaleap #0 #1 -2 1 or checkaleap #0 #1 -1 2 or checkaleap #0 #1 1 -2 or checkaleap #0 #1 2 -1 or checkleap #0 #1 1 1 or checkleap #0 #1 1 0 498 def R checkride #0 #1 1 1 and < slope #0 #1 0 or checkride #0 #1 1 0 499 def B cond < slope #0 #1 0 (checkride #0 #1 1 2) (checkride #0 #1 1 1) 500 def N checkaleap #0 #1 3 -2 or checkaleap #0 #1 2 -3 or checkaleap #0 #1 1 -3 or checkaleap #0 #1 -1 -2 501 def P checkaleap #0 #1 1 -1 or checkaleap #0 #1 0 -1 502 def G checkaleap #0 #1 2 -1 or checkaleap #0 #1 1 -2 or checkaleap #0 #1 -1 -1 or checkaleap #0 #1 1 -1 or checkaleap #0 #1 -1 1 or checkleap #0 #1 1 0 503 def S checkaleap #0 #1 -2 1 or checkaleap #0 #1 -1 2 or checkaleap #0 #1 1 1 or checkaleap #0 #1 -1 -1 or checkaleap #0 #1 1 -2 or checkaleap #0 #1 2 -1 or checkaleap #0 #1 1 -1 or checkaleap #0 #1 0 -1 504 def L checkaride #0 #1 1 -1 or checkaride #0 #1 0 -1 505 copyfn G T 506 copyfn G Y 507 copyfn G M 508 copyfn G V 509 def D checkleap #0 #1 1 2 or checkride #0 #1 1 1 and < slope #0 #1 0 or checkleap #0 #1 1 1 or checkride #0 #1 1 0 510 def H checkleap #0 #1 1 1 or checkleap #0 #1 1 0 or cond < slope #0 #1 0 (checkride #0 #1 1 2) (checkride #0 #1 1 1) 511 def KL mergeall where #0 -2 1 where #0 -1 2 where #0 1 -2 where #0 2 -1 leaps #0 1 1 leaps #0 1 0 512 def RL merge rays #0 1 1 rays #0 1 0 513 def BL merge rays #0 1 2 rays #0 1 1 514 def NL array where #0 3 -2 where #0 2 -3 where #0 1 -3 where #0 -1 -2 515 def GL mergeall leaps #0 1 0 where #0 2 -1 where #0 1 -2 where #0 -1 -1 where #0 1 -1 where #0 -1 1 516 def SL array where #0 -2 1 where #0 -1 2 where #0 1 1 where #0 -1 -1 where #0 1 -2 where #0 2 -1 where #0 1 -1 where #0 0 -1 517 def LL merge ray #0 1 -1 ray #0 0 -1 518 def PL array where #0 1 -1 where #0 0 -1 519 copyfn GL TL 520 copyfn GL YL 521 copyfn GL ML 522 copyfn GL VL 523 def DL mergeall leaps #0 1 2 rays #0 1 1 rays #0 1 0 524 def HL mergeall rays #0 1 1 leaps #0 1 0 rays #0 1 2 525 def gL mergeall leaps #0 1 0 where #0 -2 1 where #0 -1 2 where #0 1 1 where #0 -1 1 where #0 1 -1 526 def sL array where #0 -2 1 where #0 -1 2 where #0 1 1 where #0 -1 -1 where #0 1 -2 where #0 2 -1 where #0 -1 1 where #0 0 1 527 def lL merge ray #0 -1 1 ray #0 0 1 528 def pL array where #0 -1 1 where #0 0 1 529 def nL array where #0 -3 2 where #0 -2 3 where #0 -1 3 where #0 1 2 530 copyfn KL kL 531 copyfn RL rL 532 copyfn BL bL 533 copyfn gL tL 534 copyfn gL yL 535 copyfn gL mL 536 copyfn gL vL 537 copyfn DL dL 538 copyfn HL hL 539 def rearp anytrue lambda (== p space #0 and < color #0 3) array where #0 1 -1 where #0 0 -1 540 def rearP anytrue lambda (== P space #0 and < color #0 3) array where #0 -1 1 where #0 0 1 541 sub legaldrop from to 542 local piece 543 set piece space #to 544 verify not capture and < color #to 3 545 if match #piece L P 546 verify anytrue lambda (< color #0 3 and onboard #0) fn PL #to 547 if == #piece P 548 return not fn rearP #to and not fn P #to #k 549 endif 550 elseif match #piece l p 551 verify anytrue lambda (< color #0 3 and onboard #0) fn pL #to 552 if == #piece p 553 return not fn rearp #to and not fn p #to #K 554 endif 555 elseif == #piece N 556 return anytrue lambda (< color #0 3 and onboard #0) fn NL #to 557 elseif == #piece n 558 return anytrue lambda (< color #0 3 and onboard #0) fn nL #to 559 endif 560 return true 561 endsub 562 sub checks king 563 if not dest 564 return false 565 endif 566 my checks c 567 set checks () 568 if fn space dest dest #king 569 setelem checks dest space dest 570 endif 571 if not flag origin 572 set c revealed #king origin 573 if fn space #c #c #king and not samecase space #king space #c and isvisible #c and onboard #c and not flag #c and #c 574 setelem checks #c space #c 575 endif 576 endif 577 return var checks 578 endsub 579 sub checked king 580 local piece from 581 if isupper space #king 582 def enemies onlylower 583 else 584 def enemies onlyupper 585 endif 586 for (from piece) fn enemies 587 if fn #piece #from #king and not flag #from 588 return true 589 endif 590 next 591 return false 592 endsub 593 sub checkmated king checks 594 local piece from to pos loc safe 595 store 596 if isupper space #king 597 def friends onlyupper 598 def friend isupper space #0 599 set any [A-Z] 600 set pat [GSRB] 601 set pawn P 602 set pmoves PL 603 set nmoves NL 604 set pprotect rearP 605 set otherking #k 606 set lance L 607 else 608 def friends onlylower 609 def friend islower space #0 610 set any [a-z] 611 set pat [gsrb] 612 set pawn p 613 set lance l 614 set pmoves pL 615 set nmoves nL 616 set pprotect rearp 617 set otherking #K 618 endif 619 store 620 for pos fn KL #king 621 if fn K #king #pos and not fn friend #pos and not flag #pos and isvisible #pos 622 move #king #pos 623 set safe not sub checked #pos 624 restore 625 if #safe 626 setlegal #king #pos 627 endif 628 endif 629 next 630 if > count var checks 1 631 return not count system legalmoves 632 endif 633 restore 634 for (from piece) fn friends 635 if == #from #king or >= color #from 3 636 continue 637 endif 638 for (to enemy) var checks 639 if not friend #to 640 if fn #piece #from #to 641 move #from #to 642 set safe not sub checked #king 643 restore 644 if #safe 645 setlegal #from #to 646 endif 647 endif 648 endif 649 next 650 next 651 if fn K #king #to or == toupper #enemy N 652 return not count system legalmoves 653 endif 654 set openspace path #king #to 655 for (from piece) fn friends 656 if == #from #king 657 continue 658 endif 659 for to #openspace 660 if not fn friend #to 661 if fn #piece #from #to 662 move #from #to 663 set safe not sub checked #king 664 restore 665 if #safe 666 setlegal #from #to 667 endif 668 endif 669 endif 670 next 671 next 672 if not findinhand #any 673 return not count system legalmoves 674 endif 675 for to #openspace 676 if empty #to and < color #to 3 677 push piecedrops #to 678 if anytrue lambda (< color #0 3 and onboard #0) fn #pmoves #to 679 echo "to:" #to #qq 680 printr qq 681 push lancedrops #to 682 if not fn #pprotect #to and not fn #pawn #to #otherking 683 push pawndrops #to 684 endif 685 if anytrue lambda (< color #0 3 and onboard #0) fn #nmoves #to 686 push knightdrops #to 687 endif 688 endif 689 endif 690 next 691 for (from piece) fn friends 692 if not isalnum #from 693 switch #piece 694 case p P 695 for to var pawndrops 696 setlegal "{#piece}*{#to}" 697 next 698 break 699 case n N 700 for to var knightdrops 701 setlegal "{#piece}*{#to}" 702 next 703 break 704 case l L 705 for to var lancedrops 706 setlegal "{#piece}*{#to}" 707 next 708 break 709 default 710 for to var piecedrops 711 setlegal "{#piece}*{#to}" 712 next 713 break 714 endswitch 715 endif 716 next 717 return not count system legalmoves 718 endsub 719 sub stalemated king 720 my safe forward from piece to pawninhand pawn key pawndrops lancedrops knightdrops piecedrops 721 set pawndrops () 722 set lancedrops () 723 set knightdrops () 724 set piecedrops () 725 set pawnonfile () 726 if isupper space #king 727 def friend isupper #0 728 def friends onlyupper 729 set pawn P 730 set any [A-Z] 731 set pmoves PL 732 set nmoves NL 733 set pprotect rearP 734 set otherking #k 735 else 736 def friend islower #0 737 def friends onlylower 738 set pawn p 739 set any [a-z] 740 set forward 1 741 set pmoves pL 742 set nmoves nL 743 set pprotect rearp 744 set otherking #K 745 endif 746 store 747 for (from piece) fn friends 748 if < color #from 3 749 for to fn join #piece L #from 750 if fn #piece #from #to and < color #to 3 and not fn friend space #to 751 move #from #to 752 set safe not sub checked cond == #from #king #to #king 753 restore 754 if #safe 755 setlegal #from #to 756 endif 757 endif 758 next 759 endif 760 next 761 if not findinhand #any 762 return not count system legalmoves 763 endif 764 for to fn spaces 765 if empty #to and < color #to 3 766 push piecedrops #to 767 if anytrue lambda (< color #0 3 and onboard #0) fn #pmoves #to 768 push lancedrops #to 769 if not fn #pprotect #to and not fn #pawn #to #otherking 770 push pawndrops #to 771 endif 772 if anytrue lambda (< color #0 3 and onboard #0) fn #nmoves #to 773 push knightdrops #to 774 endif 775 endif 776 endif 777 next 778 for (from piece) fn friends 779 if not isalnum #from 780 switch #piece 781 case p P 782 for to var pawndrops 783 setlegal "{#piece}*{#to}" 784 next 785 break 786 case n N 787 for to var knightdrops 788 setlegal "{#piece}*{#to}" 789 next 790 break 791 case l L 792 for to var lancedrops 793 setlegal "{#piece}*{#to}" 794 next 795 break 796 default 797 for to var piecedrops 798 setlegal "{#piece}*{#to}" 799 next 800 break 801 endswitch 802 endif 803 next 804 return not count system legalmoves 805 endsub 806 endlib