You may not move a White King from f0 to d0

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. f1-f4 // first time playing this one, good luck
1... e8-e6 
2. e1-e4 
2... c9-d7 
3. d1-d3 
3... j9-h7 
4. j0-h2 
4... h9-g7 
5. h0-g2 
5... a9-c7 
6. c0-d2 
6... w3-j7 
7. g0-e2 
7... j7-i4 
8. j1-j3 
8... i4-j3 //w x p
9. i0-j0 
9... j8-j7 
10. g2-h4 
10... j3-i4 
11. g1-g3 
11... i8-i5 
12. h4-j5 
12... j7-j6 
13. w1-a2 
13... f8-f5 
14. e0-a4 
14... i4-j5 //w x n
15. a4-a8 // qxp
15... b9-a9 
16. a2-b5 // well...that went a little less than ideally...
16... a9-a8 
17. b5-a8 // a rook and more, we're hoping...wxr
17... d9-e8 
18. d0-f2 
18... d7-c5 
19. a8-b5 
19... e8-b5 // B x W...
20. a0-c2 // this is ugly...
20... f5-e4 
21. f0-d0 // ok, i'll hang in and hunker down
21... e4-d3 
22. f2-c5 // bxn
22... g9-c5 // B x B
23. c2-c3 
23... d3-e2 
24. d0-c0 
24... e9-a9 
25. c0-b0 
25... c5-d4 
26. b1-b2 
26... d4-c3 
27. b2-c3 
27... c7-c5 
28. d2-b1 
28... a9-a2 
29. c1-c2 
29... a2-c2 //Q x P ... yes, as long as it is a diagonal space.
30. e0-c0 
30... c2-b3 
31. b0-a0 
31... b5-d3 
32. a0-w1 
32... b3-b1 // q x n check
33. c0-a0 
33... b1-a1 
34. j0-d0 // it's lonely in there...
34... d3-a0 
35. d0-a0 // rxb
35... a1-b1 
36. h2-f0 
36... f9-e8 
37. f0-e0 
37... i9-a9 // rook over, have a great weekend... g
38. e0-c0 // delaying the inevitable...have fun
38... a9-a0 
39. c0-a0 
39... e2-e1 
40. w2-h0 // glutton for punishment here...take care
40... e1-e0;q-e0 //Promote to Queen.  You take care too.  g
41. resign

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

