%--------------------- Cut here ----------------------------------
 
%
%---------------------- General ----------------------------------
%
\font\gray=gray
\font\sym    =cmsy10
\font\bsym   =cmsy10    scaled \magstep1
\font\bbrm   =cmr10     scaled \magstep2
\font\bbss   =cmss10    scaled \magstep2
\font\ssbf   =cmssbx10
\font\bssbf  =cmssbx10  scaled \magstep1
\font\bbssbf =cmssbx10  scaled \magstep2
\font\bbbf   =cmbx10    scaled \magstep2
\font\bbbbsym=cmsy10    scaled \magstep4
\font\bsymbf =cmbsy10   scaled \magstep1
\font\symbf  =cmbsy10
\font\ninesym=cmsy9
\font\eightsym=cmsy8
 
\newif\ifblackfield
\newcount\movenumber
\newcount\linecount
\newcount\colcount
 
\newbox\boxone \newdimen\dimenone
\newbox\boxtwo \newdimen\dimentwo
\newdimen\dimenthree
\newskip\headskipamount  \headskipamount=-8pt
\newskip\footskipamount  \footskipamount=-5pt
 
% 1 dot = 15787.6224 sp bei 300 dots/inch
\newdimen\lowerpiece \lowerpiece=47363sp
\newdimen\fieldwidth \fieldwidth=1326160sp % 84 dots bei 300 dpi
\newdimen\fieldheight \fieldheight=994620sp % 63 dots
\newdimen\fielddepth \fielddepth=\fieldwidth % Rest
     \advance\fielddepth by -\fieldheight
\newdimen\framewidth  \framewidth=252602sp % 16 dots
 
\def\notation{%
    \catcode`\8=11 \catcode`\2=11 \catcode`\3=11 \catcode`\4=11
    \catcode`\5=11 \catcode`\6=11 \catcode`\7=11 \catcode`\1=11}
