我有一些非常大的棋盘,我正在设置它们,作为一些工作的一部分无限棋。我一直在使用棋盘包,非常棒。
但我在这些非标准尺寸的板上使用 \mainline 时遇到了困难。以下面的位置为例,它在我的一篇论文中使用。
这是生成前 z 列的代码:
\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}
现在,我的问题来了。我想要做的是将其设置为游戏的初始位置,用黑色移动,然后发出如下命令
\mainline{1...Bu14}
\chessboard
\mainline{2.xu14}
\chessboard
显示下一个位置,依此类推。(实际上,我的目的是执行几十个动作并制作动画,但我甚至无法完成一步。)
有人能向我解释一下如何实现这个功能吗?
答案1
以下是我最终使用的(黑客)解决方案:
\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}
此代码可生成一个包含 119 帧的 Beamer 幻灯片,以动画形式呈现棋局并附带注释。您可以查看以下幻灯片我最近在达特茅斯发表的演讲,其中还有其他几个无限象棋动画,总共超过 500 帧。