Please report any bugs or errors to Adam DeWitt

You may not move a BG from 3g to 10n

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. d 12k-12j 
1... P 10e-10f 
2. d 5k-5j 
2... BG 11d-9f 
3. p 12l-12k 
3... SE 5d-3f 
4. p 5l-5k 
4... HF 13d-13f 
5. se 5m-7k 
5... D 5f-5g 
6. se 12m-14k 
6... P 5e-5f 
7. p 4l-4k 
7... P 7e-7f 
8. bg 11m-14j 
8... GG 8d-14j 
9. se 14k-14j 
9... BG 6d-3g 
10. p 8l-8k 
10... BG 3g-10n; +BG-dest; onetwo 
11. rg 10m-10n 
11... FD 7c-8f 
12. vg 8m-9m; pass 
12... VG 9d-11g 
13. rg 7m-8m 
13... LH 8c-12g 
14. rg 8m-8f 
14... P 8e-8f 
15. bg 6m-12g 
15... D 12f-12g 
16. hf 13m-12l 
16... FD 10c-8e 
17. p 3l-3k 
17... D 12g-11f 
18. p 6l-6k 
18... VG 11g-9g 
19. rg 10n-10m 
19... SE 12d-14f 
20. se 14j-13i; se 13i-14j 
20... HF 4d-7g 
21. vg 9m-4h 
21... FE 9c-7c 
22. vg 4h-4i; pass 
22... FD 8e-5e 
23. rg 10m-9m 
23... VG 9g-8g; pass 
24. p 11l-11k 
24... RG 7d-4d 
25. hf 4m-7m 
25... HF 7g-6g 
26. dh 13n-6g 
26... RG 4d-4k; one 
27. b 3n-5l 
27... FD 5e-6f; FD 6f-6g; FD 6g-6f 
28. b 5l-4k 
28... VG 8g-10g 
29. p 11k-11j 
29... FD 6f-8g 
30. hf 12l-10n 
30... VG 10g-9g; pass 
31. rg 9m-9g 
31... FD 8g-10g; FD 10g-9g; FD 9g-10g 
32. p 6k-6j 
32... RG 10d-7d 
33. dh 4n-4m 
33... FD 10g-13i; FD 13i-14j; FD 14j-12j 
34. p 10l-10k 
34... FD 13i-14g 
35. d 5j-5i 
35... FE 7c-7e 
36. b 14n-10j 
36... BG 9f-11h 
37. b 10j-14f 
37... FD 14g-14f; FD 14f-14g 
38. fd 7n-9m 
38... RG 7d-9d 
39. hf 7m-9k 
39... B 3c-7g 
40. b 4k-1h 
40... SE 3f-4f 
41. b 1h-6m 
41... B 7g-6h 
42. p 8k-8j 
42... FD 14g-8g 
43. p 7l-7k 
43... BG 11h-8e 
44. b 6m-13f 
44... P 13e-13f 
45. n 15p-14n 
45... N 2a-3c 
46. n 2p-3n 
46... N 3c-5b 
47. p 6j-6i 
47... FD 8g-7h; FD 7h-6i; FD 6i-7h 
48. dk 5n-6m 
48... FD 7h-3l; FD 3l-4m; FD 4m-3m 
49. n 3n-5m 
49... FD 3l-7h 
50. vs 2n-4n 
50... SE 4f-5e 
51. n 14n-12m 
51... SE 5e-7g 
52. cs 3o-3l 
52... FD 7h-10g 
53. n 12m-11k 
53... SE 7g-9g 
54. n 5m-6k 
54... SE 9g-9k 
55. wb 6n-9k 
55... FE 7e-9g 
56. dk 6m-8m 
56... DH 13c-12d 
57. n 11k-10i 
57... FD 10g-10h; FD 10h-10i; FD 10i-10h 
58. p 8j-8i 
58... B 6h-9k 
59. p 9l-9k 
59... FE 9g-12g 
60. n 6k-7i 
60... DH 12d-15g 
61. p 12k-12j 
61... RG 9d-9m; +RG-dest; one 
62. dk 8m-9m 
62... P 8f-8g 
63. n 7i-9j 
63... FD 10h-10j; FD 10j-9j; FD 9j-10k 
64. cs 14o-15o 
64... FD 10j-2j; pass 
65. vm 2m-3m 
65... FD 2j-3l; FD 3l-3m; FD 3m-3k 
66. vs 4n-3n 
66... FD 3l-2l; FD 2l-1m; FD 1m-2l 
67. dk 12n-12l 
67... FD 2l-1o; FD 1o-1p; FD 1p-1n 
68. cs 4o-3o 
68... FD 1o-3p; FD 3p-3o; FD 3o-4p 
69. c 5p-4o 
69... FD 3p-1o 
70. vs 3n-5n 
70... FD 1o-4o; FD 4o-5n; FD 5n-4o 
71. wb 11n-8k 
71... FD 4o-5o; FD 5o-6p; FD 6p-6o 
72. g 7p-6p 
72... FD 5o-8o; FD 8o-9p; FD 9p-8p 
// - All Royals Captured! White has won! -

If this is your settings file, you may edit it at https://www.chessvariants.com/play/pbm/play.php?game=Suzumu+Shogi&settings=suzumu&submit=Edit

