summaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-04-27 03:01:52 +0000
committerNorbert Preining <norbert@preining.info>2023-04-27 03:01:52 +0000
commite947b2310e888cd5b10265d596eb332da9f6bdec (patch)
treed588e275b670d69ec6f51a702fe678f8b504238f /graphics
parent1ea4eef62d24f4f0574afba646c635f677eeb7cc (diff)
CTAN sync 202304270301
Diffstat (limited to 'graphics')
-rw-r--r--graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.pdfbin859567 -> 862646 bytes
-rw-r--r--graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.tex92
-rw-r--r--graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.pdfbin864214 -> 867272 bytes
-rw-r--r--graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.tex84
-rw-r--r--graphics/metapost/contrib/macros/mpchess/doc/mpchess-preamble.tex2
-rw-r--r--graphics/metapost/contrib/macros/mpchess/metapost/mpchess-chessboard.mp105
-rw-r--r--graphics/metapost/contrib/macros/mpchess/metapost/mpchess-pgn.mp4
-rw-r--r--graphics/metapost/contrib/macros/mpchess/metapost/mpchess.mp40
8 files changed, 224 insertions, 103 deletions
diff --git a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.pdf b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.pdf
index 2e4ff6add0..421fa6b060 100644
--- a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.pdf
+++ b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.pdf
Binary files differ
diff --git a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.tex b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.tex
index be40341c4f..bcc74e5003 100644
--- a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.tex
+++ b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.tex
@@ -68,7 +68,7 @@
}
\vfill
\begin{center}
- Version 0.5, 2023, April, 20th \\
+ Version 0.6, 2023, April, 26th \\
\url{https://plmlab.math.cnrs.fr/mchupin/mpchess}
\end{center}
%% == Page de garde ====================================================
@@ -292,7 +292,7 @@ command:
\begin{description}
\item[\meta{string}] can be:
\begin{itemize}
-\item \lstinline+"BlueLichess"+ (thème par défaut);
+\item \lstinline+"BlueLichess"+ (default);
\item \lstinline+"BrownLichess"+ ;
\item or \lstinline+"Classical"+.
\end{itemize}
@@ -322,18 +322,21 @@ The two color themes provided borrow the colors of the Lichess themes.
\subsubsection{Configuring a Personal Color Theme}
A color theme is really just the definition of two colors.
-These can be defined with the following commands:
+These can be defined with the following commands\footnote{Attention,
+in version 0.6, \lstinline+set_white_color+ became
+\lstinline+set_white_squares_color+ and \lstinline+set_black_color+ became
+\lstinline+set_black_squares_color+.}:
-\commande|set_white_color(«color»)|\index{set_white_color@\lstinline+set_white_color+}\par
-\commande|set_black_color(«color»)|\index{set_black_color@\lstinline+set_black_color+}\smallskip
+\commande|set_white_squares_color(«color»)|\index{set_white_squares_color@\lstinline+set_white_squares_color+}\par
+\commande|set_black_squares_color(«color»)|\index{set_black_squares_color@\lstinline+set_black_squares_color+}\smallskip
\meta{color} is a \MP{} \lstinline+color+.
\begin{ExempleMP}
input mpchess
beginfig(0);
-set_white_color((0.9,0.8,0.8));
-set_black_color((0.7,0.6,0.6));
+set_white_squares_color((0.9,0.8,0.8));
+set_black_squares_color((0.7,0.6,0.6));
init_backboard;
draw backboard;
endfig;
@@ -342,10 +345,21 @@ endfig;
You may have noticed in the various examples that by default, the coordinates are, as on the Lichess site, written in small letters inside the boxes.
-\mpchess allows you to position these coordinates outside the board with the
-following command:
+\mpchess allows you to choose the coordinates position inside or outside the board with the
+following command\footnote{Attention,
+in version 0.6, \lstinline+set_coords_inside+ and \lstinline+set_coords_outside+ became
+\lstinline+set_coordinates_position+.}:
-\commande|set_coords_outside|\index{set_coords_outside@\lstinline+set_coords_outside+}\smallskip
+\commande|set_coordinates_position(«string»)|\index{set_coordinates_position@\lstinline+set_coordinates_position+}\smallskip
+
+
+\begin{description}
+ \item[\meta{string}] can be:
+\begin{itemize}
+\item \lstinline+"inside"+ (default);
+\item \lstinline+"outside"+.
+\end{itemize}
+\end{description}
The result is as follows.
@@ -354,15 +368,12 @@ The result is as follows.
\begin{ExempleMP}
input mpchess
beginfig(0);
-set_coords_outside;
+set_coordinates_position("outside");
init_backboard;
draw backboard;
endfig;
\end{ExempleMP}
-There is also a command to position the coordinates inside the board:
-
-\commande|set_coords_inside|\index{set_coords_inside@\lstinline+set_coords_inside+}\smallskip
You can see in the previous examples that with \package{luamplib} and
\LaTeX, the font used for the coordinates is the font of the current document. To draw these letters and
@@ -370,22 +381,27 @@ these numbers, \mpchess uses the \MP{} operator \lstinline+infont+ and the font
is set to \lstinline+defaultfont+ by default\footnote{With \package{luamplib}
the \lstinline+infont+ operator is redefined and its argument is simply
ignored}, so it is not possible to modify the composition font of the
-coordinates. This font can be changed with the following command.
+coordinates. This font can be changed with the following command\footnote{Attention,
+in version 0.6, \lstinline+set_coords_font+ became
+\lstinline+set_coordinates_font+.}.
-\commande|set_coords_font(«font»)|\index{set_coords_font@\lstinline+set_coords_font+}\smallskip
+\commande|set_coordinates_font(«font»)|\index{set_coordinates_font@\lstinline+set_coordinates_font+}\smallskip
It will then be necessary to use the naming conventions specific to the \MP{}
operator
\lstinline+infont+, and we refer to the
\MP documentation~\cite{ctan-metapost} for more details.
-You can also delete the coordinates with the following command:
+You can also delete the coordinates with the following command\footnote{Attention,
+in version 0.6, \lstinline+set_no_coords+ became
+\lstinline+hide_coordinates+ and \lstinline+set_coords+ became
+\lstinline+show_coordinates+.}:
-\commande|set_no_coords|\index{set_no_coords@\lstinline+set_no_coords+}\smallskip
+\commande|hide_coordinates|\index{hide_coordinates@\lstinline+hide_coordinates+}\smallskip
And the reverse command also exists:
-\commande|set_coords|\index{set_coords@\lstinline+set_coords+}\smallskip
+\commande|show_coordinates|\index{show_coordinates@\lstinline+show_coordinates+}\smallskip
\subsection{White or Black Side}
@@ -409,7 +425,7 @@ chessboard. This is done with the following commands:
\commande|set_black_player(«string»)|\index{set_black_player@\lstinline+set_black_player+}\smallskip
\begin{description}
- \item[\meta{string} :] is the string interpreted by \LaTeX to display.
+ \item[\meta{string} :] is the string interpreted by \LaTeX{} to display.
\end{description}
\begin{ExempleMP}
@@ -495,7 +511,7 @@ The table~\ref{tab:pieces} shows the result of the three sets of pieces.
init_chessboard;
set_backboard_width(4cm);
set_pieces_theme("cburnett");
- unset_whos_to_move;
+ hide_whos_to_move;
init_backboard;
draw backboard;
draw chessboard_step(0);
@@ -507,7 +523,7 @@ The table~\ref{tab:pieces} shows the result of the three sets of pieces.
init_chessboard;
set_backboard_width(4cm);
set_pieces_theme("mpchess");
- unset_whos_to_move;
+ hide_whos_to_move;
init_backboard;
draw backboard;
draw chessboard_step(0);
@@ -520,7 +536,7 @@ The table~\ref{tab:pieces} shows the result of the three sets of pieces.
init_chessboard;
set_backboard_width(4cm);
set_pieces_theme("skak");
- unset_whos_to_move;
+ hide_whos_to_move;
init_backboard;
draw backboard;
draw chessboard_step(0);
@@ -534,7 +550,7 @@ The table~\ref{tab:pieces} shows the result of the three sets of pieces.
\subsection{Specifying to Move}
\mpchess indicates which player has the current move. This is done by
-a small colored triangle (white or black) at the end of the board (which you can
+a small colored triangle (white or black) at the end of the board (which
you can see in the following examples).
To specify which side is to move, use the following commands:
@@ -547,12 +563,15 @@ To specify which side is to move, use the following commands:
By default, white is to move, and this information is displayed.
To activate or deactivate this display, use one of the following two
-commands:
+commands\footnote{Attention,
+in version 0.6, \lstinline+set_whos_to_move+ and
+\lstinline+unset_whos_to_move+ became \lstinline+show_whos_to_move+ and
+\lstinline+hide_whos_to_move+.}:
-\commande|set_whos_to_move|\index{set_whos_to_move@\lstinline+set_whos_to_move+}\smallskip
+\commande|show_whos_to_move|\index{show_whos_to_move@\lstinline+show_whos_to_move+}\smallskip
-\commande|unset_whos_to_move|\index{unset_whos_to_move@\lstinline+unset_whos_to_move+}\smallskip
+\commande|hide_whos_to_move|\index{hide_whos_to_move@\lstinline+hide_whos_to_move+}\smallskip
\subsection{Draw a Position}
@@ -1348,6 +1367,19 @@ endfig;
\section{History}
\begin{description}
+\item[v0.6, April 26, 2023:] Fixed bugs concerning castling management, and
+ moves ambiguities in \textsc{pgn} format.
+Changed \lstinline+set_white_color+ to
+\lstinline+set_white_squares_color+ and \lstinline+set_black_color+ to
+\lstinline+set_black_squares_color+. Change \lstinline+set_no_coords+ to
+\lstinline+hide_coordinates+ and \lstinline+set_coords+ to
+\lstinline+show_coordinates+. Change \lstinline+set_whos_to_move+ to
+\lstinline+show_whos_to_move+ and \lstinline+unset_whos_to_move+ to
+\lstinline+hide_whos_to_move+. Change \lstinline+set_coords_inside+ and
+\lstinline+set_coords_outside+ to \lstinline+set_coordinates_position+.
+Change \lstinline+set_coords_font+ to \lstinline+set_coordinates_font+.
+
+Translated with www.DeepL.com/Translator (free version)
\item[v0.5, April 20, 2023:] Bug fixed, \textbf{changing the
default piece set} for the \lstinline+mpchess+ set (which has been added to Lichess), added TrueType font, and updated documentation.
\item[v0.4, April 6, 2023:] Corrections in the documentation, especially the
@@ -1363,8 +1395,10 @@ license) and creation of the \lstinline+mpchess+ parts theme.
\section{Acknowledgements}
-The author would like to thank Quark67 for his feedback and corrections, and
-Douglas Johnson for correcting the English version of the documentation. This
+The author would like to thank Quark67 for his feedback and corrections,
+Douglas Johnson for correcting the English version of the documentation and Hans
+Nieuwenhuis for his advices.
+This
feedback and encouragement is extremely appreciated!
diff --git a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.pdf b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.pdf
index ed40321556..fd467b6595 100644
--- a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.pdf
+++ b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.pdf
Binary files differ
diff --git a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.tex b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.tex
index 674bf9d619..2ee8714da4 100644
--- a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.tex
+++ b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.tex
@@ -71,7 +71,7 @@
}
\vfill
\begin{center}
- Version 0.5, 20 avril 2023 \\
+ Version 0.6, 26 avril 2023 \\
\url{https://plmlab.math.cnrs.fr/mchupin/mpchess}
\end{center}
%% == Page de garde ====================================================
@@ -316,18 +316,21 @@ Les deux thèmes colorés fournis empruntent les couleurs des thèmes de Lichess
\subsubsection{Configuration d’un thème personnel}
Un thème de couleur est en réalité simplement la définition de deux couleurs.
-Celles-ci peuvent se définir avec les commandes suivantes.
+Celles-ci peuvent se définir avec les commandes suivantes \footnote{Attention,
+lors du passage à la version 0.6, \lstinline+set_white_color+ est devenu
+\lstinline+set_white_squares_color+ et \lstinline+set_black_color+ est devenu
+\lstinline+set_black_squares_color+.}.
-\commande|set_white_color(«color»)|\index{set_white_color@\lstinline+set_white_color+}\par
-\commande|set_black_color(«color»)|\index{set_black_color@\lstinline+set_black_color+}\smallskip
+\commande|set_white_squares_color(«color»)|\index{set_white_squares_color@\lstinline+set_white_squares_color+}\par
+\commande|set_black_squares_color(«color»)|\index{set_black_squares_color@\lstinline+set_black_squares_color+}\smallskip
\meta{color} est une \lstinline+color+ \MP.
\begin{ExempleMP}
input mpchess
beginfig(0);
-set_white_color((0.9,0.8,0.8));
-set_black_color((0.7,0.6,0.6));
+set_white_squares_color((0.9,0.8,0.8));
+set_black_squares_color((0.7,0.6,0.6));
init_backboard;
draw backboard;
endfig;
@@ -338,46 +341,60 @@ Vous avez pu constater dans les divers exemples que par défaut, les coordonnée
sont, comme le fait le site Lichess, inscrites en petit à l’intérieur des
cases.
-\mpchess permet de positionner ces coordonnées à l’extérieur du plateau avec la commande suivante.
+\mpchess permet de choisir le positionnement de ces coordonnées à l’extérieur ou
+à l’intérieur du plateau avec la commande suivante\footnote{Attention,
+en version 0.6, \lstinline+set_coords_inside+ et \lstinline+set_coords_outside+
+ont été remplacés par
+\lstinline+set_coordinates_position+.}.
+
+\commande|set_coordinates_position(«string»)|\index{set_coordinates_position@\lstinline+set_coordinates_position+}\smallskip
+
+\begin{description}
+ \item[\meta{string}] peut valoir :
+\begin{itemize}
+\item \lstinline+"inside"+ (par défaut);
+\item \lstinline+"outside"+.
+\end{itemize}
+\end{description}
-\commande|set_coords_outside|\index{set_coords_outside@\lstinline+set_coords_outside+}\smallskip
Le résultat est alors le suivant.
\begin{ExempleMP}
input mpchess
beginfig(0);
-set_coords_outside;
+set_coordinates_position("outside");
init_backboard;
draw backboard;
endfig;
\end{ExempleMP}
-Il existe aussi la commande permettant de positionner les coordonnées à l’intérieur du plateau.
-
-\commande|set_coords_inside|\index{set_coords_inside@\lstinline+set_coords_inside+}\smallskip
-
Vous pouvez constater dans cette documentation qu’avec \package{luamplib} et
\LaTeX, la fonte est la fonte du document courant. Pour tracer ces lettres et
ces chiffres, \mpchess utilise l’opérateur \MP{} \lstinline+infont+ et la fonte
est réglée à \lstinline+defaultfont+ par défaut\footnote{Avec \package{luamplib}
l’opérateur \lstinline+infont+ est redéfini et son argument est simplement
ignoré, ainsi, il n’est pas possible de modifier la fonte de composition des
-coordonnées.}. On peut modifier cette fonte avec la commande suivante.
+coordonnées.}. On peut modifier cette fonte avec la commande suivante\footnote{Attention,
+en version 0.6, \lstinline+set_coords_font+ est devenue
+\lstinline+set_coordinates_font+.}.
-\commande|set_coords_font(«font»)|\index{set_coords_font@\lstinline+set_coords_font+}\smallskip
+\commande|set_coordinates_font(«font»)|\index{set_coordinates_font@\lstinline+set_coordinates_font+}\smallskip
Il faudra alors utiliser les conventions de nommage propres à l’opérateur
\lstinline+infont+ de \MP{} et nous renvoyons à la
documentation~\cite{ctan-metapost} pour plus de détails.
-On pourra aussi supprimer les coordonnées avec la commande suivante.
+On pourra aussi supprimer les coordonnées avec la commande suivante\footnote{Attention,
+dans la version 0.6, \lstinline+set_no_coords+ est devenu
+\lstinline+hide_coordinates+ et \lstinline+set_coords+ est devenu
+\lstinline+show_coordinates+}.
-\commande|set_no_coords|\index{set_no_coords@\lstinline+set_no_coords+}\smallskip
+\commande|hide_coordinates|\index{hide_coordinates@\lstinline+hide_coordinates+}\smallskip
Et la commande inverse aussi existe.
-\commande|set_coords|\index{set_coords@\lstinline+set_coords+}\smallskip
+\commande|show_coordinates|\index{show_coordinates@\lstinline+show_coordinates+}\smallskip
\subsection{Vue blanche ou noire}
@@ -480,7 +497,7 @@ Thème \lstinline+cburnett+&Thème \lstinline+mpchess+\\
init_chessboard;
set_backboard_width(4cm);
set_pieces_theme("cburnett");
- unset_whos_to_move;
+ hide_whos_to_move;
init_backboard;
draw backboard;
draw chessboard_step(0);
@@ -492,7 +509,7 @@ Thème \lstinline+cburnett+&Thème \lstinline+mpchess+\\
init_chessboard;
set_backboard_width(4cm);
set_pieces_theme("mpchess");
- unset_whos_to_move;
+ hide_whos_to_move;
init_backboard;
draw backboard;
draw chessboard_step(0);
@@ -505,7 +522,7 @@ Thème \lstinline+skak+&\\
init_chessboard;
set_backboard_width(4cm);
set_pieces_theme("skak");
- unset_whos_to_move;
+ hide_whos_to_move;
init_backboard;
draw backboard;
draw chessboard_step(0);
@@ -532,12 +549,15 @@ Pour spécifier qui a le trait on utilisera les commandes suivantes.
Par défaut, c’est aux blancs de jouer, et cette information est affichée.
-Pour activer ou désactiver l’affichage du trait, on utilisera une des deux commandes suivantes.
+Pour activer ou désactiver l’affichage du trait, on utilisera une des deux commandes suivantes\footnote{Attention,
+lors du passage à la version 0.6, \lstinline+set_whos_to_move+ et
+\lstinline+unset_whos_to_move+ sont devenus \lstinline+show_whos_to_move+ et
+\lstinline+hide_whos_to_move+.}.
-\commande|set_whos_to_move|\index{set_whos_to_move@\lstinline+set_whos_to_move+}\smallskip
+\commande|show_whos_to_move|\index{show_whos_to_move@\lstinline+show_whos_to_move+}\smallskip
-\commande|unset_whos_to_move|\index{unset_whos_to_move@\lstinline+unset_whos_to_move+}\smallskip
+\commande|hide_whos_to_move|\index{hide_whos_to_move@\lstinline+hide_whos_to_move+}\smallskip
\subsection{Dessiner une position}
@@ -1326,6 +1346,17 @@ endfig;
\section{Historique}
\begin{description}
+\item[v0.6, avril 2023:] Corrections de bugs concernant la gestion des roques, et
+des ambiguïtés de pièces pour les déplacements sous format \textsc{pgn}.
+Changement de \lstinline+set_white_color+ en
+\lstinline+set_white_squares_color+ et \lstinline+set_black_color+ en
+\lstinline+set_black_squares_color+. Changement de \lstinline+set_no_coords+ en
+\lstinline+hide_coordinates+ et \lstinline+set_coords+ en
+\lstinline+show_coordinates+. Changement de \lstinline+set_whos_to_move+ en
+\lstinline+show_whos_to_move+ et \lstinline+unset_whos_to_move+ en
+\lstinline+hide_whos_to_move+. Changement de \lstinline+set_coords_inside+ et
+\lstinline+set_coords_outside+ en \lstinline+set_coordinates_position+.
+Changement de \lstinline+set_coords_font+ en \lstinline+set_coordinates_font+.
\item[v0.5, 20 avril 2023:] Correction d’un bug, \textbf{changement de
l’ensemble de pièce par défaut} pour l’ensemble \lstinline+mpchess+ (qui a été
ajouté à Lichess), ajout de la fonte TrueType, et mise à jour de la documentation.
@@ -1342,8 +1373,9 @@ licence) et création du thème de pièces \lstinline+mpchess+.
\section{Remerciements}
-Nous souhaitons remercier Quark67 pour ses retours et ses corrections, ainsi
-que Douglas Johnson pour avoir corrigé la version anglaise de la documentation.
+Nous souhaitons remercier Quark67 pour ses retours et ses corrections, Douglas
+Johnson pour avoir corrigé la version anglaise de la documentation et Hans
+Nieuwenhuis pour ses conseils.
Ces retours et encouragements font extrêmement plaisir !
diff --git a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-preamble.tex b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-preamble.tex
index 89ac411f3b..62e5ad2413 100644
--- a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-preamble.tex
+++ b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-preamble.tex
@@ -97,7 +97,7 @@
set_no_coords,set_white_view,set_black_view,
set_white_player,set_black_player,set_pieces_theme,set_players_side,init_chessboard,set_empty_chessboard,add_white_pieces,add_black_pieces,clear_areas,clear_files,clear_ranks,clear_squares,build_chessboard_from_fen,build_chessboards_from_pgn,clear_chessboard,
color_square,draw_arrows,draw_circles,draw_comment,draw_crosses,get_halfmove_number,get_totalmove_number,
- reset_mpchess,set_black_to_move,set_last_move_color,set_comment_color,set_white_to_move,set_whos_to_move,show_last_move,unset_whos_to_move,set_arrow_width,clip_chessboard,build_chessboard_from_fen_file,build_chessboard_from_pgn_file,draw_black_main_lines,draw_black_main_lines_step,draw_white_main_lines,draw_white_main_lines_step,set_main_lines_color,set_possible_moves_color,show_possible_moves,show_possible_moves_step},
+ reset_mpchess,set_black_to_move,set_last_move_color,set_comment_color,set_white_to_move,set_whos_to_move,show_last_move,unset_whos_to_move,set_arrow_width,clip_chessboard,build_chessboard_from_fen_file,build_chessboard_from_pgn_file,draw_black_main_lines,draw_black_main_lines_step,draw_white_main_lines,draw_white_main_lines_step,set_main_lines_color,set_possible_moves_color,show_possible_moves,show_possible_moves_step,hide_coordinates,hide_whos_to_move,set_black_squares_color,set_coordinates_font,set_coordinates_position,set_white_squares_color,show_coordinates,show_whos_to_move},
keywordstyle=\color{darkred},
classoffset=2,% frame=tb
morekeywords={backboard,chessboard,chessboard_step},
diff --git a/graphics/metapost/contrib/macros/mpchess/metapost/mpchess-chessboard.mp b/graphics/metapost/contrib/macros/mpchess/metapost/mpchess-chessboard.mp
index d156438506..4e0fc3bed3 100644
--- a/graphics/metapost/contrib/macros/mpchess/metapost/mpchess-chessboard.mp
+++ b/graphics/metapost/contrib/macros/mpchess/metapost/mpchess-chessboard.mp
@@ -149,7 +149,7 @@ def _draw_step_chessboard(expr k) =
enddef;
-vardef _pawn_candidate(expr istart, jstart,iend,jend,wb,capture)=
+vardef _pawn_candidate(expr istart, jstart,iend,jend,wb,capture,ambiguity)=
% i int from letter, column
% j int for line
% return true if (istart,jstart) to (iend,jend)
@@ -163,33 +163,49 @@ vardef _pawn_candidate(expr istart, jstart,iend,jend,wb,capture)=
if(wb="white"):
if(jend=4): % on the line that allow 2 square move
if(((jstart=3) or (jstart=2)) and (iend=istart)):
- output:=true;
+ if((ambiguity=0) or ((ambiguity<>0) and (ambiguity=istart))):
+ output:=true;
+ fi
fi
if(((jstart=3) and ((istart=iend+1) or (istart=iend-1))) and (capture=1)): %capture
- output:=true;
+ if((ambiguity=0) or ((ambiguity<>0) and (ambiguity=istart))):
+ output:=true;
+ fi
fi
else:
if((jstart=jend-1) and (istart=iend)): % straight move
- output:=true;
+ if((ambiguity=0) or ((ambiguity<>0) and (ambiguity=istart))):
+ output:=true;
+ fi
fi
if(((jstart=jend-1) and ((istart=iend+1) or (istart=iend-1))) and (capture=1)): % capture
- output:=true;
+ if((ambiguity=0) or ((ambiguity<>0) and (ambiguity=istart))):
+ output:=true;
+ fi
fi
fi
else:
if(jend=5): % on the line that allow 2 square move
if(((jstart=6) or (jstart=7)) and (iend=istart)):
- output:=true;
+ if((ambiguity=0) or ((ambiguity<>0) and (ambiguity=istart))):
+ output:=true;
+ fi
fi
if(((jstart=6) and ((istart=iend+1) or (istart=iend-1))) and (capture=1)): %capture
- output:=true;
+ if((ambiguity=0) or ((ambiguity<>0) and (ambiguity=istart))):
+ output:=true;
+ fi
fi
else:
if((jstart=jend+1) and (istart=iend)): % straight move
- output:=true;
+ if((ambiguity=0) or ((ambiguity<>0) and (ambiguity=istart))):
+ output:=true;
+ fi
fi
if(((jstart=jend+1) and ((istart=iend+1) or (istart=iend-1))) and (capture=1)): % capture
- output:=true;
+ if((ambiguity=0) or ((ambiguity<>0) and (ambiguity=istart))):
+ output:=true;
+ fi
fi
fi
fi
@@ -197,7 +213,7 @@ vardef _pawn_candidate(expr istart, jstart,iend,jend,wb,capture)=
output
enddef;
-vardef _bishop_candidate(expr istart, jstart,iend,jend,wb)=
+vardef _bishop_candidate(expr istart, jstart,iend,jend,wb,ambiguity)=
% i int from letter, column
% j int for line
% return true if (istart,jstart) to (iend,jend)
@@ -208,13 +224,15 @@ vardef _bishop_candidate(expr istart, jstart,iend,jend,wb)=
output = false;
if((iend<=_chessSize) and (iend>=1) and (iend<=_chessSize) and (iend>=1)):
if(abs(iend-istart)=abs(jend-jstart)):
- output:=true;
+ if((ambiguity=0) or ((ambiguity<>0) and (ambiguity=istart))):
+ output:=true;
+ fi
fi
fi
output
enddef;
-vardef _rook_candidate(expr istart, jstart,iend,jend,wb)=
+vardef _rook_candidate(expr istart, jstart,iend,jend,wb,ambiguity)=
% i int from letter, column
% j int for line
% return true if (istart,jstart) to (iend,jend)
@@ -225,7 +243,9 @@ vardef _rook_candidate(expr istart, jstart,iend,jend,wb)=
output = false;
if((iend<=_chessSize) and (iend>=1) and (iend<=_chessSize) and (iend>=1)):
if((iend=istart) or (jend=jstart)):
- output:=true;
+ if((ambiguity=0) or ((ambiguity<>0) and (ambiguity=istart))):
+ output:=true;
+ fi
fi
fi
output
@@ -266,7 +286,7 @@ vardef _king_candidate(expr istart, jstart,iend,jend,wb)=
output
enddef;
-vardef _knight_candidate(expr istart, jstart,iend,jend,wb)=
+vardef _knight_candidate(expr istart, jstart,iend,jend,wb,ambiguity)=
% i int from letter, column
% j int for line
% return true if (istart,jstart) to (iend,jend)
@@ -276,31 +296,34 @@ vardef _knight_candidate(expr istart, jstart,iend,jend,wb)=
boolean output;
output = false;
if((iend<=_chessSize) and (iend>=1) and (iend<=_chessSize) and (iend>=1)):
- if(((abs(iend-istart)=2) and (abs(jend-jstart)=1)) or ((abs(iend-istart)=1) and (abs(jend-jstart)=2))):
- output:=true;
+ if(((abs(iend-istart)=2) and (abs(jend-jstart)=1)) or
+ ((abs(iend-istart)=1) and (abs(jend-jstart)=2))):
+ if((ambiguity=0) or ((ambiguity<>0) and (ambiguity=istart))):
+ output:=true;
+ fi
fi
fi
output
enddef;
-vardef _chess_candidate(expr type, istart, jstart, iend, jend,wb,capture)=
+vardef _chess_candidate(expr type, istart, jstart, iend, jend,wb,capture,ambiguity)=
numeric _pm;
_pm:=1;
if(wb="black"):
_pm:=-1;
fi
if(type=(_pm*_intWPawn)):
- _pawn_candidate(istart,jstart,iend,jend,wb,capture)
+ _pawn_candidate(istart,jstart,iend,jend,wb,capture,ambiguity)
elseif(type=_pm*_intWBishop):
- _bishop_candidate(istart,jstart,iend,jend,wb)
+ _bishop_candidate(istart,jstart,iend,jend,wb,ambiguity)
elseif(type=_pm*_intWKing):
_king_candidate(istart,jstart,iend,jend,wb)
elseif(type=_pm*_intWKnight):
- _knight_candidate(istart,jstart,iend,jend,wb)
+ _knight_candidate(istart,jstart,iend,jend,wb,ambiguity)
elseif(type=_pm*_intWQueen):
_queen_candidate(istart,jstart,iend,jend,wb)
elseif(type=_pm*_intWRook):
- _rook_candidate(istart,jstart,iend,jend,wb)
+ _rook_candidate(istart,jstart,iend,jend,wb,ambiguity)
fi
enddef;
@@ -352,11 +375,42 @@ def _build_all_chessboards=
_wb:="white";
else:
_wb:="black";
- fi
+ fi
+ % castling
+ if(_piecetype=100): % short castling
+ if(_pm=1):
+ _tmp_line:=1;
+ else:
+ _tmp_line:=8;
+ fi
+ if((chessboard_table[k][5][_tmp_line]=_pm*_intWKing) and
+ (chessboard_table[k][8][_tmp_line]=_pm*_intWRook)): % if king and
+ % in the right places
+ chessboard_table[k][5][_tmp_line]:=0;
+ chessboard_table[k][8][_tmp_line]:=0;
+ chessboard_table[k][6][_tmp_line]:=_pm*_intWRook;
+ chessboard_table[k][7][_tmp_line]:=_pm*_intWKing;
+ fi
+ fi
+ if(_piecetype=1000): % long castling
+ if(_pm=1):
+ _tmp_line:=1;
+ else:
+ _tmp_line:=8;
+ fi
+ if((chessboard_table[k][5][_tmp_line]=_pm*_intWKing) and
+ (chessboard_table[k][1][_tmp_line]=_pm*_intWRook)): % if king and
+ % in the right places
+ chessboard_table[k][5][_tmp_line]:=0;
+ chessboard_table[k][1][_tmp_line]:=0;
+ chessboard_table[k][4][_tmp_line]:=_pm*_intWRook;
+ chessboard_table[k][3][_tmp_line]:=_pm*_intWKing;
+ fi
+ fi
for i:=1 upto _chessSize:
for j:=1 upto _chessSize:
if(chessboard_table[k][i][j]=_piecetype):
- if(_chess_candidate(_piecetype, i, j, _iend, _jend,_wb,_capture)=true):
+ if(_chess_candidate(_piecetype, i, j, _iend, _jend,_wb,_capture,_ambiguity)=true):
if(_capture<>0):
if(_pm=1):
_chess_white_captures[k][_chess_wcaptures_nbr[k-1]]:=chessboard_table[k][i][j];
@@ -466,7 +520,7 @@ def _draw_main_lines(expr _k)(expr wb)(text slist)=
for i:=1 upto _chessSize:
for j:=1 upto _chessSize:
if(chessboard_table[_k][i][j]=_piecetype):
- if(_chess_candidate(_piecetype, i, j, _iend, _jend,wb,_capture)=true):
+ if(_chess_candidate(_piecetype, i, j, _iend, _jend,wb,_capture,_ambiguity)=true):
draw_arrows(_chess_main_lines_color)(_int_to_letter_w(i)&_int_to_str_w(j)&"--"&_int_to_letter_w(_iend)&_int_to_str_w(_jend));
fi
fi
@@ -740,9 +794,6 @@ def show_possible_moves_step(expr k)(expr s)=
for _ii:=-1 upto 1:
for _jj:=-1 upto 1:
if((_fl+_ii>0) and (_fl+_ii<9) and (_fn+_jj>0) and (_fn+_jj<9)):
- show "king";
- show _ii;
- show _jj;
if((_piecetype*chessboard_table[k][_fl+_ii][_fn+_jj])<=0):
_circle_move(_fl+_ii,_fn+_jj);
fi
diff --git a/graphics/metapost/contrib/macros/mpchess/metapost/mpchess-pgn.mp b/graphics/metapost/contrib/macros/mpchess/metapost/mpchess-pgn.mp
index 155aaad262..0796018e93 100644
--- a/graphics/metapost/contrib/macros/mpchess/metapost/mpchess-pgn.mp
+++ b/graphics/metapost/contrib/macros/mpchess/metapost/mpchess-pgn.mp
@@ -246,11 +246,11 @@ vardef _extract_single_move(expr s,wb)=
numeric output[];
_str := s;
_length:= length(_str);
- if(str="O-O"):
+ if(_str="O-O"):
_piecetype:=100;
_letter:=100;
_nbr:=100;
- elseif(str="O-O-O"):
+ elseif(_str="O-O-O"):
_piecetype:=1000;
_letter:=1000;
_nbr:=1000;
diff --git a/graphics/metapost/contrib/macros/mpchess/metapost/mpchess.mp b/graphics/metapost/contrib/macros/mpchess/metapost/mpchess.mp
index 0fc53bdf59..d16c821493 100644
--- a/graphics/metapost/contrib/macros/mpchess/metapost/mpchess.mp
+++ b/graphics/metapost/contrib/macros/mpchess/metapost/mpchess.mp
@@ -2,7 +2,7 @@
%% mpchess.mp %%
%% draw chessboards with metapost %%
%% chupin@ceremade.dauphine.fr %%
-%% Version 0.5 (avril 2023) %%
+%% Version 0.6 (avril 2023) %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This work may be distributed and/or modified under the conditions of
@@ -12,6 +12,7 @@
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
%input format;
input hatching;
input mpchess-pieces; % piece of mpchess package
@@ -36,7 +37,7 @@ string _coords_font;
_coords_font:=defaultfont;
% chose the font to write coordinates on board
-def set_coords_font(expr f)=
+def set_coordinates_font(expr f)=
_coords_font:=f ;
enddef;
@@ -76,21 +77,24 @@ enddef;
boolean _chess_print_coords,_chess_coords_inout;
_chess_print_coords:=true;
_chess_coords_inout:=true; %true for inside
-def set_no_coords=
+def hide_coordinates=
_chess_print_coords:=false;
enddef;
-def set_coords=
+def show_coordinates=
_chess_print_coords:=true;
enddef;
-def set_coords_inside=
- _chess_coords_inout:=true;
+def set_coordinates_position(expr s)=
+ if(s="inside"):
+ _chess_coords_inout:=true;
+ elseif(s="outside"):
+ _chess_coords_inout:=false;
+ fi
enddef;
-def set_coords_outside=
- _chess_coords_inout:=false;
-enddef;
+
+
% boolean for white or black to move
boolean _white_to_move;
@@ -105,15 +109,15 @@ def set_white_to_move=
enddef;
% boolean to show a mark to indicate whos to move
-boolean show_whos_to_move;
-show_whos_to_move:=true;
+boolean _show_whos_to_move;
+_show_whos_to_move:=true;
-def set_whos_to_move=
- show_whos_to_move:=true;
+def show_whos_to_move=
+ _show_whos_to_move:=true;
enddef;
-def unset_whos_to_move=
- show_whos_to_move:=false;
+def hide_whos_to_move=
+ _show_whos_to_move:=false;
enddef;
@@ -230,11 +234,11 @@ def set_color_theme(expr t)=
fi
enddef;
-def set_white_color(expr c)=
+def set_white_squares_color(expr c)=
_whiteColorSquare:=c;
enddef;
-def set_black_color(expr c)=
+def set_black_squares_color(expr c)=
_blackColorSquare:=c;
enddef;
@@ -683,7 +687,7 @@ vardef _chess_build_chessboard_pic(expr k)=
fi
endfor;
endfor;
- if(show_whos_to_move):
+ if(_show_whos_to_move):
if(_chess_view_wb): %white side
if(not _white_to_move):
fill _triangle(0.3) rotated 180 shifted (_chessSquareU*(_chessSize+0.35),_chessSquareU*(_chessSize)+0.3*_chessSquareU)