Here is a code listing:

   0 include chess
   1 set wcastle c0 h0
   2 set bcastle c9 h9
   3 set K findpiece K spaces
   4 set k findpiece k spaces
   5 set ep false
   6 setflag b0 f0 i0 b9 f9 i9
   7 set names assoc p "Black Pawn" P "White Pawn" n "Black Knight" N "White Knight" b "Black Bishop" B "White Bishop" w "Black Wizard" W "White Wizard" s "Black Champion" S "White Champion" r "Black Rook" R "White Rook" q "Black Queen" Q "White Queen" k "Black King" K "White King"
   8 set fps 3
   9 set wpr 1
  10 set bpr 8
  11 alias c s C S w1 !x!1 w2 !y!1 w3 !y!2 w4 !x!2
  12 def s checkleap #0 #1 0 1 or checkleap #0 #1 0 2 or checkleap #0 #1 2 2
  13 def S checkleap #0 #1 0 1 or checkleap #0 #1 0 2 or checkleap #0 #1 2 2
  14 def w checkleap #0 #1 1 1 or checkleap #0 #1 1 3
  15 def W checkleap #0 #1 1 1 or checkleap #0 #1 1 3
  16 def CAMEL check what #0 1 3 check what #0 -1 3 check what #0 1 -3 check what #0 -1 -3 check what #0 3 1 check what #0 -3 1 check what #0 3 -1 check what #0 -3 -1 target #1
  17 def DABBABAH check what #0 0 -2 check what #0 -2 0 check what #0 0 2 check what #0 2 0 target #1
  18 def ALFIL check what #0 -2 -2 check what #0 -2 2 check what #0 2 -2 check what #0 2 2 target #1
  19 def ATTACKEDBYB fn CAMEL #0 w or fn ALFIL #0 s or fn DABBABAH #0 s or fn WAZIR #0 (k s) or fn FERZ #0 (k w) or fn BPAWN #0 or fn KNIGHT #0 n or fn ROOK #0 (r q) or fn BISHOP #0 (b q)
  20 def ATTACKEDBYW fn CAMEL #0 W or fn ALFIL #0 S or fn DABBABAH #0 S or fn WAZIR #0 (K S) or fn FERZ #0 (K W) or fn WPAWN #0 or fn KNIGHT #0 N or fn ROOK #0 (R Q) or fn BISHOP #0 (B Q)
  21 def PL array where #0 0 3 where #0 0 2 where #0 0 1 where #0 -1 1 where #0 1 1
  22 def pL array where #0 0 -3 where #0 0 -2 where #0 0 -1 where #0 -1 -1 where #0 1 -1
  23 def SL merge merge leaps #0 0 1 leaps #0 0 2 leaps #0 2 2
  24 def WL merge leaps #0 1 1 leaps #0 1 3
  25 def sL merge merge leaps #0 0 1 leaps #0 0 2 leaps #0 2 2
  26 def wL merge leaps #0 1 1 leaps #0 1 3
  27 sub postauto1
  28   if isupper old
  29     die You may not capture your own pieces.
  30   endif
  31   if == moved P
  32     set nopvc 0
  33   else
  34     set ep false
  35     if capture
  36       set nopvc 0
  37     else
  38       inc nopvc
  39     endif
  40     if unequal space dest moved
  41       die You may not change the type of this piece.
  42     endif
  43   endif
  44   set legal false
  45   if match moved P K
  46     gosub moved origin dest
  47     if equal moved K
  48       set K dest
  49     endif
  50   elseif match moved Q R B N S W
  51     set legal fn moved origin dest
  52     if == moved R
  53       unsetflag origin
  54     else
  55       unsetflag dest
  56     endif
  57   endif
  58   if not var legal
  59     set ori alias origin
  60     set dst alias dest
  61     set name elem moved names
  62     die You may not move a #name from #ori to #dst
  63   endif
  64   if fn ATTACKEDBYB #K
  65     die You may not move into check.
  66   endif
  67   set posvar join "w" join fencode boardflags
  68   inc #posvar
  69 endsub
  70 sub postauto2
  71   if islower old
  72     die You may not capture your own pieces.
  73   endif
  74   if == moved p
  75     set nopvc 0
  76   else
  77     set ep false
  78     if capture
  79       set nopvc 0
  80     else
  81       inc nopvc
  82     endif
  83     if unequal space dest moved
  84       die You may not change the type of this piece.
  85     endif
  86   endif
  87   set legal false
  88   if match moved p k
  89     gosub moved origin dest
  90     if equal moved k
  91       set k dest
  92     endif
  93   elseif match moved q r b n s w
  94     set legal fn toupper moved origin dest
  95     if == moved r
  96       unsetflag origin
  97     else
  98       unsetflag dest
  99     endif
 100   endif
 101   if not var legal
 102     set ori alias origin
 103     set dst alias dest
 104     set name elem moved names
 105     die You may not move a #name from #ori to #dst
 106   endif
 107   if fn ATTACKEDBYW #k
 108     die You may not move into check.
 109   endif
 110   set posvar join "b" join fencode boardflags
 111   inc #posvar
 112 endsub
 113 moveindex 0
 114 MOVE: f1-f4
 115 postauto1
 116 moveindex 1
 117 MOVE: e8-e6
 118 postauto2
 119 moveindex 2
 120 MOVE: e1-e4
 121 postauto1
 122 moveindex 3
 123 MOVE: c9-d7
 124 postauto2
 125 moveindex 4
 126 MOVE: d1-d3
 127 postauto1
 128 moveindex 5
 129 MOVE: j9-h7
 130 postauto2
 131 moveindex 6
 132 MOVE: j0-h2
 133 postauto1
 134 moveindex 7
 135 MOVE: h9-g7
 136 postauto2
 137 moveindex 8
 138 MOVE: h0-g2
 139 postauto1
 140 moveindex 9
 141 MOVE: a9-c7
 142 postauto2
 143 moveindex 10
 144 MOVE: c0-d2
 145 postauto1
 146 moveindex 11
 147 MOVE: w3-j7
 148 postauto2
 149 moveindex 12
 150 MOVE: g0-e2
 151 postauto1
 152 moveindex 13
 153 MOVE: j7-i4
 154 postauto2
 155 moveindex 14
 156 MOVE: j1-j3
 157 postauto1
 158 moveindex 15
 159 MOVE: i4-j3
 160 postauto2
 161 moveindex 16
 162 MOVE: i0-j0
 163 postauto1
 164 moveindex 17
 165 MOVE: j8-j7
 166 postauto2
 167 moveindex 18
 168 MOVE: g2-h4
 169 postauto1
 170 moveindex 19
 171 MOVE: j3-i4
 172 postauto2
 173 moveindex 20
 174 MOVE: g1-g3
 175 postauto1
 176 moveindex 21
 177 MOVE: i8-i5
 178 postauto2
 179 moveindex 22
 180 MOVE: h4-j5
 181 postauto1
 182 moveindex 23
 183 MOVE: j7-j6
 184 postauto2
 185 moveindex 24
 186 MOVE: w1-a2
 187 postauto1
 188 moveindex 25
 189 MOVE: f8-f5
 190 postauto2
 191 moveindex 26
 192 MOVE: e0-a4
 193 postauto1
 194 moveindex 27
 195 MOVE: i4-j5
 196 postauto2
 197 moveindex 28
 198 MOVE: a4-a8
 199 postauto1
 200 moveindex 29
 201 MOVE: b9-a9
 202 postauto2
 203 moveindex 30
 204 MOVE: a2-b5
 205 postauto1
 206 moveindex 31
 207 MOVE: a9-a8
 208 postauto2
 209 moveindex 32
 210 MOVE: b5-a8
 211 postauto1
 212 moveindex 33
 213 MOVE: d9-e8
 214 postauto2
 215 moveindex 34
 216 MOVE: d0-f2
 217 postauto1
 218 moveindex 35
 219 MOVE: d7-c5
 220 postauto2
 221 moveindex 36
 222 MOVE: a8-b5
 223 postauto1
 224 moveindex 37
 225 MOVE: e8-b5
 226 postauto2
 227 moveindex 38
 228 MOVE: a0-c2
 229 postauto1
 230 moveindex 39
 231 MOVE: f5-e4
 232 postauto2
 233 moveindex 40
 234 MOVE: f0-d0
 235 postauto1
 236 moveindex 41
 237 MOVE: e4-d3
 238 postauto2
 239 moveindex 42
 240 MOVE: f2-c5
 241 postauto1
 242 moveindex 43
 243 MOVE: g9-c5
 244 postauto2
 245 moveindex 44
 246 MOVE: c2-c3
 247 postauto1
 248 moveindex 45
 249 MOVE: d3-e2
 250 postauto2
 251 moveindex 46
 252 MOVE: d0-c0
 253 postauto1
 254 moveindex 47
 255 MOVE: e9-a9
 256 postauto2
 257 moveindex 48
 258 MOVE: c0-b0
 259 postauto1
 260 moveindex 49
 261 MOVE: c5-d4
 262 postauto2
 263 moveindex 50
 264 MOVE: b1-b2
 265 postauto1
 266 moveindex 51
 267 MOVE: d4-c3
 268 postauto2
 269 moveindex 52
 270 MOVE: b2-c3
 271 postauto1
 272 moveindex 53
 273 MOVE: c7-c5
 274 postauto2
 275 moveindex 54
 276 MOVE: d2-b1
 277 postauto1
 278 moveindex 55
 279 MOVE: a9-a2
 280 postauto2
 281 moveindex 56
 282 MOVE: c1-c2
 283 postauto1
 284 moveindex 57
 285 MOVE: a2-c2
 286 postauto2
 287 moveindex 58
 288 MOVE: e0-c0
 289 postauto1
 290 moveindex 59
 291 MOVE: c2-b3
 292 postauto2
 293 moveindex 60
 294 MOVE: b0-a0
 295 postauto1
 296 moveindex 61
 297 MOVE: b5-d3
 298 postauto2
 299 moveindex 62
 300 MOVE: a0-w1
 301 postauto1
 302 moveindex 63
 303 MOVE: b3-b1
 304 postauto2
 305 moveindex 64
 306 MOVE: c0-a0
 307 postauto1
 308 moveindex 65
 309 MOVE: b1-a1
 310 postauto2
 311 moveindex 66
 312 MOVE: j0-d0
 313 postauto1
 314 moveindex 67
 315 MOVE: d3-a0
 316 postauto2
 317 moveindex 68
 318 MOVE: d0-a0
 319 postauto1
 320 moveindex 69
 321 MOVE: a1-b1
 322 postauto2
 323 moveindex 70
 324 MOVE: h2-f0
 325 postauto1
 326 moveindex 71
 327 MOVE: f9-e8
 328 postauto2
 329 moveindex 72
 330 MOVE: f0-e0
 331 postauto1
 332 moveindex 73
 333 MOVE: i9-a9
 334 postauto2
 335 moveindex 74
 336 MOVE: e0-c0
 337 postauto1
 338 moveindex 75
 339 MOVE: a9-a0
 340 postauto2
 341 moveindex 76
 342 MOVE: c0-a0
 343 postauto1
 344 moveindex 77
 345 MOVE: e2-e1
 346 postauto2
 347 moveindex 78
 348 MOVE: w2-h0
 349 postauto1
 350 moveindex 79
 351 MOVE: e1-e0
 352 MOVE: q-e0
 353 postauto2
 354 moveindex 80
 355 MOVE: resign
 356 postauto1
 357 set posvar join "w" join fencode boardflags
 358 if >= var #posvar 3
 359   say Three Times Repetition! Drawn Game!
 360   drawn
 361 endif
 362 set checks sub checks #k
 363 if var checks
 364   if sub checkmated #k #checks
 365     say Checkmate! White has won!
 366     won
 367   else
 368     say Check!
 369   endif
 370 elseif sub stalemated #k
 371   say Stalemate! The game is drawn.
 372   drawn
 373 endif
 374 if >= #nopvc 100
 375   say Fifty Moves Without Moving a Pawn or Capturing! Game Drawn!
 376   drawn
 377 endif
 378 end
 379 
 380 lib chess
 381 set wpr 2
 382 set bpr 7
 383 set fps 2
 384 set pzs 1
 385 set wcastle c1 g1
 386 set bcastle c8 g8
 387 do
 388   local x
 389   for x piecekeys
 390     if match #x P K p k
 391       continue
 392     elseif isupper #x
 393       push wprom #x
 394     elseif islower #x
 395       push bprom #x
 396     endif
 397   next
 398 loop never
 399 setsystem maxmove 2
 400 ban commands allmoves
 401 allow moves 1 captures 1 promotions 2
 402 def N checkleap #0 #1 1 2
 403 def B checkride #0 #1 1 1
 404 def R checkride #0 #1 1 0
 405 def Q fn B #0 #1 or fn R #0 #1
 406 def K checkleap #0 #1 1 1 or checkleap #0 #1 1 0
 407 def M fn N #0 #1 or fn R #0 #1
 408 def A fn N #0 #1 or fn B #0 #1
 409 def n checkleap #0 #1 1 2
 410 def b checkride #0 #1 1 1
 411 def r checkride #0 #1 1 0
 412 def q fn b #0 #1 or fn r #0 #1
 413 def k checkleap #0 #1 1 1 or checkleap #0 #1 1 0
 414 def m fn n #0 #1 or fn r #0 #1
 415 def a fn n #0 #1 or fn b #0 #1
 416 def P
