2

I have a number of very large chessboards that I am setting, as a part of some work on infinite chess. I have been using the chessboard package, which is great.

But I am having difficulty with using \mainline on these nonstandard size boards. Take for example the following position, which is used in one of my papers. A position with value $\omega^3$

This is the code to generate the first z columns of it:

  \documentclass{article}
  \usepackage{chessboard,xskak}
  \begin{document}

  \chessboard[maxfield=z29,
              boardfontsize=9pt,
              labelbottom=true,
              labelleft=true,
              labelfontsize=6pt,
              labelleftwidth=2ex,
              showmover=false,
              borderleft=false,
              borderright=false,
              bordertop=false,
              borderbottom=false,
              coloremphstyle=\color{green!25!black},
              emphfield=m6,
              coloremphstyle=\color{blue!50!black},
              emphfields={n12,q15,t18,w21,z24},
              coloremphstyle=\color{red!50!black},
              emphfield=k9,
              pgfstyle=straightmove,linewidth=.05ex,
              backmove=m6-p9,
              margin=false,
              setfen=%
  6PPPPP1PP1PP1PP1PP1PB/%
  6PPPPP1PP1PP1PP1PPrP1/%
  6PPPPP1PP1PP1PP1P1BpB/%
  6PPPPP1PP1PP1PP1PB1P1/%
  6PPPPP1PP1PP1PPrP1BPB/%
  6PPPPP1PP1PP1P1BpB1PP/%
  6PPPPP1PP1PP1PB1P1BPB/%
  6PPPPP1PP1PPrP1BPB1Pp/%
  6PPPPP1PP1P1BpB1PPBpP/%
  6PPPPP1PP1PB1P1BPBpP1/%
  2K3PPPPP1PPrP1BPB1PpP2p/%
  6PPPPP1P1BpB1PPBpP2pP/%
  6PPPPP1PB1P1BPBpP2pP/%
  6PPPPPrP1BPB1PpP2pP/%
  6PPPP1BpB1PPBpP2pP/%
  6PPPPB1P1BPBpP2pP/%
  3r2PPPP1BPB1PpP2pP/%
  6PPPkB1PPBpP2pP/%
  6PP1P1BPBpP2pP/%
  6PPBPB1PpP2pP/%
  6PPPPPBpP2pP/%
  6PPPPBpP2pP/%
  6PPPP1P2pP/%
  6PPPPBPbpP/%
  6PPPPPP1p/%
  6PPPPPP1P/%
  6PPPPPP/%
  6PPPPPP/%
  6PPPPPP/%
  ]%

  \end{document}

Now, my question. What I want to do is set this as the initial position of a game, with black to move, and then make commands like

 \mainline{1...Bu14}
 \chessboard 
 \mainline{2.xu14}
 \chessboard

