rcpt@rwc.urc.tue.nl (Piet Tutelaers) (12/04/90)
Today I have put a new version (1.1) of my (La)TeX chess package on the
ftp-server `sol.cs.ruu.nl' (131.211.80.5) of the Department of Computer
Science of the Utrecht University, the Netherlands. The main
improvements over my previous version (1.0) are:
- improved chess.sty
o TeXcode cleaned up
o problems with castling solved
o renamed internal macro `\\' because LaTeX uses that
o better hooks to adapt chess.sty to non-english languages
o added torture tests for chess.sty (torture-test.ltx and
torture-test.tex)
- improved (and hopefully accepted) TUGboat article
- improved chessdiag.mf
- other minor enhancements.
If you already have my previous version there is no need to rush out and
get the new version because I have included chess.sty together with the
torture-tests at the end of this message. For those who still want to
download the new package I have included a message containing the
instructions how to do it via ftp and/or E-mail.
Happy (La)TeX chesswriting,
--Piet
==================== getting chess.tar.Z ===============================
How to get chess.tar.Z (includes chess.README) from the archive at
Dept. of Computer Science, Utrecht University:
NOTE: In the following I have assumed your mail address is john@highbrow.edu.
Of course you must substitute your own address for this. This should be
a valid internet or uucp address. For bitnet users name@host.BITNET
usually works.
by FTP: (please restrict access to weekends or evening/night (i.e. between
about 20.00 and 0900 UTC).
ftp archive.cs.ruu.nl [131.211.80.5]
user name: anonymous or ftp
password: your own email address (e.g. john@highbrow.edu)
don't forget to set binary mode if the file is a tar/arc/zoo archive,
compressed or in any other way contains binary data.
get TEX/chess.tar.Z
by mail-server:
send the following message to
mail-server@cs.ruu.nl (or uunet!mcsun!hp4nl!ruuinf):
begin
path john@highbrow.edu
send TEX/chess.tar.Z
end
The path command can be deleted if we receive a valid from address in your
message. If this is the first time you use our mail server, we suggest you
first issue the request:
send HELP
================ improved chess.sty + torture-tests ===== shar-file =====
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: chess.sty torture-test.ltx torture-test.tex
# Wrapped by rcpt@rwc.urc.tue.nl on Mon Dec 3 21:55:24 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f chess.sty -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"chess.sty\"
else
echo shar: Extracting \"chess.sty\" \(11701 characters\)
sed "s/^X//" >chess.sty <<'END_OF_chess.sty'
X%
X% chess.sty
X% ---------
X% Style for writing about chess games
X% Author : Piet Tutelaers (UUCP: rcpt@urc.tue.nl)
X% Version: 1.1 (17 Nov 1990)
X% Improvements over version 1.0:
X% -TeX code cleaned up (thanks to TeX-wizzard Victor Eijkhout)
X% -moving a King does not generate a castling move when this
X% King already moved
X% -renamed internal macro `\\' because LaTeX uses that
X% -better hooks for foreign languages (look for lines marked with
X% %%FOREIGN%%)
X% Torture test:
X% If you change something in the chess.sty style check if everything
X% else is still working with torture-test.ltx (LaTeX) or
X% torture-test.tex (plain TeX).
X% Known problems:
X% -The analysis mode can not be used within arguments of macros
X% not: \centerline{|21.N5*f3|} but: |\centerline{21.N5*f3}|
X% Version: 1.0 (5 Jan 1990)
X%
X
X\def\@set[#1#2](#3){%arguments: [a-h1-8](<letter>)
X \expandafter\xdef\csname#1#2\endcsname{#3}}
X
X\def\@get#1[#2#3]{%arguments:\cs[a-h1-8]
X \edef#1{\csname#2#3\endcsname}}
X
X\font\Chess=chess20
X
X\newcount\@c % column
X\newcount\@r % row
X\newcount\@sum % row+column
X
X\def\@col{\ifcase\@c\or a\or b\or c\or d\or e\or f\or g\or h\fi}
X
X\def\@showchar{
X \@get\piece[\@col\the\@r]
X \if\piece E \ifodd\@sum 0\else Z\fi\else
X \if\piece P \ifodd\@sum P\else O\fi\else
X \if\piece p \ifodd\@sum p\else o\fi\else
X \if\piece R \ifodd\@sum R\else S\fi\else
X \if\piece B \ifodd\@sum B\else A\fi\else
X \if\piece N \ifodd\@sum N\else M\fi\else
X \if\piece r \ifodd\@sum r\else s\fi\else
X \if\piece b \ifodd\@sum b\else a\fi\else
X \if\piece n \ifodd\@sum n\else m\fi\else
X \if\piece K \ifodd\@sum K\else J\fi\else
X \if\piece Q \ifodd\@sum Q\else L\fi\else
X \if\piece k \ifodd\@sum k\else j\fi\else
X \if\piece q \ifodd\@sum q\else l\fi\else
X \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
X
X\def\@showrow#1{
X \@r=#1\@c=1
X \@sum=\@r\advance\@sum by\@c
X \loop
X \@showchar
X \ifnum\@c<8 \advance\@c by1\advance\@sum by1
X \repeat
X}
X
X\def\showboard{
X\vbox{\offinterlineskip
X \hrule height1pt
X \hbox{\vrule width1pt\Chess
X \vbox{\hbox{\@showrow8}
X \hbox{\@showrow7}
X \hbox{\@showrow6}
X \hbox{\@showrow5}
X \hbox{\@showrow4}
X \hbox{\@showrow3}
X \hbox{\@showrow2}
X \hbox{\@showrow1}}%
X \vrule width1pt}
X \hrule height1pt}
X}
X
X% inner loop needs extra { ... }
X
X\def\@emptyboard{
X \@r=1
X \loop
X {\@c=1
X \loop
X \@set[\@col\the\@r](E)
X \ifnum\@c<8 \advance\@c by1
X \repeat}
X \ifnum\@r<8 \advance\@r by 1
X \repeat
X}
X
X\def\@initboard{
X% empty squares
X \@r=3
X \loop
X {\@c=1
X \loop
X \@set[\@col\the\@r](E)
X \ifnum\@c<8 \advance\@c by1
X \repeat}
X \ifnum\@r<6 \advance\@r by 1
X \repeat
X% pawns
X \@c=1
X \loop
X \@set[\@col2](P)\@set[\@col7](p)
X \ifnum\@c<8 \advance\@c by1
X \repeat
X% pieces
X \@set[a1](R)\@set[h1](R)
X \@set[a8](r)\@set[h8](r)
X \@set[b1](N)\@set[g1](N)
X \@set[b8](n)\@set[g8](n)
X \@set[c1](B)\@set[f1](B)
X \@set[c8](b)\@set[f8](b)
X \@set[d1](Q)\@set[e1](K)
X \@set[d8](q)\@set[e8](k)
X}
X
X%
X% The next part defines a user friendly notation for chess moves.
X% Moves works only in chess-environment: \begin{chess} ... \end{chess}
X% in LaTeX, or \chess ... \endchess in plain TeX.
X% Some examples: |21. Nf3-e5, Ke8*f8 22. 0-0-0+, Bh8*a1|
X% : |21.: Ke8*f8 22. Bh8*a1, 0-0|
X% : |21 Nfe5 K*f8 22 0-0-0! B*a1|
X% : |21: K*f8 22 B*a1 0-0|
X%
X
X\font\Fig=chessfig10
X
X\gdef\@king{{\Fig K}}
X\gdef\@queen{{\Fig Q}}
X\gdef\@rook{{\Fig R}}
X\gdef\@bishop{{\Fig B}}
X\gdef\@knight{{\Fig N}}
X\gdef\@dash{--}
X\gdef\@capt{$\times$}
X\gdef\@dots{~$\ldots$,}
X\gdef\@dot{\char46}
X
X%%FOREIGN%% change the following character codes to your language of coice
X%% English % English % Dutch % German % French ....
X\chardef\king@=`K % King % Koning % K"onig % Roi
X\chardef\queen@=`Q % Queen % Dame % Dame % Dame
X\chardef\rook@=`R % Rook % Toren % Turm % Tour
X\chardef\bishop@=`B % Bishop % Loper % L"aufer % Fou
X\chardef\knight@=`N % kNight % Paard % Springer % Cavalier
X%%FOREIGN%% end
X
X\catcode`|=\active
X{\catcode`:=\active\catcode`.=\active\catcode`*=\active\catcode`-=\active
X \catcode\king@=\active\catcode\queen@=\active\catcode\rook@=\active
X \catcode\bishop@=\active\catcode\knight@=\active
X \gdef\@notation{\begingroup\let|=\endgroup
X \catcode`:=\active\catcode`.=\active\catcode`*=\active\catcode`-=\active
X \catcode\king@=\active\catcode\queen@=\active\catcode\rook@=\active
X \catcode\bishop@=\active\catcode\knight@=\active
X%%FOREIGN%% choose the same characters as above
X \letK=\@king\letQ=\@queen\letR=\@rook\letB=\@bishop\letN=\@knight
X%%Dutch \letK=\@king\letD=\@queen\letT=\@rook\letL=\@bishop\letP=\@knight
X%%German\letK=\@king\letD=\@queen\letT=\@rook\letL=\@bishop\letS=\@knight
X%%French\letR=\@king\letD=\@queen\letT=\@rook\letF=\@bishop\letC=\@knight
X%%FOREIGN%% that's all
X \let-=\@dash\let*=\@capt\let:=\@dots\let.=\@dot
X }
X%
X% Provide a chess environment in which the `|' character is active, because
X% the `|' is used by LaTeX in the `tabular' environment!
X%
X \gdef\chess{\catcode`|=\active\let|=\@notation}
X \global\let\endchess\relax
X}
X\catcode`|=12
X
X%
X% Next part provides a ply (half move) generator
X%
X
X\newif\ifWhite \newif\ifFigure \newif\ifcapture
X
X%
X% next newif's needed for castling
X%
X\newif\ifKnotmoved \newif\ifknotmoved
X\newif\ifcastling \newif\ifoo
X
X%
X% Globals for special pawn moves (en passant capture and promotion)
X%
X
X\newif\ifenpassant \newif\ifpromotion
X
X\def\@color#1{ % Color of a piece 0: none, -1: black, 1: white
X \if #1E0\else
X \ifnum`#1=\uccode`#11\else-1\fi\fi}
X
X%
X% No checking is done for validity of moves, only legal moves behave well!!
X%
X
X\def\@ply#1#2#3#4#5 {% Syntax: [a-h][1-8][a-h][1-8]{QRBN}
X \@get\piece[#1#2]\@get\capture[#3#4]\Figuretrue
X \if\capture E\capturefalse\else\capturetrue\fi
X \ifWhite
X \if\piece P\Figurefalse
X \if#46
X \if\eprow#3\capturetrue\enpassanttrue\fi
X \xdef\eprow{x}
X \else
X \xdef\eprow{x}
X \if#22
X \if#44\xdef\eprow{#3}\fi
X \else
X \if#48\promotiontrue\fi
X \fi
X \fi
X \else
X \if\piece K% check for possible castling
X \ifKnotmoved
X \if#3g\if#41\castlingtrue\ootrue\fi
X \else\if#3c\if#41\castlingtrue\oofalse\fi\fi
X \fi
X \global\Knotmovedfalse
X \fi
X \fi
X \fi
X \ifcastling
X \@set[#1#2](E)\@set[#3#4](K)
X \ifoo 0\@dash0#5\@set[f1](R)\@set[h1](E)
X \else 0\@dash0\@dash0#5\@set[d1](R)\@set[a1](E)\fi
X \castlingfalse
X \else
X \ifFigure{\Fig\piece}\fi
X #1#2\ifcapture\@capt\else\@dash\fi#3#4
X \ifpromotion{\Fig#5}\else#5\fi
X \@set[#1#2](E)
X \ifpromotion\@set[#3#4](#5)\else\@set[#3#4](\piece)\fi
X \ifenpassant\@set[#3#2](E)\enpassantfalse\fi
X \fi
X \global\Whitefalse
X \else
X \if\piece p\Figurefalse
X \if#43
X \if\eprow#3\capturetrue\enpassanttrue\fi
X \xdef\eprow{x}
X \else
X \xdef\eprow{x}
X \if#27
X \if#45\xdef\eprow{#3}\fi
X \else
X \if#41\promotiontrue\fi
X \fi
X \fi
X \else
X \if\piece k
X \ifknotmoved
X \if#3g\if#48\castlingtrue\ootrue\fi
X \else\if#3c\if#48\castlingtrue\oofalse\fi\fi
X \fi
X \global\knotmovedfalse
X \fi
X \fi
X \fi
X \ifcastling
X \@set[#1#2](E)\@set[#3#4](k)
X \ifoo 0\@dash0#5\@set[f8](r)\@set[h8](E)
X \else 0\@dash0\@dash0#5\@set[d8](r)\@set[a8](E)\fi
X \castlingfalse
X \else
X \ifFigure{\Fig\if\piece rR\else\if\piece bB\else\if\piece nN\else
X \if\piece qQ\else K\fi\fi\fi\fi}\fi%
X #1#2\ifcapture\@capt\else\@dash\fi#3#4
X \ifpromotion{\Fig#5}\else#5\fi
X \@set[#1#2](E)\ifpromotion\@set[#3#4](#5)\else\@set[#3#4](\piece)\fi
X \ifenpassant\@set[#3#2](E)\enpassantfalse\fi
X \fi
X \global\Whitetrue
X \fi
X}
X
X\newcount\movecount \movecount=0
X
X\def\move#1 #2 {\frenchspacing
X \ifWhite\advance\movecount by 1\fi
X \hskip1cm\llap{\the\movecount.}\hskip.5cm
X \hbox to 2.3cm{\hfil\@ply#1 \hfil}\hskip.5cm
X \hbox to 2.3cm{\hfil\@ply#2 \hfil}
X \par}
X
X\def\ply#1 {\frenchspacing
X \ifWhite\advance\movecount by 1
X \hskip1cm\llap{\the\movecount.}\hskip.5cm
X \hbox to 2.3cm{\hfil\@ply#1 \hfil}
X \else\hskip1cm\llap{\the\movecount.}\hskip.5cm
X \hbox to 2.3cm{\hfil$\ldots$\hfil}\hskip.5cm
X \hbox to 2.3cm{\hfil\@ply#1 \hfil}
X \fi\par}
X
X\def\newgame{\movecount=0 \@initboard
X \Whitetrue\castlingfalse
X \Knotmovedtrue\knotmovedtrue
X \promotionfalse\enpassantfalse}
X
X\def\@dolist{\afterassignment\@dodolist\let\@next= } % Answer 11.5 TeXbook
X\def\@dodolist{\ifx\@next\@endlist \let\@next\relax % adapted to generate
X \else \@nextitem\let\@next\@dolist \fi % chess diagrams
X \@next}
X
X\def\@endlist{\@endlist}
X
X\def\@nextitem{%
X \if\@next\space\@set[\@col\the\@r](E)\else
X \if\@next * \@set[\@col\the\@r](E)\else
X \if\@next P \@set[\@col\the\@r](P)\else
X \if\@next p \@set[\@col\the\@r](p)\else
X \if\@next R \@set[\@col\the\@r](R)\else
X \if\@next r \@set[\@col\the\@r](r)\else
X \if\@next B \@set[\@col\the\@r](B)\else
X \if\@next b \@set[\@col\the\@r](b)\else
X \if\@next N \@set[\@col\the\@r](N)\else
X \if\@next n \@set[\@col\the\@r](n)\else
X \if\@next K \@set[\@col\the\@r](K)\else
X \if\@next k \@set[\@col\the\@r](k)\else
X \if\@next Q \@set[\@col\the\@r](Q)\else
X \if\@next q \@set[\@col\the\@r](q)\else
X \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
X \advance\@c by1}
X
X\def\@initrow#1#2{\@r=#1\@c=1\@dolist#2\@endlist}
X
X%
X% For setting up a position
X%
X\def\board#1#2#3#4#5#6#7#8{
X \@initrow8{#1}
X \@initrow7{#2}
X \@initrow6{#3}
X \@initrow5{#4}
X \@initrow4{#5}
X \@initrow3{#6}
X \@initrow2{#7}
X \@initrow1{#8}}
X
X%
X% Next macros for defining chess position (thanks to Victor Eijkhout)
X%
X\def\White(#1){\def\match{xxx}\xWhite#1,xxx,}
X\def\xWhite#1,{\def\temp{#1}
X \ifx\temp\match \else \WhitePieceOrPawn#1XY \expandafter\xWhite \fi}
X\def\WhitePieceOrPawn#1#2#3#4Y{%
X \if#3X \@set[#1#2](P)
X \else\ifnum`#1=\king@ \@set[#2#3](K)\else % King
X \ifnum`#1=\queen@ \@set[#2#3](Q)\else % Queen
X \ifnum`#1=\rook@ \@set[#2#3](R)\else % Rook
X \ifnum`#1=\bishop@\@set[#2#3](B)\else % Bishop
X \ifnum`#1=\knight@\@set[#2#3](N)\else % kNight
X \fi\fi\fi\fi\fi
X \fi}
X
X\def\Black(#1){\def\match{xxx}\xBlack#1,xxx,}
X\def\xBlack#1,{\def\temp{#1}
X \ifx\temp\match \else \BlackPieceOrPawn#1XY \expandafter\xBlack \fi}
X\def\BlackPieceOrPawn#1#2#3#4Y{
X \if#3X\@set[#1#2](p)
X \else\ifnum`#1=\king@ \@set[#2#3](k)\else % King
X \ifnum`#1=\queen@ \@set[#2#3](q)\else % Queen
X \ifnum`#1=\rook@ \@set[#2#3](r)\else % Rook
X \ifnum`#1=\bishop@\@set[#2#3](b)\else % Bishop
X \ifnum`#1=\knight@\@set[#2#3](n)\else % kNight
X \fi\fi\fi\fi\fi
X \fi}
X
X\def\position{\begingroup%
X \@emptyboard\movecount=0
X \global\Whitetrue\global\castlingfalse
X \global\Knotmovedtrue\global\knotmovedtrue
X \global\promotionfalse\global\enpassantfalse}
X\def\endposition{\endgroup}
X
END_OF_chess.sty
if test 11701 -ne `wc -c <chess.sty`; then
echo shar: \"chess.sty\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f torture-test.ltx -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"torture-test.ltx\"
else
echo shar: Extracting \"torture-test.ltx\" \(1157 characters\)
sed "s/^X//" >torture-test.ltx <<'END_OF_torture-test.ltx'
X%
X% torture-test.ltx
X% ----------------
X% A LaTeX test for the chess.sty style.
X% Author : Piet Tutelaers (UUCP: rcpt@urc.tue.nl)
X% Version: 1 (17 Nov 1990)
X%
X\documentstyle[twocolumn,chess]{article}
X\tracinglostchars=1
X\begin{document}
X
X\subsection*{Torture test for \verb|chess.sty|}
X\begin{position}
X\White(Ke1,Rh1,h7,b2)
X\Black(Ke8,Ra8,a5)
X\global\movecount=50
X\global\Whitefalse
X\end{position}
X
X$$\showboard$$
X
XThe castling test:\par
X\ply e8c8!?
X\ply e1g1
X
XBoth players have castled.
X
X\ply c8e8?
X\ply g1e1?
X
XThey move back their kings... Chess.sty does not check the
Xvalidity of moves.
X
X\ply e8c8
X\ply e1g1??
X
XBut now these moves are not typeset as castling moves because the kings have
Xmoved.
X
XAnd now the `en passant' test:\par
X\ply a5a4
X\move b2b4 a4b3ep
X
X\begin{chess}
XA short analysis test: |54. b3? ab3:| and White looses his pawn.
XBetter seems |54.Nf7 but not 54.Ng6 because then 54:Rg8!|.
X\end{chess}
X
XAnd the promotion test (no comment yet!):
X
X\ply h7h8N
X
X$$\showboard$$
X
X\begin{chess}
XNot in that way?
X
X\centerline{|55.Nf3 Nc6|}
X
XBut in this way!
X
X|\centerline{55.Nf3 Nc6}|
X\end{chess}
X
X\end{document}
END_OF_torture-test.ltx
if test 1157 -ne `wc -c <torture-test.ltx`; then
echo shar: \"torture-test.ltx\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f torture-test.tex -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"torture-test.tex\"
else
echo shar: Extracting \"torture-test.tex\" \(1103 characters\)
sed "s/^X//" >torture-test.tex <<'END_OF_torture-test.tex'
X%
X% torture-test.tex
X% ----------------
X% A plain TeX test for the chess.sty style.
X% Author : Piet Tutelaers (UUCP: rcpt@urc.tue.nl)
X% Version: 1 (17 Nov 1990)
X%
X\catcode`@=11
X\input chess.sty
X\catcode`@=12
X
X\tracinglostchars=1
X
X{\bf Torture test for {\tt chess.sty}}
X\position
X\White(Ke1,Rh1,h7,b2)
X\Black(Ke8,Ra8,a5)
X\global\movecount=50
X\global\Whitefalse
X\endposition
X
X$$\showboard$$
X
XThe castling test:\par
X\ply e8c8!?
X\ply e1g1
X
XBoth players have castled.
X
X\ply c8e8?
X\ply g1e1?
X
XThey move back their kings... Chess.sty does not check the
Xvalidity of moves.
X
X\ply e8c8
X\ply e1g1??
X
XBut now these moves are not typeset as castling moves because the kings have
Xmoved.
X
XAnd now the `en passant' test:\par
X\ply a5a4
X\move b2b4 a4b3ep
X
X\chess
XA short analysis test: |54. b3? ab3:| and White looses his pawn.
XBetter seems |54.Nf7 but not 54.Ng6 because then 54:Rg8!|.
X\endchess
X
XAnd the promotion test (no comment yet!):
X
X\ply h7h8N
X
X$$\showboard$$
X
X\chess
XNot in that way?
X
X\centerline{|55.Nf3 Nc6|}
X
XBut in this way!
X
X|\centerline{55.Nf3 Nc6}|
X\endchess
X
X\bye
END_OF_torture-test.tex
if test 1103 -ne `wc -c <torture-test.tex`; then
echo shar: \"torture-test.tex\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0