如何在使用 xskakloop(移动历史记录)时标记当前移动和所有先前的移动

如何在使用 xskakloop(移动历史记录)时标记当前移动和所有先前的移动

movenr={1}, 
markmove=\xskakget{movefrom}-\xskakget{moveto},
movenr={2}, 
markmove=\xskakget{movefrom}-\xskakget{moveto},
movenr={3}, 
markmove=\xskakget{movefrom}-\xskakget{moveto},
......
......

我可以标记的动作movenr
使用 xskakloop 时,如何标记当前移动和所有先前移动?

在此处输入图片描述

\documentclass[margin=5mm, varwidth]{standalone}
\usepackage{xskak}
\usepackage{chessboard}
\setchessboard{showmover=false, margin=false}

\begin{document}
\section{Loop}
\newchessgame[setwhite={Ba8}]
\mainline{1. Be4 ... 2. Bh7 ... 3. Bg8 ... 4. Ba2 ...}
\setchessboard{pgfstyle=straightmove, color=red,}

\xskakloop[step=2,]{%
\begin{tabular}{c}
\chessboard[tinyboard,  setfen=\xskakget{nextfen},
movenr={1},  
markmove=\xskakget{movefrom}-\xskakget{moveto},
movenr={2}, 
markmove=\xskakget{movefrom}-\xskakget{moveto},
movenr={3}, 
markmove=\xskakget{movefrom}-\xskakget{moveto},
movenr={4}, 
markmove=\xskakget{movefrom}-\xskakget{moveto},
] \\[1em]
movenr: \xskakget{movenr}, lastmovenr: \xskakgetgame{lastmovenr} \\ 
\xskakget{opennr}\xskakget{lan}%
\end{tabular}\quad}%
\end{document}

答案1

\mynamedef\mynameuse来自 https://tex.stackexchange.com/a/635757/46023

在此处输入图片描述

\documentclass{article} 
% https://tex.stackexchange.com/a/635757/46023
\makeatletter
\def\mynamedef#1#2{\expandafter\xdef\csname#1\endcsname{#2}}
\let\mynameuse\@nameuse
\makeatother

\usepackage{xskak}
\usepackage{chessboard} 
\setchessboard{showmover=false, 
pgfstyle=straightmove, color=red,} 

\begin{document}
\newchessgame[setwhite={Ba8}]
\mainline{1. Be4 ... 2. Bh7 ... 3. Bg8 ... 4. Ba2 ...}

\section{markmove Lists}
\def\Player{w}
\foreach \Moveno in {1,...,\xskakgetgame{lastmovenr}}{%%
\let\List=\empty% create List
\foreach \moveno in {1,...,\Moveno}{%
%\noindent Test: \moveno  % Test 1/3
\xskakset{moveid=\moveno\Player}
\xdef\movefromto{\xskakget{movefrom}-\xskakget{moveto}}
%\movefromto % Test 2/3
  \ifx\empty\List{} \xdef\List{\movefromto}%
  \else \xdef\List{\List, \movefromto}%
\fi%
}% \\% Test 3/3
\mynamedef{List\Moveno}{\List}% List1, List2, .... 
}%%

\subsection{Test}
\foreach \Moveno in {1,...,\xskakgetgame{lastmovenr}}{%%
List\Moveno: \mynameuse{List\Moveno} \\}%%

\section{xskak Loop}
\xskakloop[step=2,]{%
\begin{tabular}{c}
\chessboard[tinyboard,  setfen=\xskakget{nextfen},
markmoves={\mynameuse{List\xskakget{movenr}}},
] \\[1em]
movenr: \xskakget{movenr}, lastmovenr: \xskakgetgame{lastmovenr} \\ 
\xskakget{opennr}\xskakget{lan} \\   
markmoves: \mynameuse{List\xskakget{movenr}}
\end{tabular}\quad}%
\end{document}

相关内容