to show the next position, and so on. (Actually, my intention is to do this for dozens of moves and animate the play, but I can't even manage to do one step.)

Could someone explain to me how to make this work?

4
  • 1
    You can't. Skak can handle only "normal" moves. You will have to change the position with chessboard keys - or write an extension of skak. Jan 12 '14 at 15:33
  • Darn. But thanks for answering (and your chessboard package is fantastic!). What do you mean by "with chessboard keys"? Do you mean writing out the complete fen for each subsequent position?
    – JDH
    Jan 12 '14 at 15:36
  • I would use the keys clearfield and addpieces Jan 12 '14 at 15:44
  • OK, I see. I guess that won't be too hard. Thanks!
    – JDH
    Jan 12 '14 at 15:48
2

Here is the (hack) solution I ended up using:

 \documentclass{beamer}
 \mode<presentation>
 \usepackage{chessboard,xskak}
 \def\certainlynotintoks{\certainlynotintoks}
 \makeatletter
 \def\iftoksempty#1{\expandafter\ifx\expandafter\certainlynotintoks\the#1 \certainlynotintoks \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
 \def\move #1#2-#3.#4 {\setchessboard{clearfield=#2,addpieces=#1#3}\only<+>{\chessboard[pgfstyle=straightmove,color=blue,shortenend=.7ex,linewidth=.05ex,markmove=#2-#3]\par\vfill\strut#4 }}
 \def\moves #1.#2 {\toks0{#1}\iftoksempty{\toks0}{}{\move #1.{#2} \moves}}

 \begin{document}

 \begin{frame}
 \newgame
 \setchessboard{maxfield=z15,tinyboard,label=false,border=false,showmover=false,margin=true,emphstyle=\color{red!50!black},emphfield=f6,setfen=%
 4P1P/4P1P/4P1P4r/4P1P1K/4P1P/4P1P/4PrP/Q3PBP/QQ2PPP/QQQ2P/QQ3P1k/Q4P/5P/5P/5P/}%
 \only<+>{\chessboard\par\vfill Black to move.}
 \moves rf9-f13.{He moves trapped rook up arbitrary height.} Pe12-f13.{White should capture from left side.}
 rl13-l12.{Now black begins to harass white king.} Ki12-j13.{White must chase down the rook to avoid perpetual check.} rl12-l13. Kj13-k12. rl13-p13.{Black must move away to save rook.}
 Pe11-e12.{Now is white's chance to advance a pawn.} rp13-p12. Kk12-l13. rp12-p13. Kl13-m12. rp13-p12. Km12-n13. rp12-p13. Kn13-o12. rp13-x13.{Black moves arbitrary distance out.}
 Pe10-e11.{Another chance to advance a pawn.} rx13-x12.{Black harasses the white king.} Ko12-p13.{White must chase him down.} rx12-x13. Kp13-q12. rx13-x12. Kq12-r13. rx12-x13. Kr13-s12.
 rx13-x12. Ks12-t13. rx12-x13. Kt13-u12. rx13-x12. Ku12-v13. rx12-x13. Kv13-w12.
 rx13-j13.{(Black should actually move arbitrary distance to the right.)} Pe9-e10. rj13-j12. Kw12-v13. rj12-j13. Kv13-u12. rj13-j12. Ku12-t13. rj12-j13. Kt13-s12. rj13-j12. Ks12-r13. rj12-j13. Kr13-q12. rj13-j12.
 Kq12-p13. rj12-j13. Kp13-o12. rj13-j12. Ko12-n13. rj12-j13. Kn13-m12. rj13-j12. Km12-l13. rj12-j13. Kl13-k12. rj13-p13.
 Bf8-c11.{The bishop unlocks the door.} rp13-p12. Kk12-l13. rp12-p13. Kl13-m12. rp13-p12. Km12-n13. rp12-p13. Kn13-o12. rp13-x13.{Black can move rook arbitrary distance.}
 Pf7-f8. rx13-x12. Ko12-p13. rx12-x13. Kp13-q12. rx13-x12. Kq12-r13. rx12-x13. Kr13-s12. rx13-x12. Ks12-t13. rx12-x13. Kt13-u12. rx13-x12. Ku12-v13.
 rx12-x13. Kv13-w12. rx13-j13.
 Pf6-f7.{The portcullis opens...} rj13-j12. Kw12-v13. rj12-j13. Kv13-u12. rj13-j12. Ku12-t13. rj12-j13. Kt13-s12. rj13-j12. Ks12-r13. rj12-j13. Kr13-q12. rj13-j12.
 Kq12-p13. rj12-j13. Kp13-o12. rj13-j12. Ko12-n13. rj12-j13. Kn13-m12. rj13-j12. Km12-l13. rj12-j13. Kl13-k12. rj13-y13.
 Qc6-i6.{Queens enter the mating chamber.} kh5-h4. Qb6-h6.{Checkmate} .
 \vfill\vfill
 \end{frame}
 \end{document}

This code produces a beamer slideshow with 119 frames, animating the chess play with annotations. You can view the slides of the talk I recently gave at Dartmouth, which has several other infinite chess animations, over 500 frames in all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.