\catcode`\@=11
%
%---------------------- Pieces -----------------------------------
%
\def\setpiece#1{\lower\lowerpiece\hbox to \fieldwidth{\hfill#1\hfill}}
 
\def\together#1#2{%
   \setbox\boxone=\hbox{#1}\setbox\boxtwo=\hbox{#2}%
   \dimenone=\wd\boxone \dimentwo=\wd\boxtwo
   \dimenthree=-\dimenone
   \advance\dimenone by -\dimentwo \divide\dimenone by 2
   \advance\dimenthree by \dimenone
   \unhbox\boxone\kern\dimenthree\unhbox\boxtwo}
 
\def\pmb#1{\setbox0=\hbox{#1}%
    \kern-.025em\copy0\kern-\wd0
    \kern .05em\copy0\kern-\wd0
    \kern-0.025em\raise .0433em\box0 }
\def\WB{\together{\kern 0pt\hbox{\bbbbsym\char14 }}%
    {\kern -1pt\hbox{\vrule height 1.4pt depth 0pt width 8pt}}}
\def\SB{\together{\kern 0pt\hbox{\bbbbsym\char15 }}%
    {\kern -1pt\hbox{\vrule height 1.4pt depth 0pt width 8pt}}}
\edef\WS{\setbox0=\hbox{\bsym\char120 }\raise\dp0\hbox{\unhbox0 }}
\edef\SS{\setbox0=\hbox{\pmb{\bsymbf\char120 }}%
   \together{\raise\dp0\hbox{\unhbox0 }}%
        {\raise3pt\hbox{\pmb{\symbf\char15 }}}}
\edef\WT{{\bbrm\char5 }}
\edef\ST{\together{\kern-1pt\hbox{\bbbf\char5 }}%
     {\vrule height 9.5pt width 6pt depth 0pt}}
\edef\WK{\together{\symbf\char117 }%
     {\together{\raise 4pt\hbox{\sym\char121 }}%
     {\vrule width 5pt depth0pt height 0.4pt}}}
\edef\SK{\together{\vrule width 6pt depth 0pt height 6pt}%
    {\raise 5pt \hbox{\symbf\char121 }}}
\edef\WL{{\bbss\char3 }}
\edef\SL{\together{\bbssbf\char3 }%
    {\together{\bssbf\char3 }{\together{\vrule height 5pt width 5pt
                        depth 0pt}{\ssbf\char3 }}}}
\edef\SD{\together{\together{\pmb{\symbf\char52 }}%
           {\together{\pmb{\ninesym\char52 }}%
           {\together{\pmb{\eightsym\char52 }}{\symbf\char15 }}}}%
           {\kern 1pt\hbox{\raise 6pt\hbox{\symbf\char15 }}}}
\edef\WD{\together{\symbf\char52 }%
    {\kern  0pt\hbox{\raise 6pt\hbox{\symbf\char14 }}}}
%
%---------------------- Board ------------------------------------
%
\def\fieldstrut{\vrule height \fieldheight depth \fielddepth  width 0pt}
\def\void{}
 
\def\field#1.#2.{\def\next{#1}%
    \ifx\next\empty\blackfieldfalse
     \else\blackfieldtrue\fi
     \ifblackfield\edef\next{#2}%
    \ifx\next\empty\vrule\fieldstrut\hbox to \fieldwidth
         {\hfill\emptyblackfield\hfill}%
        \else\vrule\fieldstrut\blackborder\setpiece{#2}\fi
    \else\vrule\fieldstrut\setpiece{#2}\fi}
 
\def\nfield#1{\vrule height 0pt depth 0pt\fieldstrut\hbox to \fieldwidth
          {\hfil\rm#1\hfil}}
 
\def\linenumber#1{\hbox to 0pt{\rm \kern -10pt #1\hss}}
 
\def\innerloop#1\innerrepeat{\def\innerbody{#1}\inneriterate}
\def\inneriterate{\innerbody\let\next=\inneriterate
    \else\let\next=\relax\fi\next}
 
%
% This is for a character width of 1.4454pt
%
\newcount\numberofchars
\newcount\numberofborderchars
\newcount\numberofgapchars
\numberofchars=14 \numberofborderchars=4
%
% This is for a character width of 0.9636pt
%
%\numberofchars=21 \numberofborderchars=5
 
\numberofgapchars=\numberofchars
\advance\numberofgapchars by -\numberofborderchars
\advance\numberofgapchars by -\numberofborderchars
 
\def\emptyblackfield{\vbox to \fieldheight{\gray
   \offinterlineskip\parindent=0pt
   \setbox0=\hbox{\char1 }\hsize=\wd0 \multiply \hsize by \numberofchars\relax
   \linecount=0
   \loop\advance\linecount by 1 \colcount=0
    \innerloop\advance\colcount by 1 \char1
         \ifnum\colcount<\numberofchars\relax\innerrepeat
    \ifnum\linecount<\numberofchars\relax\break\repeat
   \vss}}
 
\def\blackborder{\hbox to 0pt{\vbox to \fieldheight{\gray
   \offinterlineskip\parindent=0pt
   \setbox0=\hbox{\char1 }\hsize=\wd0 \multiply \hsize by \numberofchars\relax
   \linecount=0
   \count0=\numberofchars \advance\count0 by -\numberofborderchars
   \loop\advance\linecount by 1 \colcount=0
    \innerloop\advance\colcount by 1 \char1
         \ifnum\colcount<\numberofchars\relax\innerrepeat
    \ifnum\linecount<\numberofborderchars\relax\break\repeat
   \break
   \loop\advance\linecount by 1 \colcount=0
    \innerloop\advance\colcount by 1 \char1
         \ifnum\colcount<\numberofborderchars\relax\innerrepeat
    \hfill\colcount=0
    \innerloop\advance\colcount by 1 \char1
         \ifnum\colcount<\numberofborderchars\relax\innerrepeat
    \ifnum\linecount<\count0\relax\break\repeat
   \break
   \loop\advance\linecount by 1 \colcount=0
    \innerloop\advance\colcount by 1 \char1
         \ifnum\colcount<\numberofchars\relax\innerrepeat
    \ifnum\linecount<\numberofchars\relax\break\repeat
   \vss}\hss}}
 
{\notation
 \gdef\showboard{\par\centerline{Board after
  \ifx\colour\whitecolour Black's \else White's \fi
  \number\movenumber.\ move}\vskip \headskipamount
  $$\vbox{\offinterlineskip
  \halign{\linenumber{##}&\vrule\field##.&\field##.&\field##.&\field##.&
            \field##.&\field##.&\field##.&\field##.\vrule\vrule\cr
    \noalign{\hrule}\noalign{\hrule}
    8& .\@a8&*.\@b8& .\@c8&*.\@d8& .\@e8&*.\@f8& .\@g8&*.\@h8\cr
    \noalign{\hrule}
    7&*.\@a7& .\@b7&*.\@c7& .\@d7&*.\@e7& .\@f7&*.\@g7& .\@h7\cr
    \noalign{\hrule}
    6& .\@a6&*.\@b6& .\@c6&*.\@d6& .\@e6&*.\@f6& .\@g6&*.\@h6\cr
    \noalign{\hrule}
    5&*.\@a5& .\@b5&*.\@c5& .\@d5&*.\@e5& .\@f5&*.\@g5& .\@h5\cr
    \noalign{\hrule}
    4& .\@a4&*.\@b4& .\@c4&*.\@d4& .\@e4&*.\@f4& .\@g4&*.\@h4\cr
    \noalign{\hrule}
    3&*.\@a3& .\@b3&*.\@c3& .\@d3&*.\@e3& .\@f3&*.\@g3& .\@h3\cr
    \noalign{\hrule}
    2& .\@a2&*.\@b2& .\@c2&*.\@d2& .\@e2&*.\@f2& .\@g2&*.\@h2\cr
    \noalign{\hrule}
    1&*.\@a1& .\@b1&*.\@c1& .\@d1&*.\@e1& .\@f1&*.\@g1& .\@h1\cr
    \noalign{\hrule}\noalign{\hrule}
    }\vskip \footskipamount
  \halign{\linenumber{##}&\nfield{##}&\nfield{##}&\nfield{##}&\nfield{##}&
             \nfield{##}&\nfield{##}&\nfield{##}&\nfield{##}\cr
    &a&b&c&d&e&f&g&h\cr}
  }$$\par}
}
 
{\notation
 \gdef\setupboard{\def\colour{W}\movenumber=0
 \gdef\@a8{\ST}\gdef\@b8{\SS}\gdef\@c8{\SL}\gdef\@d8{\SD}%
 \gdef\@e8{\SK}\gdef\@f8{\SL}\gdef\@g8{\SS}\gdef\@h8{\ST}%
 \gdef\@a7{\SB}\gdef\@b7{\SB}\gdef\@c7{\SB}\gdef\@d7{\SB}%
 \gdef\@e7{\SB}\gdef\@f7{\SB}\gdef\@g7{\SB}\gdef\@h7{\SB}%
 \gdef\@a6{\void}\gdef\@b6{\void}\gdef\@c6{\void}\gdef\@d6{\void}%
 \gdef\@e6{\void}\gdef\@f6{\void}\gdef\@g6{\void}\gdef\@h6{\void}%
 \gdef\@a5{\void}\gdef\@b5{\void}\gdef\@c5{\void}\gdef\@d5{\void}%
 \gdef\@e5{\void}\gdef\@f5{\void}\gdef\@g5{\void}\gdef\@h5{\void}%
 \gdef\@a4{\void}\gdef\@b4{\void}\gdef\@c4{\void}\gdef\@d4{\void}%
 \gdef\@e4{\void}\gdef\@f4{\void}\gdef\@g4{\void}\gdef\@h4{\void}%
 \gdef\@a3{\void}\gdef\@b3{\void}\gdef\@c3{\void}\gdef\@d3{\void}%
 \gdef\@e3{\void}\gdef\@f3{\void}\gdef\@g3{\void}\gdef\@h3{\void}%
 \gdef\@a2{\WB}\gdef\@b2{\WB}\gdef\@c2{\WB}\gdef\@d2{\WB}%
 \gdef\@e2{\WB}\gdef\@f2{\WB}\gdef\@g2{\WB}\gdef\@h2{\WB}%
 \gdef\@a1{\WT}\gdef\@b1{\WS}\gdef\@c1{\WL}\gdef\@d1{\WD}%
 \gdef\@e1{\WK}\gdef\@f1{\WL}\gdef\@g1{\WS}\gdef\@h1{\WT}}
}
\setupboard
%
%---------------------- Moves ------------------------------------
%
\def\move#1#2#3#4#5#6 {% Syntax: [KDTLS ][a-h][1-8][-x][a-h][1-8]
    % Man beachte, dass der erste Parameter fehlen kann, d.h., dies muss
    % erst ermittelt werden mit hilfe des dritten.
    \if#3-\@move B#1#2#3#4#5%
       \else\if#3x\@move B#1#2#3#4#5%
        \else\@move #1#2#3#4#5#6\fi\fi
    \ifx\colour\whitecolour\def\colour{S}\advance\movenumber by 1
    \else\def\colour{W}\fi
    }
 
\def\whitecolour{W}
\def\colour{W}
 
\def\@move#1#2#3#4#5#6{% Syntax: [KDTLSB][a-h][1-8][-x][a-h][1-8]
    \expandafter\def\csname @#2#3\endcsname{\void}%
    \ifx\colour\whitecolour
    \expandafter\def\csname @#5#6\endcsname{\csname W#1\endcsname}%
    \else\expandafter\def\csname @#5#6\endcsname{\csname S#1\endcsname}\fi}
 
\catcode`\@=12
%
%---------------------- End of Macro Definitions -----------------
%
    \move e2-e4  \move c7-c6
    \move d2-d4  \move d7-d5
    \move Sb1-d2 \move d5xe4
    \move Sd2xe4 \move Sb8-d7
    \move Sg1-f3
  \showboard