Here is a code listing:

   0 echo Please report any bugs or errors to Adam DeWitt
   1 set mypieces ()
   2 set myflipped ()
   3 foreach label (p P d D n N i I c C s S bt BT fl FL g G de DE l L ky KY ph PH sm SM vm VM b B ss SS vs VS r R dh DH dk DK cs CS hf HF se SE ln LN bg BG rg RG wb WB fe FE lh LH vg VG gg GG fd FD k K)
   4   setelem mypieces #label pieceimg #label
   5   setelem myflipped #label flipimg #label
   6 next
   7 foreach pair ((rc rv) (RC RV) (fk q) (FK Q) (p$ +p) (P$ +P) (d$ +d) (D$ +D) (n$ +n) (N$ +N) (i$ +i) (I$ +I) (c$ +c) (C$ +C) (s$ +s) (S$ +S) (bt$ +bt) (BT$ +BT) (fl$ +fl) (FL$ +FL) (g$ +g) (G$ +G) (de$ +de) (DE$ +DE) (rc$ +rv) (RC$ +RV) (l$ +l) (L$ +L) (ky$ +ky) (KY$ +KY) (ph$ +ph) (PH$ +PH) (sm$ +sm) (SM$ +SM) (vm$ +vm) (VM$ +VM) (b$ +b) (B$ +B) (ss$ +ss) (SS$ +SS) (vs$ +vs) (VS$ +VS) (r$ +r) (R$ +R) (dh$ +dh) (DH$ +DH) (dk$ +dk) (DK$ +DK) (cs$ +cs) (CS$ +CS) (hf$ +hf) (HF$ +HF) (se$ +se) (SE$ +SE) (ln$ +ln) (LN$ +LN) (fk$ +q) (FK$ +Q) (bg$ +bg) (BG$ +BG) (rg$ +rg) (RG$ +RG) (wb$ +wb) (WB$ +WB))
   8   setelem mypieces #pair.1 pieceimg #pair.0
   9   setelem myflipped #pair.1 flipimg #pair.0
  10 next
  11 setsystem pieces #mypieces
  12 setsystem flipped #myflipped
  13 setsystem originalpieces currentpieces
  14 set bpieces p +p d +d n +n i +i c +c s +s bt +bt fl +fl g +g de +de rv +rv l +l ky +ky ph +ph sm +sm vm +vm b +b ss +ss vs +vs r +r dh +dh dk +dk cs +cs hf +hf se +se ln +ln q +q bg +bg rg +rg wb +wb fe lh vg gg fd k
  15 set wpieces P +P D +D N +N I +I C +C S +S BT +BT FL +FL G +G DE +DE RV +RV L +L KY +KY PH +PH SM +SM VM +VM B +B SS +SS VS +VS R +R DH +DH DK +DK CS +CS HF +HF SE +SE LN +LN Q +Q BG +BG RG +RG WB +WB FE LH VG GG FD K
  16 set pzs cond >= lastrank 14 5 4
  17 set promote assoc p +p d +d n +n i +i c +c s +s bt +bt fl +fl g +g de +de rv +rv l +l ky +ky ph +ph sm +sm vm +vm b +b ss +ss vs +vs r +r dh +dh dk +dk cs +cs hf +hf se +se ln +ln q +q bg +bg rg +rg wb +wb fe fe lh lh vg vg gg gg fd fd k k P +P D +D N +N I +I C +C S +S BT +BT FL +FL G +G DE +DE RV +RV L +L KY +KY PH +PH SM +SM VM +VM B +B SS +SS VS +VS R +R DH +DH DK +DK CS +CS HF +HF SE +SE LN +LN Q +Q BG +BG RG +RG WB +WB FE FE LH LH VG VG GG GG FD FD K K
  18 set steps array 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
  19 setsystem maxmove 3
  20 ban commands allmoves
  21 allow moves 1 captures 1 moves 2 captures 2 pass 2 one 2 two 2 onetwo 2 promotions 2 moves 3 captures 3 pass 3 one 3 two 3 onetwo 3 promotions 3
  22 map n 0 1
  23 map n2 0 2
  24 map s 0 -1
  25 map s2 0 -2
  26 map e 1 0
  27 map e2 2 0
  28 map w -1 0
  29 map w2 -2 0
  30 map ne 1 1
  31 map ne2 2 2
  32 map se 1 -1
  33 map se2 2 -2
  34 map sw -1 -1
  35 map sw2 -2 -2
  36 map nw -1 1
  37 map nw2 -2 2
  38 def NO logride #0 #1 (n2 n n n n n n n n n n n n n)
  39 def NE logride #0 #1 (ne2 ne ne ne ne ne ne ne ne ne ne ne ne ne)
  40 def EA logride #0 #1 (e2 e)
  41 def SED logride #0 #1 (se2 se se se se se se se se se se se se se)
  42 def SO logride #0 #1 (s2 s s s s s s s s s s s s s)
  43 def SW logride #0 #1 (sw2 sw sw sw sw sw sw sw sw sw sw sw sw sw)
  44 def WE logride #0 #1 (w2 w)
  45 def NW logride #0 #1 (nw2 nw nw nw nw nw nw nw nw nw nw nw nw nw)
  46 def neighbor match #1 what #0 1 0 what #0 1 1 what #0 0 1 what #0 -1 1 what #0 -1 0 what #0 -1 -1 what #0 0 -1 what #0 1 -1
  47 def p checkaleap #0 #1 0 1
  48 def P checkaleap #0 #1 0 -1
  49 def pL array where #0 0 1
  50 def PL array where #0 0 -1
  51 def d checkaleap #0 #1 0 1 or checkaleap #0 #1 -1 -1 or checkaleap #0 #1 1 -1
  52 def D checkaleap #0 #1 0 -1 or checkaleap #0 #1 -1 1 or checkaleap #0 #1 1 1
  53 def dL array where #0 0 1 where #0 -1 -1 where #0 1 -1
  54 def DL array where #0 0 -1 where #0 -1 1 where #0 1 1
  55 def n checkleap #0 #1 1 2
  56 copyfn n N
  57 def nL leaps #0 1 2
  58 def NL leaps #0 1 2
  59 copyfn D i
  60 copyfn d I
  61 def iL array where #0 0 -1 where #0 -1 1 where #0 1 1
  62 def IL array where #0 0 1 where #0 -1 -1 where #0 1 -1
  63 def c fn i #0 #1 or fn p #0 #1
  64 def C fn I #0 #1 or fn P #0 #1
  65 def cL array where #0 0 1 where #0 0 -1 where #0 -1 1 where #0 1 1
  66 def CL array where #0 0 1 where #0 0 -1 where #0 -1 -1 where #0 1 -1
  67 def s checkleap #0 #1 1 1 or fn p #0 #1
  68 def S checkleap #0 #1 1 1 or fn P #0 #1
  69 def sL merge leaps #0 1 1 array where #0 0 1
  70 def SL merge leaps #0 1 1 array where #0 0 -1
  71 def bt fn S #0 #1 or checkaleap #0 #1 -1 0 or checkaleap #0 #1 1 0
  72 def BT fn s #0 #1 or checkaleap #0 #1 -1 0 or checkaleap #0 #1 1 0
  73 def btL merge leaps #0 1 1 array where #0 -1 0 where #0 1 0 where #0 0 -1
  74 def BTL merge leaps #0 1 1 array where #0 -1 0 where #0 1 0 where #0 0 1
  75 def fl checkleap #0 #1 1 1 or checkaleap #0 #1 0 1 or checkaleap #0 #1 0 -1
  76 copyfn fl FL
  77 def flL merge leaps #0 1 1 array where #0 0 1 where #0 0 -1
  78 def FLL merge leaps #0 1 1 array where #0 0 1 where #0 0 -1
  79 def g checkleap #0 #1 0 1 or checkaleap #0 #1 -1 1 or checkaleap #0 #1 1 1
  80 def G checkleap #0 #1 0 1 or checkaleap #0 #1 -1 -1 or checkaleap #0 #1 1 -1
  81 def gL merge leaps #0 0 1 array where #0 -1 1 where #0 1 1
  82 def GL merge leaps #0 0 1 array where #0 -1 -1 where #0 1 -1
  83 def de fn BT #0 #1
  84 def DE fn bt #0 #1
  85 def deL merge leaps #0 1 1 array where #0 -1 0 where #0 1 0 where #0 0 1
  86 def DEL merge leaps #0 1 1 array where #0 -1 0 where #0 1 0 where #0 0 -1
  87 def rv checkaride #0 #1 0 1 or checkaride #0 #1 0 -1
  88 copyfn rv RV
  89 def rvL rays #0 0 1
  90 def RVL rays #0 0 1
  91 def l checkaride #0 #1 0 -1 and <= distance #0 #1 2 or checkaride #0 #1 0 1
  92 def L checkaride #0 #1 0 1 and <= distance #0 #1 2 or checkaride #0 #1 0 -1
  93 def lL rays #0 0 1
  94 def LL rays #0 0 1
  95 def ky checkleap #0 #1 1 1 or checkleap #0 #1 0 2
  96 copyfn ky KY
  97 def kyL merge leaps #0 1 1 leaps #0 0 2
  98 def KYL merge leaps #0 1 1 leaps #0 0 2
  99 def ph checkleap #0 #1 0 1 or checkleap #0 #1 2 2
 100 copyfn ph PH
 101 def phL merge leaps #0 0 1 leaps #0 2 2
 102 def PHL merge leaps #0 0 1 leaps #0 2 2
 103 def sm checkaride #0 #1 -1 0 or checkaride #0 #1 1 0 or checkleap #0 #1 0 1
 104 copyfn sm SM
 105 def smL rays #0 0 1
 106 def SML rays #0 0 1
 107 def vm checkaride #0 #1 0 -1 or checkaride #0 #1 0 1 or checkleap #0 #1 0 1
 108 copyfn vm VM
 109 def vmL rays #0 0 1
 110 def VML rays #0 0 1
 111 def b checkride #0 #1 1 1
 112 def B checkride #0 #1 1 1
 113 def bL rays #0 1 1
 114 def BL rays #0 1 1
 115 def ss checkaride #0 #1 0 1 and <= distance #0 #1 2 or checkleap #0 #1 0 1 or checkaride #0 #1 1 0 or checkaride #0 #1 -1 0
 116 def SS checkaride #0 #1 0 -1 and <= distance #0 #1 2 or checkleap #0 #1 0 1 or checkaride #0 #1 1 0 or checkaride #0 #1 -1 0
 117 def ssL rays #0 0 1
 118 def SSL rays #0 0 1
 119 def vs checkaride #0 #1 1 0 or checkaride #0 #1 -1 0 and <= distance #0 #1 2 or checkleap #0 #1 0 1 or checkaride #0 #1 0 1
 120 def VS checkaride #0 #1 1 0 or checkaride #0 #1 -1 0 and <= distance #0 #1 2 or checkleap #0 #1 0 1 or checkaride #0 #1 0 -1
 121 def vsL rays #0 0 1
 122 def VSL rays #0 0 1
 123 def r checkride #0 #1 0 1
 124 def R checkride #0 #1 0 1
 125 def rL rays #0 0 1
 126 def RL rays #0 0 1
 127 def dh fn b #0 #1 or checkleap #0 #1 0 1
 128 def DH fn B #0 #1 or checkleap #0 #1 0 1
 129 def dhL merge rays #0 1 1 leaps #0 0 1
 130 def DHL merge rays #0 1 1 leaps #0 0 1
 131 def dk fn r #0 #1 or checkleap #0 #1 1 1
 132 def DK fn R #0 #1 or checkleap #0 #1 1 1
 133 def dkL merge rays #0 0 1 leaps #0 1 1
 134 def DKL merge rays #0 0 1 leaps #0 1 1
 135 def cs checkride #0 #1 0 1 and <= distance #0 #1 2 or checkride #0 #1 1 1 or checkaride #0 #1 0 1 or checkaride #0 #1 0 -1
 136 def CS checkride #0 #1 0 1 and <= distance #0 #1 2 or checkride #0 #1 1 1 or checkaride #0 #1 0 1 or checkaride #0 #1 0 -1
 137 def csL merge rays #0 0 1 rays #0 1 1
 138 def CSL merge rays #0 0 1 rays #0 1 1
 139 def hf cond == 0 var phase (checkride #0 #1 1 1 or checkaride #0 #1 -1 0 or checkaride #0 #1 1 0 or checkaride #0 #1 0 -1 or checkleap #0 #1 0 1 or checkaleap #0 #1 0 2) (checkaleap #0 #1 0 1 or checkaleap #0 #1 0 -1) and #0 and #1
 140 def HF cond == 0 var phase (checkride #0 #1 1 1 or checkaride #0 #1 -1 0 or checkaride #0 #1 1 0 or checkaride #0 #1 0 1 or checkleap #0 #1 0 1 or checkaleap #0 #1 0 -2) (checkaleap #0 #1 0 1 or checkaleap #0 #1 0 -1) and #0 and #1
 141 def hfL mergeall rays #0 0 1 rays #0 1 1 leaps #0 0 2
 142 def HFL mergeall rays #0 0 1 rays #0 1 1 leaps #0 0 2
 143 def se cond == 0 var phase (checkride #0 #1 0 1 or checkaride #0 #1 -1 -1 or checkaride #0 #1 1 -1 or checkleap #0 #1 1 1 or checkaleap #0 #1 -2 2 or checkaleap #0 #1 2 2) (sub SE #0 #1) and #0 and #1
 144 def SE cond == 0 var phase (checkride #0 #1 0 1 or checkaride #0 #1 -1 1 or checkaride #0 #1 1 1 or checkleap #0 #1 1 1 or checkaleap #0 #1 -2 -2 or checkaleap #0 #1 2 -2) (sub SE #0 #1) and #0 and #1
 145 def seL mergeall rays #0 0 1 rays #0 1 1 leaps #0 2 2
 146 def SEL mergeall rays #0 0 1 rays #0 1 1 leaps #0 2 2
 147 def ln <= distance #0 #1 cond == 0 var phase 2 1
 148 copyfn ln LN
 149 def lnL mergeall leaps #0 0 1 leaps #0 1 1 leaps #0 0 2 leaps #0 1 2 leaps #0 2 2
 150 def LNL mergeall leaps #0 0 1 leaps #0 1 1 leaps #0 0 2 leaps #0 1 2 leaps #0 2 2
 151 def q fn r #0 #1 or fn b #0 #1
 152 def Q fn R #0 #1 or fn B #0 #1
 153 def qL merge rays #0 0 1 rays #0 1 1
 154 def QL merge rays #0 0 1 rays #0 1 1
 155 def bg sub DIAGRANGEJUMP #0 #1 and sub canrangejump #0 #1 1 or checkride #0 #1 1 1
 156 copyfn bg BG
 157 def bgL rays #0 1 1
 158 def BGL rays #0 1 1
 159 def rg sub ORTHORANGEJUMP #0 #1 and sub canrangejump #0 #1 1 or checkride #0 #1 0 1
 160 copyfn rg RG
 161 def rgL rays #0 0 1
 162 def RGL rays #0 0 1
 163 def wb checkride #0 #1 0 1 and <= distance #0 #1 2 or checkride #0 #1 1 1 or checkaride #0 #1 1 0 or checkaride #0 #1 -1 0
 164 copyfn wb WB
 165 def wbL merge rays #0 0 1 rays #0 1 1
 166 def WBL merge rays #0 0 1 rays #0 1 1
 167 def fe cond == 0 var phase (fn q #0 #1 or checkleap #0 #1 0 2 or checkleap #0 #1 2 2) (checkleap #0 #1 1 1) and #0 and #1
 168 copyfn fe FE
 169 def feL mergeall rays #0 0 1 rays #0 1 1 leaps #0 0 2 leaps #0 2 2
 170 def FEL mergeall rays #0 0 1 rays #0 1 1 leaps #0 0 2 leaps #0 2 2
 171 def lh cond == 0 var phase (<= distance #0 #1 2 or fn b #0 #1) (checkleap #0 #1 0 1 or checkleap #0 #1 1 1) and #0 and #1
 172 copyfn lh LH
 173 def lhL mergeall rays #0 1 1 leaps #0 0 1 leaps #0 0 2 leaps #0 1 2 leaps #0 2 2
 174 def LHL mergeall rays #0 1 1 leaps #0 0 1 leaps #0 0 2 leaps #0 1 2 leaps #0 2 2
 175 def vg cond == 0 var phase (sub DIAGRANGEJUMP #0 #1 and sub canrangejump #0 #1 2 or checkride #0 #1 1 1 or checkmaxsteps #0 #1 3) (checkleap #0 #1 0 1 or checkleap #0 #1 1 1 and == var ori #1) and #0 and #1
 176 copyfn vg VG
 177 def vgL mergeall rays #0 1 1 leaps #0 0 1 leaps #0 0 2 leaps #0 1 2 leaps #0 2 2 leaps #0 0 3 leaps #0 1 3 leaps #0 2 3 leaps #0 3 3
 178 def VGL mergeall rays #0 1 1 leaps #0 0 1 leaps #0 0 2 leaps #0 1 2 leaps #0 2 2 leaps #0 0 3 leaps #0 1 3 leaps #0 2 3 leaps #0 3 3
 179 def gg sub ORTHORANGEJUMP #0 #1 or sub DIAGRANGEJUMP #0 #1 and sub canrangejump #0 #1 3 or checkride #0 #1 0 1 or checkride #0 #1 1 1
 180 copyfn gg GG
 181 def ggL merge rays #0 0 1 rays #0 1 1
 182 def GGL merge rays #0 0 1 rays #0 1 1
 183 def fd cond == 0 var phase (checkride #0 #1 1 1 or checkaride #0 #1 -1 0 or checkaride #0 #1 1 0 or checkmaxsteps #0 #1 3) (sub FD #0 #1) and #0 and #1
 184 copyfn fd FD
 185 def fdL mergeall rays #0 0 1 rays #0 1 1 leaps #0 0 2 leaps #0 1 2 leaps #0 2 2 leaps #0 0 3 leaps #0 1 3 leaps #0 2 3 leaps #0 3 3
 186 def FDL mergeall rays #0 0 1 rays #0 1 1 leaps #0 0 2 leaps #0 1 2 leaps #0 2 2 leaps #0 0 3 leaps #0 1 3 leaps #0 2 3 leaps #0 3 3
 187 copyfn g +p
 188 copyfn G +P
 189 copyfn gL +pL
 190 copyfn GL +PL
 191 def +d checkaride #0 #1 0 1 or checkaride #0 #1 -1 -1 or checkaride #0 #1 1 -1
 192 def +D checkaride #0 #1 0 -1 or checkaride #0 #1 -1 1 or checkaride #0 #1 1 1
 193 def +dL mergeall ray #0 0 1 ray #0 -1 -1 ray #0 1 -1
 194 def +DL mergeall ray #0 0 -1 ray #0 -1 1 ray #0 1 1
 195 copyfn ss +n
 196 copyfn SS +N
 197 copyfn ssL +nL
 198 copyfn SSL +NL
 199 copyfn vs +i
 200 copyfn VS +I
 201 copyfn vsL +iL
 202 copyfn VSL +IL
 203 copyfn sm +c
 204 copyfn SM +C
 205 copyfn smL +cL
 206 copyfn SML +CL
 207 copyfn vm +s
 208 copyfn VM +S
 209 copyfn vmL +sL
 210 copyfn VML +SL
 211 def +bt checkaride #0 #1 0 1 or checkaride #0 #1 0 -1 or checkleap #0 #1 0 1 or checkleap #0 #1 1 1
 212 copyfn +bt +BT
 213 def +btL mergeall ray #0 0 1 ray #0 0 -1 leaps #0 0 1 leaps #0 1 1
 214 def +BTL mergeall ray #0 0 1 ray #0 0 -1 leaps #0 0 1 leaps #0 1 1
 215 copyfn b +fl
 216 copyfn B +FL
 217 copyfn bL +flL
 218 copyfn BL +FLL
 219 copyfn r +g
 220 copyfn R +G
 221 copyfn rL +gL
 222 copyfn RL +GL
 223 def +de checkleap #0 #1 0 1 or checkleap #0 #1 1 1
 224 copyfn +de +DE
 225 def +deL merge leaps #0 0 1 leaps #0 1 1
 226 def +DEL merge leaps #0 0 1 leaps #0 1 1
 227 def +rv checkaride #0 #1 0 1 or checkaride #0 #1 0 -1 or checkaride #0 #1 -1 -1 or checkaride #0 #1 1 -1
 228 def +RV checkaride #0 #1 0 1 or checkaride #0 #1 0 -1 or checkaride #0 #1 -1 1 or checkaride #0 #1 1 1
 229 def +rvL mergeall ray #0 0 1 ray #0 0 -1 ray #0 -1 -1 ray #0 1 -1
 230 def +RVL mergeall ray #0 0 1 ray #0 0 -1 ray #0 -1 1 ray #0 1 1
 231 def +l checkaride #0 #1 0 1 or checkaride #0 #1 0 -1 or checkaride #0 #1 -1 1 or checkaride #0 #1 1 1
 232 def +L checkaride #0 #1 0 1 or checkaride #0 #1 0 -1 or checkaride #0 #1 -1 -1 or checkaride #0 #1 1 -1
 233 def +lL mergeall ray #0 0 1 ray #0 0 -1 ray #0 -1 1 ray #0 1 1
 234 def +LL mergeall ray #0 0 1 ray #0 0 -1 ray #0 -1 -1 ray #0 1 -1
 235 copyfn ln +ky
 236 copyfn LN +KY
 237 copyfn lnL +kyL
 238 copyfn LNL +KYL
 239 copyfn q +ph
 240 copyfn Q +PH
 241 copyfn qL +phL
 242 copyfn QL +PHL
 243 def +sm checkride #0 #1 1 1 or checkaride #0 #1 -1 0 or checkaride #0 #1 1 0
 244 copyfn +sm +SM
 245 def +sm$L merge rays #0 0 1 rays #0 1 1
 246 def +SML merge rays #0 0 1 rays #0 1 1
 247 def +vm checkride #0 #1 1 1 or checkaride #0 #1 0 -1 or checkaride #0 #1 0 1
 248 copyfn +vm +VM
 249 def +vmL merge rays #0 0 1 rays #0 1 1
 250 def +VML merge rays #0 0 1 rays #0 1 1
 251 copyfn dh +b
 252 copyfn DH +B
 253 copyfn dhL +bL
 254 copyfn DHL +BL
 255 copyfn wb +ss
 256 copyfn WB +SS
 257 copyfn wbL +ssL
 258 copyfn WBL +SSL
 259 copyfn cs +vs
 260 copyfn CS +VS
 261 copyfn csL +vsL
 262 copyfn CSL +VSL
 263 copyfn dk +r
 264 copyfn DK +R
 265 copyfn dkL +rL
 266 copyfn DKL +RL
 267 copyfn hf +dh
 268 copyfn HF +DH
 269 copyfn hfL +dhL
 270 copyfn HFL +DHL
 271 copyfn se +dk
 272 copyfn SE +DK
 273 copyfn seL +dkL
 274 copyfn SEL +DKL
 275 def +cs cond == 0 var phase (checkleap #0 #1 0 1 or checkleap #0 #1 1 1 and cond empty #0 capture (not empty #1) or fn NO #0 #1 or fn NE #0 #1 or fn EA #0 #1 or fn SED #0 #1 or fn SO #0 #1 or fn SW #0 #1 or fn WE #0 #1 or fn NW #0 #1) (sub HT #0 #1) and #0 and #1
 276 copyfn +cs +CS
 277 def +csL mergeall leaps #0 0 1 leaps #0 1 1 leaps #0 1 2 lograys #0 (n2 n) (ne2 ne) (e2 e stop) (se2 se) (s2 s) (sw2 sw) (w2 w stop) (nw2 nw)
 278 def +CSL mergeall leaps #0 0 1 leaps #0 1 1 leaps #0 1 2 lograys #0 (n2 n) (ne2 ne) (e2 e stop) (se2 se) (s2 s) (sw2 sw) (w2 w stop) (nw2 nw)
 279 copyfn bg +hf
 280 copyfn BG +HF
 281 copyfn bgL +hfL
 282 copyfn BGL +HFL
 283 copyfn rg +se
 284 copyfn RG +SE
 285 copyfn rgL +seL
 286 copyfn RGL +SEL
 287 copyfn lh +ln
 288 copyfn LH +LN
 289 copyfn lhL +lnL
 290 copyfn LHL +LNL
 291 copyfn fe +q
 292 copyfn FE +Q
 293 copyfn feL +qL
 294 copyfn FEL +QL
 295 copyfn vg +bg
 296 copyfn VG +BG
 297 copyfn vgL +bgL
 298 copyfn VGL +BGL
 299 copyfn gg +rg
 300 copyfn GG +RG
 301 copyfn ggL +rgL
 302 copyfn GGL +RGL
 303 copyfn fd +wb
 304 copyfn FD +WB
 305 copyfn fdL +wbL
 306 copyfn FDL +WBL
 307 def k checkleap #0 #1 0 1 or checkleap #0 #1 1 1
 308 copyfn k K
 309 def kL merge leaps #0 0 1 leaps #0 1 1
 310 def KL merge leaps #0 0 1 leaps #0 1 1
 311 sub FD from to
 312   if cond empty #from (match old (fd FD +wb +WB) and capture) (match space #to (fd FD +wb +WB) and not empty #to) and != var ori #from
 313     return false
 314   endif
 315   if == 1 var phase
 316     return cond cond empty #from capture (not empty #to) (checkleap #from #to 0 1 or checkleap #from #to 1 1) (== var ori #to and <= distance #from #to 1) and #to
 317   elseif == 2 var phase
 318     if == var ori #from
 319       return checkleap #from #to 0 1 or checkleap #from #to 1 1 and cond empty #from capture (not empty #to)
 320     else
 321       return <= distance #from #to 2 and <= distance #dst #to 1 and cond empty #from capture (not empty #to) or == var dst #to
 322     endif
 323   endif
 324 endsub
 325 sub HT from to
 326   return <= distance #from #to 2 and == distance #ori #to 1 and cond empty #from capture (not empty #to)
 327 endsub
 328 sub ORTHORANGEJUMP from to
 329   local step, cnt, i
 330   if != file #from file #to and != rank #from rank #to
 331     return false
 332   endif
 333   verify cond empty #from capture (not empty #to) and #to
 334   set step #from
 335   set cnt 0
 336   do
 337     for i #steps
 338       set step where #step cmp file #to file #from cmp rank #to rank #from
 339       if == #step #to
 340         return true
 341       endif
 342       if != @ space #step
 343         set cnt inc #cnt
 344       endif
 345       if >= #cnt 3
 346         return false
 347       endif
 348     next
 349   loop never
 350 endsub
 351 sub DIAGRANGEJUMP from to
 352   local step, cnt, i
 353   if != abs - file #from file #to abs - rank #from rank #to
 354     return false
 355   endif
 356   verify cond empty #from capture (not empty #to) and #to
 357   set step #from
 358   set cnt 0
 359   do
 360     for i #steps
 361       set step where #step cmp file #to file #from cmp rank #to rank #from
 362       if == #step #to
 363         return true
 364       endif
 365       if != @ space #step
 366         set cnt inc #cnt
 367       endif
 368       if >= #cnt 3
 369         return false
 370       endif
 371     next
 372   loop never
 373 endsub
 374 sub SE from to
 375   if > slope origin dest 0
 376     return checkaleap #from #to 1 1 or checkaleap #from #to -1 -1
 377   else
 378     return checkaleap #from #to 1 -1 or checkaleap #from #to -1 1
 379   endif
 380 endsub
 381 sub canburn from to kingpos
 382   if fn K #from #to && == 0 var phase
 383     return true
 384   else
 385     if isupper #kingpos
 386       def enemy match #0 #bpieces and not match #0 fd +wb
 387     else
 388       def enemy match #0 #wpieces and not match #0 FD +WB
 389     endif
 390     set north where #to 0 1
 391     set east where #to 1 0
 392     set south where #to 0 -1
 393     set west where #to -1 0
 394     set northeast where #to 1 1
 395     set southeast where #to 1 -1
 396     set southwest where #to -1 -1
 397     set northwest where #to -1 1
 398     if fn enemy space #north
 399       return true
 400     elseif fn enemy space #northeast
 401       return true
 402     elseif fn enemy space #east
 403       return true
 404     elseif fn enemy space #southeast
 405       return true
 406     elseif fn enemy space #south
 407       return true
 408     elseif fn enemy space #southwest
 409       return true
 410     elseif fn enemy space #west
 411       return true
 412     elseif fn enemy space #northwest
 413       return true
 414     else
 415       return false
 416     endif
 417   endif
 418 endsub
 419 sub canrangecapture from to kingpos
 420   verify match moved bg BG +hf +HF rg RG +se +SE vg VG +bg +BG gg GG +rg +RG
 421   if match moved bg BG +hf +HF vg VG +bg +BG
 422     verify == abs - file #from file #to abs - rank #from rank #to
 423     set jrank cond match moved (bg BG +hf +HF) 1 2
 424   elseif match moved rg RG +se +SE
 425     verify == file #from file #to or == rank #from rank #to
 426     set jrank 1
 427   elseif match moved gg GG +rg +RG
 428     verify == file #from file #to or == rank #from rank #to or == abs - file #from file #to abs - rank #from rank #to
 429     set jrank 3
 430   endif
 431   verify sub canrangejump #from #to #jrank
 432   set cx cmp file #to file #from
 433   set cy cmp rank #to rank #from
 434   verify not checkride #from #to #cx #cy
 435   if isupper #kingpos
 436     def enemy match #0 #bpieces
 437   else
 438     def enemy match #0 #wpieces
 439   endif
 440   set firstscreen false
 441   set secondscreen false
 442   local step, cnt, i
 443   set step #from
 444   set ecnt 0
 445   set canrc false
 446   do
 447     for i #steps
 448       set step where #step #cx #cy
 449       if == #step #to
 450         break
 451       endif
 452       if fn enemy space #step
 453         set ecnt inc #ecnt
 454         if == #ecnt 1
 455           set firstscreen #step
 456         elseif == #ecnt 2
 457           set secondscreen #step
 458         endif
 459       endif
 460     next
 461   loop never
 462   return cond > #ecnt 0 true false
 463 endsub
 464 sub canrangejump from to jrank
 465   if == #jrank 1
 466     def barriers match #0 (bg BG +hf +HF rg RG +se +SE vg VG +bg +BG gg GG +rg +RG k K +de +DE)
 467   elseif == #jrank 2
 468     def barriers match #0 (vg VG +bg +BG gg GG +rg +RG k K +de +DE)
 469   elseif == #jrank 3
 470     def barriers match #0 (gg GG +rg +RG k K +de +DE)
 471   else
 472     return false
 473   endif
 474   set cx cmp file #to file #from
 475   set cy cmp rank #to rank #from
 476   local step, cnt, i
 477   set step #from
 478   do
 479     for i #steps
 480       set step where #step #cx #cy
 481       if == #step #to
 482         break
 483       endif
 484       if fn barriers space #step
 485         return false
 486       endif
 487     next
 488   loop never
 489   return true
 490 endsub
 491 sub rangecapture from to kingpos
 492   verify sub canrangecapture #from #to #kingpos
 493   if not fnmatch *pass* thismove and not fnmatch *one* thismove and not fnmatch *two* thismove
 494     if == #secondscreen true
 495       ask "Which pieces will you capture?" "None" "pass" "First screen only" "one" "Second screen only" "two" "Both screens" "onetwo"
 496     else
 497       ask "Which pieces will you capture?" "None" "pass" "Screen" "one"
 498     endif
 499   endif
 500   if fnmatch *one* thismove
 501     empty #firstscreen
 502   endif
 503   if fnmatch *two* thismove
 504     if == #secondscreen false
 505       die "No second screen available to capture."
 506     else
 507       empty #secondscreen
 508     endif
 509   endif
 510   return true
 511 endsub
 512 sub one
 513   return true
 514 endsub
 515 sub two
 516   return true
 517 endsub
 518 sub onetwo
 519   return true
 520 endsub
 521 sub stalemated kingpos
 522   store
 523   local from piece to
 524   if isupper #kingpos
 525     def friends intersection nolower #wpieces
 526     def friend match #0 #wpieces
 527     def FREEZER +cs
 528     def FREEZEIMMUNE +CS
 529   else
 530     def friends intersection noupper #bpieces
 531     def friend match #0 #bpieces
 532     def FREEZER +CS
 533     def FREEZEIMMUNE +cs
 534   endif
 535   set phase 0
 536   store
 537   for (from piece) fn friends
 538     for to fn join #piece L #from
 539       if fn #piece #from #to and not fn friend space #to and onboard #to
 540         if fn neighbor #from fn FREEZER and != #piece fn FREEZEIMMUNE
 541           continue
 542         endif
 543         move #from #to
 544         setlegal #from #to
 545       endif
 546       restore
 547     next
 548   next
 549   return cond count system legalmoves false true
 550 endsub
 551 sub legalmoves2 kingpos movephase
 552   store
 553   local from piece to
 554   if isupper #kingpos
 555     def friends intersection nolower #wpieces
 556     def friend match #0 #wpieces
 557   else
 558     def friends intersection noupper #bpieces
 559     def friend match #0 #bpieces
 560   endif
 561   set phase #movephase
 562   set oldto dest
 563   store
 564   for (from piece) fn friends
 565     if == #from #oldto
 566       for to fn join #piece L #from
 567         if fn #piece #from #to and not fn friend space #to and onboard #to
 568           move #from #to
 569           setlegal #from #to
 570         endif
 571         restore
 572       next
 573     endif
 574   next
 575   return cond count system legalmoves false true
 576 endsub
 577 sub ismultimove
 578   if == 0 var phase
 579     if match moved fd +wb and sub canburn origin dest king
 580       return true
 581     elseif match moved FD +WB and sub canburn origin dest KING
 582       return true
 583     elseif checkleap origin dest 0 1 or checkleap origin dest 1 1 and match moved ln LN lh LH vg VG +ky +KY +ln +LN +bg +BG +cs +CS
 584       if match moved vg VG +bg +BG and capture
 585         return false
 586       else
 587         return true
 588       endif
 589     elseif checkleap origin dest 1 1 and match moved fe FE +q +Q
 590       return true
 591     elseif checkaleap origin dest 0 1 and match moved hf +dh
 592       return true
 593     elseif checkaleap origin dest 0 -1 and match moved HF +DH
 594       return true
 595     elseif checkaleap origin dest -1 1 or checkaleap origin dest 1 1 and match moved se +dk
 596       return true
 597     elseif checkaleap origin dest -1 -1 or checkaleap origin dest 1 -1 and match moved SE +DK
 598       return true
 599     else
 600       return false
 601     endif
 602   elseif == 1 var phase
 603     if match moved fd +wb and var firstcapture
 604       if == var ori dest and not sub canburn origin dest king
 605         return false
 606       else
 607         return true
 608       endif
 609     elseif match moved FD +WB and var firstcapture
 610       if == var ori dest and not sub canburn origin dest KING
 611         return false
 612       else
 613         return true
 614       endif
 615     endif
 616   endif
 617 endsub
 618 sub bpromotion
 619   verify not sub ismultimove
 620   if onboard where #ori 0 #pzs and onboard where dest 0 #pzs
 621     return false
 622   elseif not match moved p d n i c s bt fl g de rv l ky ph sm vm b ss vs r dh dk cs hf se ln q bg rg wb
 623     return false
 624   else
 625     return true
 626   endif
 627 endsub
 628 sub wpromotion
 629   verify not sub ismultimove
 630   if onboard where #ori 0 neg #pzs and onboard where dest 0 neg #pzs
 631     return false
 632   elseif not match moved P D N I C S BT FL G DE RV L KY PH SM VM B SS VS R DH DK CS HF SE LN Q BG RG WB
 633     return false
 634   else
 635     return true
 636   endif
 637 endsub
 638 sub bpromote
 639   set legal false
 640   if == 0 var phase and fn neighbor origin +CS and != moved +cs
 641     return false
 642   endif
 643   verify fn moved origin dest
 644   if != space dest moved and sub ismultimove
 645     die "You may not promote any piece without completing your move."
 646   elseif != space dest moved and onboard where #ori 0 #pzs and onboard where dest 0 #pzs
 647     die "You may not promote any piece without entering or exiting the promotion zone."
 648   elseif not onboard where #ori 0 #pzs or not onboard where dest 0 #pzs
 649     if == moved space dest and not fnmatch *-dest* thismove and match moved p d n i c s bt fl g de rv l ky ph sm vm b ss vs r dh dk cs hf se ln q bg rg wb and not sub ismultimove
 650       set pc moved
 651       set pm elem moved promote
 652       askpromote #pm #pc
 653     elseif != moved space dest and != elem moved promote space dest
 654       set np space dest
 655       die "You may not promote a" moved "to a" #np
 656     endif
 657   endif
 658   gosub rangecapture #ori dest king
 659   set legal true
 660   return true
 661 endsub
 662 sub wpromote
 663   set legal false
 664   if == 0 var phase and fn neighbor origin +cs and != moved +CS
 665     return false
 666   endif
 667   verify fn moved origin dest
 668   if != space dest moved and sub ismultimove
 669     die "You may not promote any piece without completing your move."
 670   elseif != space dest moved and onboard where #ori 0 neg #pzs and onboard where dest 0 neg #pzs
 671     die "You may not promote any piece without entering or exiting the promotion zone."
 672   elseif not onboard where #ori 0 neg #pzs or not onboard where dest 0 neg #pzs
 673     if == moved space dest and not fnmatch *-dest* thismove and match moved P D N I C S BT FL G DE RV L KY PH SM VM B SS VS R DH DK CS HF SE LN Q BG RG WB and not sub ismultimove
 674       set pc moved
 675       set pm elem moved promote
 676       askpromote #pm #pc
 677     elseif != moved space dest and != elem moved promote space dest
 678       set np space dest
 679       die "You may not promote a" moved "to a" #np
 680     endif
 681   endif
 682   gosub rangecapture #ori dest KING
 683   set legal true
 684   return true
 685 endsub
 686 sub preauto1
 687   store
 688 endsub
 689 sub preauto2
 690   store
 691 endsub
 692 sub postauto1
 693   set mvs explode chr 59 thismove
 694   restore
 695   set i 0
 696   set phase 0
 697   set firstcapture false
 698   eval join "MOVE: " trim elem var i mvs
 699   if match old #bpieces
 700     die You may not capture your own pieces.
 701   endif
 702   set ori origin
 703   set dst dest
 704   if sub bpromotion
 705     inc i
 706     if < var i count var mvs
 707       set ori2 origin
 708       set dst2 dest
 709       eval join "MOVE: " trim elem var i mvs
 710       if != var dst2 dest or != var ori2 origin or match (pass one two onetwo) trim elem var i mvs
 711         die Only a promotion can immediately follow a promotable piece moving to or from the promotion zone.
 712       endif
 713     endif
 714   endif
 715   if sub canrangecapture origin dest king
 716     inc i
 717     if < var i count var mvs
 718       eval join "MOVE: " trim elem var i mvs
 719       if not match (pass one two onetwo) trim elem var i mvs
 720         die Only pass, one, two, or onetwo can immediately follow a potential range capture.
 721       endif
 722     endif
 723   endif
 724   set legal false
 725   switch moved
 726     case p +p d +d n +n i +i c +c s +s bt +bt fl +fl g +g de +de rv +rv l +l ky +ky ph +ph sm +sm vm +vm b +b ss +ss vs +vs r +r dh +dh dk +dk cs +cs hf +hf se +se ln +ln q +q bg +bg rg +rg wb +wb fe lh vg gg fd k
 727     gosub bpromote
 728     break
 729     default
 730     die You may not move a moved
 731   endswitch
 732   if not var legal
 733     die You may not move a moved from origin to dest
 734   endif
 735   if capture
 736     set firstcapture true
 737   endif
 738   if == 0 var phase and sub ismultimove
 739     inc i
 740     do while < var i count var mvs
 741       set phase 1
 742       set mv trim elem var i mvs
 743       if match var mv (one two onetwo)
 744         die one, two, and onetwo may only be used when the move is a potential range capture.
 745       endif
 746       if == var mv pass
 747         if sub bpromotion
 748           inc i
 749           if < var i count var mvs
 750             set ori2 origin
 751             set dst2 dest
 752             eval join "MOVE: " trim elem var i mvs
 753             if != var dst2 dest or != var ori2 origin or match (pass one two onetwo) trim elem var i mvs
 754               die Only a promotion can immediately follow a promotable piece moving to or from the promotion zone.
 755             endif
 756           endif
 757         elseif == moved +cs and fn k origin dest
 758           add moved origin
 759           empty dest
 760         endif
 761         gosub bpromote
 762         break
 763       endif
 764       eval join "MOVE: " var mv
 765       if match old #bpieces
 766         die You may not capture your own pieces.
 767       elseif != var dst origin
 768         die You may not move more than one piece per turn.
 769       endif
 770       if sub bpromotion
 771         inc i
 772         if < var i count var mvs
 773           set ori2 origin
 774           set dst2 dest
 775           eval join "MOVE: " trim elem var i mvs
 776           if != var dst2 dest or != var ori2 origin or match (pass one two onetwo) trim elem var i mvs
 777             die Only a promotion can immediately follow a promotable piece moving to or from the promotion zone.
 778           endif
 779         endif
 780       endif
 781       set legal false
 782       switch moved
 783         case hf +dh se +dk ln +ky fe +q lh +ln vg +bg fd +wb +cs
 784         gosub bpromote
 785         break
 786         default
 787         die You may not move a moved
 788       endswitch
 789       if not var legal
 790         die You may not move a moved from origin to dest
 791       elseif == moved +cs and != var ori dest and == distance #ori #dst 1
 792         add moved #ori
 793         empty dest
 794       endif
 795       if capture
 796         set firstcapture true
 797       endif
 798       set dst1 dest
 799     loop never
 800   endif
 801   if == 1 var phase and sub ismultimove
 802     inc i
 803     do while < var i count var mvs
 804       set phase 2
 805       set mv trim elem var i mvs
 806       if match var mv (one two onetwo)
 807         die one, two, and onetwo may only be used when the move is a potential range capture.
 808       endif
 809       if == var mv pass
 810         if match moved fd +wb != var ori dest and not checkleap #ori #dst 0 1 and not checkleap #ori #dst 1 1
 811           die Pass may only be used on the third part of a Fire Demon's move to disambiguate single igui and double igui.
 812         endif
 813         gosub bpromote
 814         break
 815       endif
 816       eval join "MOVE: " var mv
 817       if match old #bpieces
 818         die You may not capture your own pieces.
 819       elseif != var dst1 origin
 820         die You may not move more than one piece per turn.
 821       endif
 822       set legal false
 823       switch moved
 824         case fd +wb
 825         gosub bpromote
 826         break
 827         default
 828         die You may not move a moved
 829       endswitch
 830       if not var legal
 831         die You may not move a moved from origin to dest
 832       elseif match moved fd +wb
 833         if == var ori origin
 834           add moved origin
 835           empty dest
 836         else
 837           if != var dst dest
 838             add moved #dst
 839             empty dest
 840           endif
 841         endif
 842       endif
 843     loop never
 844   endif
 845   if != #ori dest
 846     set bskips 0
 847   elseif != space dest moved
 848     set bskips 0
 849   elseif var firstcapture
 850     set bskips 0
 851   else
 852     inc bskips
 853   endif
 854   inc i
 855   if < var i count var mvs
 856     die Too many moves.
 857   endif
 858   set posvar join "b" join fencode boardflags
 859   inc #posvar
 860 endsub
 861 sub postauto2
 862   set mvs explode chr 59 thismove
 863   restore
 864   set i 0
 865   set phase 0
 866   set firstcapture false
 867   eval join "MOVE: " trim elem var i mvs
 868   if match old #wpieces
 869     die You may not capture your own pieces.
 870   endif
 871   set ori origin
 872   set dst dest
 873   if sub wpromotion
 874     inc i
 875     if < var i count var mvs
 876       set ori2 origin
 877       set dst2 dest
 878       eval join "MOVE: " trim elem var i mvs
 879       if != var dst2 dest or != var ori2 origin or match (pass one two onetwo) trim elem var i mvs
 880         die Only a promotion can immediately follow a promotable piece moving to or from the promotion zone.
 881       endif
 882     endif
 883   endif
 884   if sub canrangecapture origin dest KING
 885     inc i
 886     if < var i count var mvs
 887       set mv trim elem var i mvs
 888       if not match var mv (pass one two onetwo)
 889         die Only pass, one, two, or onetwo can immediately follow a potential range capture.
 890       endif
 891     endif
 892   endif
 893   set legal false
 894   switch moved
 895     case P +P D +D N +N I +I C +C S +S BT +BT FL +FL G +G DE +DE RV +RV L +L KY +KY PH +PH SM +SM VM +VM B +B SS +SS VS +VS R +R DH +DH DK +DK CS +CS HF +HF SE +SE LN +LN Q +Q BG +BG RG +RG WB +WB FE LH VG GG FD K
 896     gosub wpromote
 897     break
 898     default
 899     die You may not move a moved
 900   endswitch
 901   if not var legal
 902     die You may not move a moved from origin to dest
 903   endif
 904   if capture
 905     set firstcapture true
 906   endif
 907   if == 0 var phase and sub ismultimove
 908     inc i
 909     do while < var i count var mvs
 910       set phase 1
 911       set mv trim elem var i mvs
 912       if match var mv (one two onetwo)
 913         die one, two, and onetwo may only be used when the move is a potential range capture.
 914       endif
 915       if == var mv pass
 916         if sub wpromotion
 917           inc i
 918           if < var i count var mvs
 919             set ori2 origin
 920             set dst2 dest
 921             eval join "MOVE: " trim elem var i mvs
 922             if != var dst2 dest or != var ori2 origin
 923               die Only a promotion can immediately follow a promotable piece moving to or from the promotion zone.
 924             endif
 925           endif
 926         elseif == moved +CS and fn K origin dest
 927           add moved origin
 928           empty dest
 929         endif
 930         gosub wpromote
 931         break
 932       endif
 933       eval join "MOVE: " var mv
 934       if match old #wpieces
 935         die You may not capture your own pieces.
 936       elseif != var dst origin
 937         die You may not move more than one piece per turn.
 938       endif
 939       if sub wpromotion
 940         inc i
 941         if < var i count var mvs
 942           set ori2 origin
 943           set dst2 dest
 944           eval join "MOVE: " trim elem var i mvs
 945           if != var dst2 dest or != var ori2 origin or match (pass one two onetwo) trim elem var i mvs
 946             die Only a promotion can immediately follow a promotable piece moving to or from the promotion zone.
 947           endif
 948         endif
 949       endif
 950       set legal false
 951       switch moved
 952         case HF +DH SE +DK LN +KY FE +Q LH +LN VG +BG FD +WB +CS
 953         gosub wpromote
 954         break
 955         default
 956         die You may not move a moved
 957       endswitch
 958       if not var legal
 959         die You may not move a moved from origin to dest
 960       elseif == moved +CS and != var ori dest and == distance #ori #dst 1
 961         add moved #ori
 962         empty dest
 963       endif
 964       if capture
 965         set firstcapture true
 966       endif
 967       set dst1 dest
 968     loop never
 969   endif
 970   if == 1 var phase and sub ismultimove
 971     inc i
 972     do while < var i count var mvs
 973       set phase 2
 974       set mv trim elem var i mvs
 975       if match var mv (one two onetwo)
 976         die one, two, and onetwo may only be used when the move is a potential range capture.
 977       endif
 978       if == var mv pass
 979         if match moved FD +WB != var ori dest and not checkleap #ori #dst 0 1 and not checkleap #ori #dst 1 1
 980           die Pass may only be used on the third part of a Fire Demon's move to disambiguate single igui and double igui.
 981         endif
 982         gosub wpromote
 983         break
 984       endif
 985       eval join "MOVE: " var mv
 986       if match old #wpieces
 987         die You may not capture your own pieces.
 988       elseif != var dst1 origin
 989         die You may not move more than one piece per turn.
 990       endif
 991       set legal false
 992       switch moved
 993         case FD +WB
 994         gosub wpromote
 995         break
 996         default
 997         die You may not move a moved
 998       endswitch
 999       if not var legal
1000         die You may not move a moved from origin to dest
1001       elseif match moved FD +WB
1002         if == var ori origin
1003           add moved origin
1004           empty dest
1005         else
1006           if != var dst dest
1007             add moved #dst
1008             empty dest
1009           endif
1010         endif
1011       endif
1012     loop never
1013   endif
1014   if != #ori dest
1015     set wskips 0
1016   elseif != space dest moved
1017     set wskips 0
1018   elseif var firstcapture
1019     set wskips 0
1020   else
1021     inc wskips
1022   endif
1023   inc i
1024   if < var i count var mvs
1025     die Too many moves.
1026   endif
1027   set posvar join "w" join fencode boardflags
1028   inc #posvar
1029 endsub
1030 preauto1
1031 moveindex 1
1032 MOVE: d 12k-12j
1033 postauto1
1034 preauto2
1035 moveindex 2
1036 MOVE: P 10e-10f
1037 postauto2
1038 preauto1
1039 moveindex 3
1040 MOVE: d 5k-5j
1041 postauto1
1042 preauto2
1043 moveindex 4
1044 MOVE: BG 11d-9f
1045 postauto2
1046 preauto1
1047 moveindex 5
1048 MOVE: p 12l-12k
1049 postauto1
1050 preauto2
1051 moveindex 6
1052 MOVE: SE 5d-3f
1053 postauto2
1054 preauto1
1055 moveindex 7
1056 MOVE: p 5l-5k
1057 postauto1
1058 preauto2
1059 moveindex 8
1060 MOVE: HF 13d-13f
1061 postauto2
1062 preauto1
1063 moveindex 9
1064 MOVE: se 5m-7k
1065 postauto1
1066 preauto2
1067 moveindex 10
1068 MOVE: D 5f-5g
1069 postauto2
1070 preauto1
1071 moveindex 11
1072 MOVE: se 12m-14k
1073 postauto1
1074 preauto2
1075 moveindex 12
1076 MOVE: P 5e-5f
1077 postauto2
1078 preauto1
1079 moveindex 13
1080 MOVE: p 4l-4k
1081 postauto1
1082 preauto2
1083 moveindex 14
1084 MOVE: P 7e-7f
1085 postauto2
1086 preauto1
1087 moveindex 15
1088 MOVE: bg 11m-14j
1089 postauto1
1090 preauto2
1091 moveindex 16
1092 MOVE: GG 8d-14j
1093 postauto2
1094 preauto1
1095 moveindex 17
1096 MOVE: se 14k-14j
1097 postauto1
1098 preauto2
1099 moveindex 18
1100 MOVE: BG 6d-3g
1101 postauto2
1102 preauto1
1103 moveindex 19
1104 MOVE: p 8l-8k
1105 postauto1
1106 preauto2
1107 moveindex 20
1108 MOVE: BG 3g-10n
1109 MOVE:  +BG-dest
1110 MOVE:  onetwo
1111 postauto2
1112 preauto1
1113 moveindex 21
1114 MOVE: rg 10m-10n
1115 postauto1
1116 preauto2
1117 moveindex 22
1118 MOVE: FD 7c-8f
1119 postauto2
1120 preauto1
1121 moveindex 23
1122 MOVE: vg 8m-9m
1123 MOVE:  pass
1124 postauto1
1125 preauto2
1126 moveindex 24
1127 MOVE: VG 9d-11g
1128 postauto2
1129 preauto1
1130 moveindex 25
1131 MOVE: rg 7m-8m
1132 postauto1
1133 preauto2
1134 moveindex 26
1135 MOVE: LH 8c-12g
1136 postauto2
1137 preauto1
1138 moveindex 27
1139 MOVE: rg 8m-8f
1140 postauto1
1141 preauto2
1142 moveindex 28
1143 MOVE: P 8e-8f
1144 postauto2
1145 preauto1
1146 moveindex 29
1147 MOVE: bg 6m-12g
1148 postauto1
1149 preauto2
1150 moveindex 30
1151 MOVE: D 12f-12g
1152 postauto2
1153 preauto1
1154 moveindex 31
1155 MOVE: hf 13m-12l
1156 postauto1
1157 preauto2
1158 moveindex 32
1159 MOVE: FD 10c-8e
1160 postauto2
1161 preauto1
1162 moveindex 33
1163 MOVE: p 3l-3k
1164 postauto1
1165 preauto2
1166 moveindex 34
1167 MOVE: D 12g-11f
1168 postauto2
1169 preauto1
1170 moveindex 35
1171 MOVE: p 6l-6k
1172 postauto1
1173 preauto2
1174 moveindex 36
1175 MOVE: VG 11g-9g
1176 postauto2
1177 preauto1
1178 moveindex 37
1179 MOVE: rg 10n-10m
1180 postauto1
1181 preauto2
1182 moveindex 38
1183 MOVE: SE 12d-14f
1184 postauto2
1185 preauto1
1186 moveindex 39
1187 MOVE: se 14j-13i
1188 MOVE:  se 13i-14j
1189 postauto1
1190 preauto2
1191 moveindex 40
1192 MOVE: HF 4d-7g
1193 postauto2
1194 preauto1
1195 moveindex 41
1196 MOVE: vg 9m-4h
1197 postauto1
1198 preauto2
1199 moveindex 42
1200 MOVE: FE 9c-7c
1201 postauto2
1202 preauto1
1203 moveindex 43
1204 MOVE: vg 4h-4i
1205 MOVE:  pass
1206 postauto1
1207 preauto2
1208 moveindex 44
1209 MOVE: FD 8e-5e
1210 postauto2
1211 preauto1
1212 moveindex 45
1213 MOVE: rg 10m-9m
1214 postauto1
1215 preauto2
1216 moveindex 46
1217 MOVE: VG 9g-8g
1218 MOVE:  pass
1219 postauto2
1220 preauto1
1221 moveindex 47
1222 MOVE: p 11l-11k
1223 postauto1
1224 preauto2
1225 moveindex 48
1226 MOVE: RG 7d-4d
1227 postauto2
1228 preauto1
1229 moveindex 49
1230 MOVE: hf 4m-7m
1231 postauto1
1232 preauto2
1233 moveindex 50
1234 MOVE: HF 7g-6g
1235 postauto2
1236 preauto1
1237 moveindex 51
1238 MOVE: dh 13n-6g
1239 postauto1
1240 preauto2
1241 moveindex 52
1242 MOVE: RG 4d-4k
1243 MOVE:  one
1244 postauto2
1245 preauto1
1246 moveindex 53
1247 MOVE: b 3n-5l
1248 postauto1
1249 preauto2
1250 moveindex 54
1251 MOVE: FD 5e-6f
1252 MOVE:  FD 6f-6g
1253 MOVE:  FD 6g-6f
1254 postauto2
1255 preauto1
1256 moveindex 55
1257 MOVE: b 5l-4k
1258 postauto1
1259 preauto2
1260 moveindex 56
1261 MOVE: VG 8g-10g
1262 postauto2
1263 preauto1
1264 moveindex 57
1265 MOVE: p 11k-11j
1266 postauto1
1267 preauto2
1268 moveindex 58
1269 MOVE: FD 6f-8g
1270 postauto2
1271 preauto1
1272 moveindex 59
1273 MOVE: hf 12l-10n
1274 postauto1
1275 preauto2
1276 moveindex 60
1277 MOVE: VG 10g-9g
1278 MOVE:  pass
1279 postauto2
1280 preauto1
1281 moveindex 61
1282 MOVE: rg 9m-9g
1283 postauto1
1284 preauto2
1285 moveindex 62
1286 MOVE: FD 8g-10g
1287 MOVE:  FD 10g-9g
1288 MOVE:  FD 9g-10g
1289 postauto2
1290 preauto1
1291 moveindex 63
1292 MOVE: p 6k-6j
1293 postauto1
1294 preauto2
1295 moveindex 64
1296 MOVE: RG 10d-7d
1297 postauto2
1298 preauto1
1299 moveindex 65
1300 MOVE: dh 4n-4m
1301 postauto1
1302 preauto2
1303 moveindex 66
1304 MOVE: FD 10g-13i
1305 MOVE:  FD 13i-14j
1306 MOVE:  FD 14j-12j
1307 postauto2
1308 preauto1
1309 moveindex 67
1310 MOVE: p 10l-10k
1311 postauto1
1312 preauto2
1313 moveindex 68
1314 MOVE: FD 13i-14g
1315 postauto2
1316 preauto1
1317 moveindex 69
1318 MOVE: d 5j-5i
1319 postauto1
1320 preauto2
1321 moveindex 70
1322 MOVE: FE 7c-7e
1323 postauto2
1324 preauto1
1325 moveindex 71
1326 MOVE: b 14n-10j
1327 postauto1
1328 preauto2
1329 moveindex 72
1330 MOVE: BG 9f-11h
1331 postauto2
1332 preauto1
1333 moveindex 73
1334 MOVE: b 10j-14f
1335 postauto1
1336 preauto2
1337 moveindex 74
1338 MOVE: FD 14g-14f
1339 MOVE:  FD 14f-14g
1340 postauto2
1341 preauto1
1342 moveindex 75
1343 MOVE: fd 7n-9m
1344 postauto1
1345 preauto2
1346 moveindex 76
1347 MOVE: RG 7d-9d
1348 postauto2
1349 preauto1
1350 moveindex 77
1351 MOVE: hf 7m-9k
1352 postauto1
1353 preauto2
1354 moveindex 78
1355 MOVE: B 3c-7g
1356 postauto2
1357 preauto1
1358 moveindex 79
1359 MOVE: b 4k-1h
1360 postauto1
1361 preauto2
1362 moveindex 80
1363 MOVE: SE 3f-4f
1364 postauto2
1365 preauto1
1366 moveindex 81
1367 MOVE: b 1h-6m
1368 postauto1
1369 preauto2
1370 moveindex 82
1371 MOVE: B 7g-6h
1372 postauto2
1373 preauto1
1374 moveindex 83
1375 MOVE: p 8k-8j
1376 postauto1
1377 preauto2
1378 moveindex 84
1379 MOVE: FD 14g-8g
1380 postauto2
1381 preauto1
1382 moveindex 85
1383 MOVE: p 7l-7k
1384 postauto1
1385 preauto2
1386 moveindex 86
1387 MOVE: BG 11h-8e
1388 postauto2
1389 preauto1
1390 moveindex 87
1391 MOVE: b 6m-13f
1392 postauto1
1393 preauto2
1394 moveindex 88
1395 MOVE: P 13e-13f
1396 postauto2
1397 preauto1
1398 moveindex 89
1399 MOVE: n 15p-14n
1400 postauto1
1401 preauto2
1402 moveindex 90
1403 MOVE: N 2a-3c
1404 postauto2
1405 preauto1
1406 moveindex 91
1407 MOVE: n 2p-3n
1408 postauto1
1409 preauto2
1410 moveindex 92
1411 MOVE: N 3c-5b
1412 postauto2
1413 preauto1
1414 moveindex 93
1415 MOVE: p 6j-6i
1416 postauto1
1417 preauto2
1418 moveindex 94
1419 MOVE: FD 8g-7h
1420 MOVE:  FD 7h-6i
1421 MOVE:  FD 6i-7h
1422 postauto2
1423 preauto1
1424 moveindex 95
1425 MOVE: dk 5n-6m
1426 postauto1
1427 preauto2
1428 moveindex 96
1429 MOVE: FD 7h-3l
1430 MOVE:  FD 3l-4m
1431 MOVE:  FD 4m-3m
1432 postauto2
1433 preauto1
1434 moveindex 97
1435 MOVE: n 3n-5m
1436 postauto1
1437 preauto2
1438 moveindex 98
1439 MOVE: FD 3l-7h
1440 postauto2
1441 preauto1
1442 moveindex 99
1443 MOVE: vs 2n-4n
1444 postauto1
1445 preauto2
1446 moveindex 100
1447 MOVE: SE 4f-5e
1448 postauto2
1449 preauto1
1450 moveindex 101
1451 MOVE: n 14n-12m
1452 postauto1
1453 preauto2
1454 moveindex 102
1455 MOVE: SE 5e-7g
1456 postauto2
1457 preauto1
1458 moveindex 103
1459 MOVE: cs 3o-3l
1460 postauto1
1461 preauto2
1462 moveindex 104
1463 MOVE: FD 7h-10g
1464 postauto2
1465 preauto1
1466 moveindex 105
1467 MOVE: n 12m-11k
1468 postauto1
1469 preauto2
1470 moveindex 106
1471 MOVE: SE 7g-9g
1472 postauto2
1473 preauto1
1474 moveindex 107
1475 MOVE: n 5m-6k
1476 postauto1
1477 preauto2
1478 moveindex 108
1479 MOVE: SE 9g-9k
1480 postauto2
1481 preauto1
1482 moveindex 109
1483 MOVE: wb 6n-9k
1484 postauto1
1485 preauto2
1486 moveindex 110
1487 MOVE: FE 7e-9g
1488 postauto2
1489 preauto1
1490 moveindex 111
1491 MOVE: dk 6m-8m
1492 postauto1
1493 preauto2
1494 moveindex 112
1495 MOVE: DH 13c-12d
1496 postauto2
1497 preauto1
1498 moveindex 113
1499 MOVE: n 11k-10i
1500 postauto1
1501 preauto2
1502 moveindex 114
1503 MOVE: FD 10g-10h
1504 MOVE:  FD 10h-10i
1505 MOVE:  FD 10i-10h
1506 postauto2
1507 preauto1
1508 moveindex 115
1509 MOVE: p 8j-8i
1510 postauto1
1511 preauto2
1512 moveindex 116
1513 MOVE: B 6h-9k
1514 postauto2
1515 preauto1
1516 moveindex 117
1517 MOVE: p 9l-9k
1518 postauto1
1519 preauto2
1520 moveindex 118
1521 MOVE: FE 9g-12g
1522 postauto2
1523 preauto1
1524 moveindex 119
1525 MOVE: n 6k-7i
1526 postauto1
1527 preauto2
1528 moveindex 120
1529 MOVE: DH 12d-15g
1530 postauto2
1531 preauto1
1532 moveindex 121
1533 MOVE: p 12k-12j
1534 postauto1
1535 preauto2
1536 moveindex 122
1537 MOVE: RG 9d-9m
1538 MOVE:  +RG-dest
1539 MOVE:  one
1540 postauto2
1541 preauto1
1542 moveindex 123
1543 MOVE: dk 8m-9m
1544 postauto1
1545 preauto2
1546 moveindex 124
1547 MOVE: P 8f-8g
1548 postauto2
1549 preauto1
1550 moveindex 125
1551 MOVE: n 7i-9j
1552 postauto1
1553 preauto2
1554 moveindex 126
1555 MOVE: FD 10h-10j
1556 MOVE:  FD 10j-9j
1557 MOVE:  FD 9j-10k
1558 postauto2
1559 preauto1
1560 moveindex 127
1561 MOVE: cs 14o-15o
1562 postauto1
1563 preauto2
1564 moveindex 128
1565 MOVE: FD 10j-2j
1566 MOVE:  pass
1567 postauto2
1568 preauto1
1569 moveindex 129
1570 MOVE: vm 2m-3m
1571 postauto1
1572 preauto2
1573 moveindex 130
1574 MOVE: FD 2j-3l
1575 MOVE:  FD 3l-3m
1576 MOVE:  FD 3m-3k
1577 postauto2
1578 preauto1
1579 moveindex 131
1580 MOVE: vs 4n-3n
1581 postauto1
1582 preauto2
1583 moveindex 132
1584 MOVE: FD 3l-2l
1585 MOVE:  FD 2l-1m
1586 MOVE:  FD 1m-2l
1587 postauto2
1588 preauto1
1589 moveindex 133
1590 MOVE: dk 12n-12l
1591 postauto1
1592 preauto2
1593 moveindex 134
1594 MOVE: FD 2l-1o
1595 MOVE:  FD 1o-1p
1596 MOVE:  FD 1p-1n
1597 postauto2
1598 preauto1
1599 moveindex 135
1600 MOVE: cs 4o-3o
1601 postauto1
1602 preauto2
1603 moveindex 136
1604 MOVE: FD 1o-3p
1605 MOVE:  FD 3p-3o
1606 MOVE:  FD 3o-4p
1607 postauto2
1608 preauto1
1609 moveindex 137
1610 MOVE: c 5p-4o
1611 postauto1
1612 preauto2
1613 moveindex 138
1614 MOVE: FD 3p-1o
1615 postauto2
1616 preauto1
1617 moveindex 139
1618 MOVE: vs 3n-5n
1619 postauto1
1620 preauto2
1621 moveindex 140
1622 MOVE: FD 1o-4o
1623 MOVE:  FD 4o-5n
1624 MOVE:  FD 5n-4o
1625 postauto2
1626 preauto1
1627 moveindex 141
1628 MOVE: wb 11n-8k
1629 postauto1
1630 preauto2
1631 moveindex 142
1632 MOVE: FD 4o-5o
1633 MOVE:  FD 5o-6p
1634 MOVE:  FD 6p-6o
1635 postauto2
1636 preauto1
1637 moveindex 143
1638 MOVE: g 7p-6p
1639 postauto1
1640 preauto2
1641 moveindex 144
1642 MOVE: FD 5o-8o
1643 MOVE:  FD 8o-9p
1644 MOVE:  FD 9p-8p
1645 postauto2
1646 preauto1
1647 if >= #wskips 2
1648   die You may not skip two consecutive turns.
1649 endif
1650 if not findpiece k spaces and not findpiece +de spaces and not sub ismultimove
1651   say All Royals Captured! White has won!
1652   won
1653 endif
1654 set posvar join "w" join fencode boardflags
1655 if >= var #posvar 4
1656   say Four Times Repetition! Drawn Game!
1657   drawn
1658 endif
1659 if == 0 var phase and sub ismultimove
1660   gosub legalmoves2 KING 1
1661   remind "Enter second leg of move or press Pass"
1662   continuemove
1663 elseif == 1 var phase and not == var mv pass and sub ismultimove
1664   gosub legalmoves2 KING 2
1665   remind "Enter second leg of move or press Pass"
1666   continuemove
1667 elseif sub stalemated king
1668 endif
1669 end
1670