remove var ep
and checkleap #0 #1 1 1
and == var ep join filename #1 rankname #0
or and checkride #0 #1 0 1 == rankname #0 var wpr
or checkleap #0 #1 0 1
and empty #1
or and islower space #1 checkleap #0 #1 1 1
and <= distance #0 #1 var fps
and > rank #1 rank #0
 417 def p
remove var ep
and checkleap #0 #1 1 1
and == var ep join filename #1 rankname #0
or and checkride #0 #1 0 1 == rankname #0 var bpr
or checkleap #0 #1 0 1
and empty #1
or and isupper space #1 checkleap #0 #1 1 1
and <= distance #0 #1 var fps
and < rank #1 rank #0
 418 sub capturep p
 419   empty #p
 420   return true
 421 endsub
 422 sub checks king
 423   if not dest
 424     return false
 425   endif
 426   my checks c
 427   set checks ()
 428   if fn space dest dest #king
 429     setelem checks dest space dest
 430   endif
 431   set c sub checkedthru #king origin
 432   if #c
 433     setelem checks #c space #c
 434   elseif #epc
 435     set c sub checkedthru #king #epc
 436     if #c
 437       setelem checks #c space #c
 438     endif
 439   endif
 440   return var checks
 441 endsub
 442 sub checkmated king checks
 443   local from piece to key legalmove piece nopawn
 444   store
 445   if isupper space #king
 446     def friends onlyupper
 447     def friend isupper #0
 448     set attacked ATTACKEDBYB
 449   else
 450     def friends onlylower
 451     def friend islower #0
 452     set attacked ATTACKEDBYW
 453   endif
 454   set kingmoves fn KL #king
 455   for to #kingmoves
 456     if not fn friend space #to and onboard #to
 457       move #king #to
 458       set incheck fn var attacked #to
 459       restore
 460       if not #incheck
 461         setlegal #king #to
 462       endif
 463     endif
 464   next
 465   if == count var checks 1
 466     for (key enemy) var checks
 467       set possible path #king #key
 468       push possible #key
 469       if == #key #ep
 470         push possible cond isupper space #ep where #ep 0 -1 where #ep 0 1
 471       endif
 472       for (from piece) fn friends
 473         if == #from #king
 474           continue
 475         endif
 476         for to #possible
 477           if fn #piece #from #to
 478             move #from #to
 479             set incheck fn var attacked #king
 480             if not #incheck
 481               setlegal #from #to
 482             endif
 483           endif
 484           restore
 485         next
 486       next
 487     next
 488   endif
 489   return cond count system legalmoves false true and checks
 490 endsub
 491 def PL array where #0 0 2 where #0 0 1 where #0 -1 1 where #0 1 1
 492 def pL array where #0 0 -2 where #0 0 -1 where #0 -1 -1 where #0 1 -1
 493 def NL leaps #0 1 2
 494 def BL rays #0 1 1
 495 def RL rays #0 1 0
 496 def VL rays #0 1 1
 497 def CL rays #0 1 0
 498 def QL merge rays #0 1 0 rays #0 1 1
 499 def KL merge leaps #0 1 0 leaps #0 1 1
 500 def AL merge leaps #0 1 2 rays #0 1 1
 501 def ML merge rays #0 1 0 leaps #0 1 2
 502 def nL leaps #0 1 2
 503 def bL rays #0 1 1
 504 def rL rays #0 1 0
 505 def vL rays #0 1 1
 506 def cL rays #0 1 0
 507 def qL merge rays #0 1 0 rays #0 1 1
 508 def kL merge leaps #0 1 0 leaps #0 1 1
 509 def aL merge leaps #0 1 2 rays #0 1 1
 510 def mL merge rays #0 1 0 leaps #0 1 2
 511 sub castlepos from to
 512   local c RPOS RDEST xdir safe
 513   verify flag #from
 514   verify empty #to
 515   if isupper space #king
 516     def friend isupper #0
 517     def friends onlyupper
 518     set attacked ATTACKEDBYB
 519   else
 520     def friend islower #0
 521     def friends onlylower
 522     set attacked ATTACKEDBYW
 523   endif
 524   set xdir sign minus file #to file #from
 525   verify checkaride #from #to #xdir 0
 526   verify not fn var attacked #from
 527   set c #to
 528   do
 529     set c where #c #xdir 0
 530     if flag #c
 531       break
 532     endif
 533     verify onboard #c
 534     verify empty #c
 535   loop
 536   verify flag #c
 537   set RPOS #c
 538   store
 539   for c path #from #to
 540     move #from #c
 541     set safe not fn var attacked #c
 542     restore
 543     verify #safe
 544   next
 545   move #from #to
 546   set RDEST where #to neg #xdir 0
 547   move #RPOS #RDEST
 548   return true
 549 endsub
 550 sub stalemated king
 551   local legalmove temp from piece to attacked ra
 552   if isupper space #king
 553     def friend isupper #0
 554     def friends onlyupper
 555     set attacked ATTACKEDBYB
 556     set cspaces var wcastle
 557   else
 558     def friend islower #0
 559     def friends onlylower
 560     set attacked ATTACKEDBYW
 561     set cspaces var bcastle
 562   endif
 563   store
 564   set kingmoves fn KL #king
 565   for to #kingmoves
 566     if not fn friend space #to and onboard #to
 567       move #king #to
 568       set incheck fn var attacked #to
 569       restore
 570       if not #incheck
 571         setlegal #king #to
 572       endif
 573     endif
 574   next
 575   for to var cspaces
 576     if sub castlepos #king #to
 577       set incheck fn var attacked #to
 578       restore
 579       if not #incheck
 580         setlegal #king #to
 581       endif
 582     endif
 583   next
 584   restore
 585   for (from piece) fn friends
 586     if == #from #king
 587       continue
 588     endif
 589     for to fn join #piece L #from
 590       if fn #piece #from #to and not fn friend space #to and onboard #to
 591         move #from #to
 592         set incheck fn var attacked #king
 593         if not #incheck
 594           setlegal #from #to
 595         endif
 596       endif
 597       restore
 598     next
 599   next
 600   return cond count system legalmoves false true
 601 endsub
 602 def WPAWN match P what #0 1 -1 what #0 -1 -1
 603 def BPAWN match p what #0 1 1 what #0 -1 1
 604 def KNIGHT check what #0 1 2 check what #0 -1 2 check what #0 1 -2 check what #0 -1 -2 check what #0 2 1 check what #0 -2 1 check what #0 2 -1 check what #0 -2 -1 target #1
 605 def WAZIR check what #0 0 -1 check what #0 -1 0 check what #0 0 1 check what #0 1 0 target #1
 606 def FERZ check what #0 -1 -1 check what #0 -1 1 check what #0 1 -1 check what #0 1 1 target #1
 607 def KING fn WAZIR #0 #1 or fn FERZ #0 #1
 608 def ROOK check insight #0 0 -1 check insight #0 -1 0 check insight #0 0 1 check insight #0 1 0 target #1
 609 def BISHOP check insight #0 -1 -1 check insight #0 -1 1 check insight #0 1 -1 check insight #0 1 1 target #1
 610 def ATTACKEDBYB fn KING #0 k or fn BPAWN #0 or fn KNIGHT #0 (n a m) or fn ROOK #0 (r q m) or fn BISHOP #0 (b q a)
 611 def ATTACKEDBYW fn KING #0 K or fn WPAWN #0 or fn KNIGHT #0 (N A M) or fn ROOK #0 (R Q M) or fn BISHOP #0 (B Q A)
 612 sub P from to
 613   local ydir
 614   if == file #from file #to and not capture
 615     set legal checkaleap #from #to 0 1
 616     if var legal
 617       set ep false
 618     else
 619       set legal checkaride #from #to 0 1 and <= distance #from #to #fps and or == rankname #from #wpr < #wpr 0
 620       set ep #to
 621     endif
 622     set epc false
 623   elseif capture or #ep
 624     set legal checkaleap #from #to -1 1 or checkaleap #from #to 1 1
 625     set epc false
 626     if not capture and var legal
 627       set legal > rank #to rank #ep and < rankname #to #bpr and == file #to file #ep
 628       if var legal
 629         capture #ep
 630         set epc #ep
 631       endif
 632     endif
 633     set ep false
 634   endif
 635   if != space #to moved and onboard where #to 0 #pzs
 636     die "You may not promote a Pawn until it reaches the promotion zone."
 637   endif
 638   if not onboard where #to 0 1
 639     if == P space #to
 640       askpromote #wprom
 641     elseif not match space #to var wprom
 642       set np space #to
 643       die "You may not promote your Pawn to a" #np
 644     endif
 645   endif
 646 endsub
 647 sub p from to
 648   if == file #from file #to and not capture
 649     set legal checkaleap #from #to 0 -1
 650     if var legal
 651       set ep false
 652     else
 653       set legal checkaride #from #to 0 -1 and <= distance #from #to #fps and or == rankname #from #bpr > #bpr lastrank
 654       set ep #to
 655     endif
 656     set epc false
 657   elseif capture or #ep
 658     set legal checkaleap #from #to -1 -1 or checkaleap #from #to 1 -1
 659     set epc false
 660     if not capture and var legal
 661       set legal < rank #to rank #ep and > rankname #to #wpr and == file #to file #ep
 662       if var legal
 663         capture #ep
 664         set epc #ep
 665       endif
 666     endif
 667     set ep false
 668   endif
 669   if != space #to moved and onboard where #to 0 neg #pzs
 670     die You may not promote a Pawn until it reaches the promotion zone.
 671   endif
 672   if not onboard where #to 0 -1
 673     if == p space #to
 674       askpromote #bprom
 675     elseif not match space #to var bprom
 676       set np space #to
 677       die You may not promote your Pawn to a #np
 678     endif
 679   endif
 680 endsub
 681 sub K from to
 682   if match #to var wcastle and flag #from
 683     set legal sub castle
 684   else
 685     set legal fn K #from #to
 686   endif
 687   set K #to
 688   unsetflag e1
 689 endsub
 690 sub k from to
 691   if match #to var bcastle and flag #from
 692     set legal sub castle
 693   else
 694     set legal fn k #from #to
 695   endif
 696   set k #to
 697   unsetflag e8
 698 endsub
 699 sub castle
 700   local ATTACKED c RPOS RDEST xdir
 701   if not flag #from
 702     die A King may not castle after it moves.
 703   endif
 704   if capture
 705     die A King may not castle to an occupied space.
 706   endif
 707   set xdir sign minus file #to file #from
 708   if not checkaride #from #to #xdir 0
 709     die A King may not castle across any occupied space.
 710   endif
 711   set c #to
 712   do
 713     set c where #c #xdir 0
 714     if flag #c
 715       break
 716     elseif not onboard #c
 717       die No piece was found to castle with.
 718     elseif not empty #c
 719       die The King cannot castle with the piece at #c
 720     endif
 721   loop
 722   set RPOS #c
 723   set ATTACKED ATTACKEDBYW unless isupper moved ATTACKEDBYB
 724   if fn var ATTACKED #from
 725     die A King may not castle out of check.
 726   endif
 727   for c path #from #to
 728     if fn var ATTACKED #c
 729       die A King may not castle through check.
 730     endif
 731   next
 732   if == count var subargs 0
 733     set RDEST where #to neg #xdir 0
 734   else
 735     set RDEST elem 0 subarg
 736   endif
 737   unsetflag #RPOS
 738   move #RPOS #RDEST
 739   return true
 740 endsub
 741 sub checkedthru king loc
 742   my dir c
 743   set c revealed #king #loc
 744   verify fn space #c #c #king and not samecase space #king space #c and onboard #c and #c
 745   return #c
 746 endsub
 747 def fn checkedfrom fn space #1 #0 and xor isupper space #0 isupper space #1 and not empty #1
 748 sub P1 from to
 749   if == file #from file #to
 750     return not capture
 751   elseif capture
 752     return true
 753   elseif == file #to file #ep and == rank #from rank #ep and #ep
 754     capture #ep
 755     return true
 756   endif
 757   return false
 758 endsub
 759 sub PP from to
 760   if checkatwostep #from #to 0 1 0 1 or checkaleap #from #to 0 1
 761     return empty #to
 762   elseif not checkaleap #from #to 1 1 and not checkaleap #from #to -1 1
 763     return false
 764   elseif not empty #to
 765     return true
 766   elseif == file #to file #ep and == rank #from rank #ep and #ep
 767     capture #ep
 768     return true
 769   endif
 770   return false
 771 endsub
 772 sub pp from to
 773   if checkatwostep #from #to 0 -1 0 -1 or checkaleap #from #to 0 -1
 774     return empty #to
 775   elseif not checkaleap #from #to 1 -1 and not checkaleap #from #to -1 -1
 776     return false
 777   elseif not empty #to
 778     return true
 779   elseif == file #to file #ep and == rank #from rank #ep and #ep
 780     capture #ep
 781     return true
 782   endif
 783   return false
 784 endsub
 785 endlib