% !TEX program = xelatex\documentclass{article}\usepackage{chessboard}\usepackage[LSBC4,T1]{fontenc}\let\clipbox\relax\usepackage{../styles/style}\usepackage{../styles/langs}\usepackage{disclaimer}\usepackage{ulem}%\usepackage{tipauni}\tikzset{% pics/piece/.style n args={1}{ code={% \fill[rounded corners] (-0.1,-0.1) rectangle (-0.9, -0.9); \fill[left color=white,rounded corners, right color=gray, opacity=0.7] (-0.1,-0.1) rectangle (-0.9, -0.9); \draw[line width=0.4mm,rounded corners] (-0.1,-0.1) rectangle (-0.9, -0.9); \draw[line width=0.2mm,rounded corners] (-0.2,-0.2) rectangle (-0.8, -0.8); \draw[anchor=mid] (-0.5,-0.6) node {#1}; }}, pics/king/.style n args={1}{ code={% \fill[rounded corners] (-0.1,-0.1) rectangle (-0.9, -0.9); \fill[left color=white,rounded corners, right color=gray, opacity=0.7] (-0.1,-0.1) rectangle (-0.9, -0.9); \draw[line width=0.4mm,rounded corners] (-0.1,-0.1) rectangle (-0.9, -0.9); \draw[line width=0.2mm,rounded corners] (-0.2,-0.2) rectangle (-0.8, -0.8); \draw[anchor=mid] (-0.5,-0.6) node {#1}; \draw[anchor=center] (-0.5,-0.25) node {\includegraphics[scale=0.015]{crown.png}}; }}}\begin{document}\setchessboard{smallboard, zero, showmover=false, boardfontencoding=LSBC4, hlabelformat=\arabic{ranklabel}, vlabelformat=\arabic{filelabel}}\mbox{}\\[-18mm]\mbox{}\section*{Resit:\\ Implementing the Shogun Board Game\\ (Scala, 8 Marks)}\noindentYou are asked to implement a Scala program for playing the Shogunboard game. The deadline for your submission is on 26th July at16:00. Make sure you use \texttt{scala-cli} and Scala version \textbf{3.XX}for the resit---the same version as during the lectures. \medskip\IMPORTANTNONE{}\noindentAlso note that the running time of each task will be restricted to amaximum of 30 seconds on my laptop: If you calculate a result once,try to avoid to calculate the result again.\DISCLAIMER{}\subsection*{Background}Shogun(\faVolumeUp\,[shÅgoon]) is a game played by two players on a chess board and is somewhatsimilar to chess and checkers. A real Shogun board lookslike in the pictures on the left.\begin{center}\begin{tabular}{@{}ccc@{}}\raisebox{2mm}{\includegraphics[scale=0.1]{shogun2.jpeg}}&\raisebox{2mm}{\includegraphics[scale=0.14]{shogun.jpeg}}&\begin{tikzpicture}[scale=0.45,every node/.style={scale=0.45}]% chessboard\draw[very thick,gray] (0,0) rectangle (8,8);\foreach\x in {0,...,7}\foreach\y in {7,...,0}{ \pgfmathsetmacro\blend{Mod(\x+\y,2)==0?75:25} \fill[gray!\blend] (\x,\y) rectangle ++ (1,1);}% black pieces\foreach\x/\y/\e in {1/1/1,2/1/3,3/1/2,4/1/3,6/1/3,7/1/1,8/1/2} \pic[fill=white] at (\x,\y) {piece={\e}};% white pieces\foreach\x/\y/\e in {1/8/4,2/8/2,3/8/4,5/8/4,6/8/2,7/8/3,8/8/1} \pic[fill=red] at (\x,\y) {piece={\e}};\pic[fill=white] at (5.0,1.0) {king={1}};\pic[fill=red] at (4.0,8.0) {king={2}};% numbers\foreach\x in {1,...,8}{\draw (\x - 0.5, -0.4) node {\x};}\foreach\y in {1,...,8}{\draw (-0.4, \y - 0.6, -0.4) node {\y};}\end{tikzpicture}\end{tabular}\end{center}\noindentIn what follows we shall use board illustrations as shown on the right. Ascan be seen there are two colours in Shogun for the pieces, red and white. Eachplayer has 8 pieces, one of which is a king (the piece with the crown)and seven are pawns. At the beginning the pieces are lined up as shownabove. What sets Shogun apart from chess and checkers is that eachpiece has, what I call, a kind of \textit{energy}---which for pawns isa number between 1 and 4, and for kings between 1 and 2. The energydetermines how far a piece has to move. In the physical version ofShogun, the pieces and the board have magnets that can change theenergy of a piece from move to move---so a piece on one field can haveenergy 2 and on a different field the same piece might have energy3. There are some further constraints on legal moves, which areexplained below. The point of the resit is to implement functionsabout moving pieces on the Shogun board.\medskip\medskip%and testing for when a%checkmate occurs---i.e.~the king is attacked and cannot move%anymore to an ``unattacked'' field (to simplify matters for%the resit we leave out the case where the checkmate can be averted by capturing%the attacking piece).\medskip\noindentLike in chess, in Shogun the players take turns of moving andpossibly capturing opposing pieces.There are the following rules on how pieces can move:\begin{itemize}\item The energy of a piece determines how far, that is how many fields, a piece has to move (remember pawns have an energy between 1 -- 4, kings have an energy of only 1 -- 2). The energy of a piece might change when the piece moves to new field.\item Pieces can move in straight lines (up, down, left, right), or in L-shape moves, meaning a move can make a single 90$^{\circ}$-turn. S-shape moves with more than one turn are not allowed. Also in a single move a piece cannot go forward and then go backward---for example with energy 3 you cannot move 2 fields up and then 1 field down. A piece can never move diagonally.\item A piece cannot jump over another piece and cannot stack up on top of your own pieces. But you can capture an opponent's piece if you move to an occupied field. A captured piece is removed from the board.\end{itemize}\noindentLike in chess, checkmate is determined when the king of a player cannotmove anymore to a field that is not attacked, or a player cannotcapture or block the attacking piece, or the king is the onlypiece left for a player. A non-trivial board that is checkmate is the following:\begin{center}\begin{tikzpicture}[scale=0.5,every node/.style={scale=0.5}]% chessboard\draw[very thick,gray] (0,0) rectangle (8,8);\foreach\x in {0,...,7}\foreach\y in {7,...,0}{ \pgfmathsetmacro\blend{Mod(\x+\y,2)==0?75:25} \fill[gray!\blend] (\x,\y) rectangle ++ (1,1);}% redpieces\pic[fill=red] at (4,2) {king={2}};\pic[fill=red] at (6,1) {piece={3}};\pic[fill=red] at (4,4) {piece={4}};\pic[fill=red] at (5,3) {piece={4}};% white pieces\pic[fill=white] at (7,1) {king={2}};\pic[fill=white] at (8,5) {piece={2}};\pic[fill=white] at (4,1) {piece={2}};% numbers\foreach\x in {1,...,8}{\draw (\x - 0.5, -0.4) node {\x};}\foreach\y in {1,...,8}{\draw (-0.4, \y - 0.6, -0.4) node {\y};}\end{tikzpicture}\end{center}\noindentThe reason for the checkmate is that the white king on field (7, 1) isattacked by the red pawn on \mbox{(5, 3)}. There is nowhere for thewhite king to go, and no white pawn can be moved into the way of thisred pawn and white can also not capture it. When determining a possiblemove, you need to be careful with pieces that might be in theway. Consider the following position:\begin{equation}\label{moves}\begin{tikzpicture}[scale=0.5,every node/.style={scale=0.5}]% chessboard\draw[very thick,gray] (0,0) rectangle (8,8);\foreach\x in {0,...,7}\foreach\y in {7,...,0}{ \pgfmathsetmacro\blend{Mod(\x+\y,2)==0?75:25} \fill[gray!\blend] (\x,\y) rectangle ++ (1,1);}% redpieces\fill[blue!50] (0,2) rectangle ++ (1,1);\fill[blue!50] (1,1) rectangle ++ (1,1);\fill[blue!50] (0,4) rectangle ++ (1,1);\fill[blue!50] (1,5) rectangle ++ (1,1);\fill[blue!50] (2,6) rectangle ++ (1,1);%%\fill[blue!50] (3,7) rectangle ++ (1,1);\fill[blue!50] (4,6) rectangle ++ (1,1);\fill[blue!50] (5,5) rectangle ++ (1,1);\fill[blue!50] (6,4) rectangle ++ (1,1);\fill[blue!50] (6,2) rectangle ++ (1,1);\fill[blue!50] (7,3) rectangle ++ (1,1);\fill[blue!50] (4,0) rectangle ++ (1,1);\fill[blue!50] (2,0) rectangle ++ (1,1);\pic[fill=red] at (4,4) {piece={4}};\pic[fill=red] at (4,8) {piece={4}};\pic[fill=white] at (2,5) {piece={3}};\pic[fill=white] at (4,3) {piece={2}};\pic[fill=white] at (6,3) {piece={1}};\pic[fill=white] at (8,4) {piece={1}};% numbers\foreach\x in {1,...,8}{\draw (\x - 0.5, -0.4) node {\x};}\foreach\y in {1,...,8}{\draw (-0.4, \y - 0.6, -0.4) node {\y};}\end{tikzpicture}\end{equation}\noindentThe red piece in the centre on field (4, 4) can move to all the blue fields.In particular it can move to (2, 6), because it can move 2 fields upand 2 fields to the left---it cannot reach this field by moving twofields to the left and then two up, because jumping over the whitepiece at (2, 5) is not allowed. Similarly, the field at (6, 2) isunreachable for the red piece because of the two white pieces at (4,3) and (6, 3) are in the way and no S-shape move is allowed inShogun. The red piece on (4, 4) cannot move to the field (4, 8) at thetop, because a red piece is already there; but it can move to (8, 4)and capture the white piece there. The moral is we always have toexplore all possible ways in order to determine whether a piece can bemoved to a field or not: in general there might be several ways and some ofthem might be blocked.\subsection*{Hints}Useful functions about pieces and boards are defined at the beginningof the template file. The function \texttt{.map} applies a function toeach element of a list or set; \texttt{.flatMap} works like\texttt{map} followed by a \texttt{.flatten}---this is useful if afunction returns a set of sets, which need to be ``unioned up''. Setscan be partitioned according to a predicate with the function\texttt{.partition}. For example\begin{lstlisting}val (even, odd) = Set(1,2,3,4,5).partition(_ % 2 == 0)// --> even = Set(2,4)// odd = Set(1,3,5)\end{lstlisting}\noindentThe function \texttt{.toList} transforms a set into a list. The function\texttt{.count} counts elements according to a predicate. For example\begin{lstlisting}Set(1,2,3,4,5).count(_ % 2 == 0)// --> 2\end{lstlisting}%% \newpage\subsection*{Tasks}You are asked to implement how pieces can move on a Shogun board. Letus first fix the basic datastructures for the implementation. A\emph{position} (or field) is a pair of integers, like $(3, 2)$. Theboard's dimension is always 8 $\times$ 8. A \emph{colour} is eitherred (\texttt{Red}) or white (\texttt{Wht}). A \emph{piece} is eithera pawn or a king, and has a position, a colour and an energy (aninteger). In the template file there are functions \texttt{incx},\texttt{decx}, \texttt{incy} and \texttt{decy} for incrementing anddecrementing the x- and y-coordinates of positions of pieces.A \emph{board} consists of a set of pieces. We always assume that westart with a consistent board and every move only generates anotherconsistent board. In this way we do not need to check, for example,whether pieces are stacked on top of each other or located outside theboard, or have an energy outside the permitted range. There arefunctions \texttt{-} and \texttt{+} for removing, respectively adding,single pieces to a board. The function \texttt{occupied} takes aposition and a board as arguments, and returns an \texttt{Option} of apiece when this position is occupied, otherwise \texttt{None}. Thefunction \texttt{occupied\_by} returns the colour of a potential pieceon that position. The function \texttt{is\_occupied} returns a booleanfor whether a position is occupied or not; \texttt{print\_board} is arough function that prints out a board on the console. This functionis meant for testing purposes.\begin{itemize}\item[(1)] You need to calculate all possible moves for a piece on a Shogun board. In order to make sure no piece moves forwards and backwards at the same time, and also exclude all S-shape moves, the data-structure \texttt{Move} is introduced. A \texttt{Move} encodes all simple moves (up, down, left, right) and L-shape moves (first right, then up and so on). This is defined as follows:{\small\begin{lstlisting}abstract class Movecase object U extends Move // upcase object D extends Move // downcase object R extends Move // rightcase object L extends Move // leftcase object RU extends Move // ...case object LU extends Movecase object RD extends Movecase object LD extends Movecase object UR extends Movecase object UL extends Movecase object DR extends Movecase object DL extends Move\end{lstlisting}}You need to implement an \texttt{eval} function that takes a piece\texttt{pc}, a move \texttt{m}, an energy \texttt{en} and a board\texttt{b} as arguments. The idea is to recursively calculate allfields that can be reached by the move \texttt{m} (there might be more thanone). The energy acts as a counter and decreases in each recursivecall until 0 is reached (the final field). The function \texttt{eval} for a piece \texttt{pc}should behave as follows:\begin{itemize}\item If the position of a piece is outside the board, then no field can be reached (represented by the empty set \texttt{Set()}).\item If the energy is 0 and the position of the piece is \textit{not} occupied, then the field can be reached and the set \texttt{Set(pc)} is returned whereby \texttt{pc} is the piece given as argument.\item If the energy is 0 and the position of the piece \textit{is} occupied, but occupied by a piece of the opposite colour, then also the set \texttt{Set(pc)} is returned. Otherwise the empty set \texttt{Set()} is returned.\item In case the energy is > 0 and the position of the piece \texttt{pc} is occupied, then this move is blocked and the set \texttt{Set()} is returned.\item In all other cases we have to analyse the move \texttt{m}. First, the simple moves (that is \texttt{U}, \texttt{D}, \texttt{L} and \texttt{R}) we only have to increment / decrement the x- or y-position of the piece, decrease the energy and call eval recursively with the updated arguments. For example for \texttt{U} (up) you need to increase the y-coordinate: \begin{center} \texttt{U} $\quad\Rightarrow\quad$ new arguments: \texttt{incy(pc)}, \texttt{U}, energy - 1, same board \end{center} The move \texttt{U} here acts like a ``mode'', meaning if you move up, you can only move up; the mode never changes for simple moves. Similarly for the other simple moves: if you move right, you can only move right and so on. In this way it is prevented to go first to the right, and then change direction in order to go left (same with up and down). For the L-shape moves (\texttt{RU}, \texttt{LU}, \texttt{RD} and so on) you need to calculate two sets of reachable fields. Say we analyse \texttt{RU}, then we first have to calculate all fields reachable by moving to the right; then we have to calculate all moves by changing the mode to \texttt{U}. That means there are two recursive calls to \texttt{eval}: \begin{center} \begin{tabular}{@{}lll@{}} \texttt{RU} & $\Rightarrow$ & new args for call 1: \texttt{incx(pc)}, \texttt{RU}, energy - 1, same board\\ & & new args for call 2: \texttt{pc}, \texttt{U}, same energy, same board \end{tabular} \end{center} In each case we receive some new piece(s) on reachable fields and therefore we return the set containing all these fields. Similarly in the other cases.\end{itemize}For example in the left board below, \texttt{eval} is called with the whitepiece in the centre and the move \texttt{RU} generates then a set ofnew pieces corresponding to the blue fields. The difference with theright board is that \texttt{eval} is called with a red piece and therefore thefield (4, 8) is not reachable anymore because it is already occupied byanother red piece. But (7, 5) becomes reachable because it is occupiedby a piece of the opposite colour.\begin{center}\begin{tabular}{cc}\begin{tikzpicture}[scale=0.45,every node/.style={scale=0.45}]% chessboard\draw[very thick,gray] (0,0) rectangle (8,8);\foreach\x in {0,...,7}\foreach\y in {7,...,0}{ \pgfmathsetmacro\blend{Mod(\x+\y,2)==0?75:25} \fill[gray!\blend] (\x,\y) rectangle ++ (1,1);}\fill[blue!50] (5,5) rectangle ++ (1,1);\fill[blue!50] (3,7) rectangle ++ (1,1);\fill[blue!50] (4,6) rectangle ++ (1,1);%\fill[blue!50] (6,4) rectangle ++ (1,1);\fill[blue!50] (7,3) rectangle ++ (1,1);% black pieces\foreach\x/\y/\e in {2/1/3,3/1/2,4/1/3,6/1/3,7/1/1,7/5/2} \pic[fill=white] at (\x,\y) {piece={\e}};% white pieces\foreach\x/\y/\e in {1/8/4,2/8/2,3/8/4,5/8/4,6/8/2,7/8/3,8/8/1} \pic[fill=red] at (\x,\y) {piece={\e}};\pic[fill=white] at (5.0,1.0) {king={1}};\pic[fill=red] at (4.0,8.0) {king={2}};\pic[fill=white] at (4,4) {piece={4}};% numbers\foreach\x in {1,...,8}{\draw (\x - 0.5, -0.4) node {\x};}\foreach\y in {1,...,8}{\draw (-0.4, \y - 0.6, -0.4) node {\y};}\end{tikzpicture}&\begin{tikzpicture}[scale=0.45,every node/.style={scale=0.45}]% chessboard\draw[very thick,gray] (0,0) rectangle (8,8);\foreach\x in {0,...,7}\foreach\y in {7,...,0}{ \pgfmathsetmacro\blend{Mod(\x+\y,2)==0?75:25} \fill[gray!\blend] (\x,\y) rectangle ++ (1,1);}\fill[blue!50] (5,5) rectangle ++ (1,1);\fill[blue!50] (4,6) rectangle ++ (1,1);\fill[blue!50] (6,4) rectangle ++ (1,1);\fill[blue!50] (7,3) rectangle ++ (1,1);% black pieces\foreach\x/\y/\e in {1/1/1,2/1/3,3/1/2,4/1/3,6/1/3,7/1/1,7/5/2} \pic[fill=white] at (\x,\y) {piece={\e}};% white pieces\foreach\x/\y/\e in {1/8/4,2/8/2,3/8/4,5/8/4,6/8/2,7/8/3} \pic[fill=red] at (\x,\y) {piece={\e}};\pic[fill=white] at (5.0,1.0) {king={1}};\pic[fill=red] at (4.0,8.0) {king={2}};\pic[fill=red] at (4,4) {piece={4}};% numbers\foreach\x in {1,...,8}{\draw (\x - 0.5, -0.4) node {\x};}\foreach\y in {1,...,8}{\draw (-0.4, \y - 0.6, -0.4) node {\y};}\end{tikzpicture}\\[-5mm]\end{tabular}\end{center}\hfill[3 Marks]\item[(2)] Implement an \texttt{all\_moves} function that calculates for a piece and a board, \textit{all} possible onward positions. For this you have to call \texttt{eval} for all possible moves \texttt{m} (that is \texttt{U}, \texttt{D}, \ldots, \texttt{DL}). An example for all moves for the red piece on (4, 4) is shown in \eqref{moves} on page \pageref{moves}. Be careful about possible modifications you need to apply to the board before you call the \texttt{eval} function. Also for this task, ignore the fact that a king cannot move onto an attacked field.\\ \mbox{}\hfill[1 Mark]\item[(3)] Implement a function \texttt{attacked} that takes a colour and a board and calculates all pieces of the opposite side that are attacked. For example below in the left board are all the attacked pieces by red, and on the right all for white:\begin{center}\begin{tabular}{cc}\begin{tikzpicture}[scale=0.45,every node/.style={scale=0.45}]% chessboard\draw[very thick,gray] (0,0) rectangle (8,8);\foreach\x in {0,...,7}\foreach\y in {7,...,0}{ \pgfmathsetmacro\blend{Mod(\x+\y,2)==0?75:25} \fill[gray!\blend] (\x,\y) rectangle ++ (1,1);}\fill[blue!50] (7,3) rectangle ++ (1,1);\fill[blue!50] (6,0) rectangle ++ (1,1);% red pieces\foreach\x/\y/\e in {6/1/3,4/4/4,5/3/4,6/5/3} \pic[fill=red] at (\x,\y) {piece={\e}};% white pieces\foreach\x/\y/\e in {8/4/1,4/1/2,8/7/3,6/7/2} \pic[fill=white] at (\x,\y) {piece={\e}};\pic[fill=red] at (4,2) {king={2}};\pic[fill=white] at (7,1) {king={2}};% numbers\foreach\x in {1,...,8}{\draw (\x - 0.5, -0.4) node {\x};}\foreach\y in {1,...,8}{\draw (-0.4, \y - 0.6, -0.4) node {\y};}\end{tikzpicture}&\begin{tikzpicture}[scale=0.45,every node/.style={scale=0.45}]% chessboard\draw[very thick,gray] (0,0) rectangle (8,8);\foreach\x in {0,...,7}\foreach\y in {7,...,0}{ \pgfmathsetmacro\blend{Mod(\x+\y,2)==0?75:25} \fill[gray!\blend] (\x,\y) rectangle ++ (1,1);}\fill[blue!50] (5,0) rectangle ++ (1,1);\fill[blue!50] (5,4) rectangle ++ (1,1);% red pieces\foreach\x/\y/\e in {6/1/3,4/4/4,5/3/4,6/5/3} \pic[fill=red] at (\x,\y) {piece={\e}};% white pieces\foreach\x/\y/\e in {8/4/1,4/1/2,8/7/3,6/7/2} \pic[fill=white] at (\x,\y) {piece={\e}};\pic[fill=red] at (4,2) {king={2}};\pic[fill=white] at (7,1) {king={2}};% numbers\foreach\x in {1,...,8}{\draw (\x - 0.5, -0.4) node {\x};}\foreach\y in {1,...,8}{\draw (-0.4, \y - 0.6, -0.4) node {\y};}\end{tikzpicture}\\[-5mm]\end{tabular}\end{center}\mbox{}\hfill[1 Mark]\item[(4)] Implement a function \texttt{attackedN} that takes a piece and a board and calculates the number of times this pieces is attacked by pieces of the opposite colour. For example the piece on field (8, 4) above is attacked by 3 red pieces, and the piece on (6, 1) by 1 white piece. In this number also include kings even if they cannot move to this field because the would be in ``check''. \mbox{}\hfill[1 Mark]\item[(5)] Implement a function \texttt{protectedN} that takes a piece and a board and calculates the number of times this pieces is protected by pieces of the same colour. For example the piece on field (8, 4) above is protected by 1 white pieces (the one on (8, 7)), and the piece on (5, 3) is protected by three red pieces ((6, 1), (4, 2), and (6, 5)). Similarly to \texttt{attackedN}, include in the calculated number here also the king provided it can reach the given piece. \\ \mbox{}\hfill[1 Mark] \item[(6)] Implement a function \texttt{legal\_moves} that behaves like \texttt{all\_moves} from (2) for pawns, but for kings, in addition, makes sure that they do not move to an attacked field. For example in the board below on the left, there are three possible fields the white king can reach, but all of them are attacked by red pieces. In the board on the right where the white king has an energy of 1, there is only one legal move, namely to move to field (8, 1). The field (7, 2) is reachable, but is attacked; similarly capturing the red piece on field (6, 1) is not possible because it is protected by at least another red piece. % \begin{center} \begin{tabular}{cc} \begin{tikzpicture}[scale=0.45,every node/.style={scale=0.45}] % chessboard \draw[very thick,gray] (0,0) rectangle (8,8); \foreach\x in {0,...,7}\foreach\y in {7,...,0} { \pgfmathsetmacro\blend{Mod(\x+\y,2)==0?75:25} \fill[gray!\blend] (\x,\y) rectangle ++ (1,1); } \fill[blue!50] (5,1) rectangle ++ (1,1); \fill[blue!50] (6,2) rectangle ++ (1,1); \fill[blue!50] (7,1) rectangle ++ (1,1); % red pieces \foreach\x/\y/\e in {6/1/3,4/4/4,5/3/4,6/5/3} \pic[fill=red] at (\x,\y) {piece={\e}}; % white pieces \foreach\x/\y/\e in {8/4/1,4/1/2,8/7/3,6/7/2} \pic[fill=white] at (\x,\y) {piece={\e}}; \pic[fill=red] at (4,2) {king={2}}; \pic[fill=white] at (7,1) {king={2}}; % numbers \foreach\x in {1,...,8} {\draw (\x - 0.5, -0.4) node {\x}; } \foreach\y in {1,...,8} {\draw (-0.4, \y - 0.6, -0.4) node {\y}; } \end{tikzpicture} & \begin{tikzpicture}[scale=0.45,every node/.style={scale=0.45}] % chessboard \draw[very thick,gray] (0,0) rectangle (8,8); \foreach\x in {0,...,7}\foreach\y in {7,...,0} { \pgfmathsetmacro\blend{Mod(\x+\y,2)==0?75:25} \fill[gray!\blend] (\x,\y) rectangle ++ (1,1); } \fill[blue!50] (5,0) rectangle ++ (1,1); \fill[blue!50] (6,1) rectangle ++ (1,1); \fill[blue!50] (7,0) rectangle ++ (1,1); % red pieces \foreach\x/\y/\e in {6/1/3,4/4/4,5/3/3,6/5/3} \pic[fill=red] at (\x,\y) {piece={\e}}; % white pieces \foreach\x/\y/\e in {8/4/1,4/1/2,8/7/3,6/7/2} \pic[fill=white] at (\x,\y) {piece={\e}}; \pic[fill=red] at (4,2) {king={2}}; \pic[fill=white] at (7,1) {king={1}}; % numbers \foreach\x in {1,...,8} {\draw (\x - 0.5, -0.4) node {\x}; } \foreach\y in {1,...,8} {\draw (-0.4, \y - 0.6, -0.4) node {\y}; } \end{tikzpicture} \end{tabular} \end{center} \mbox{}\hfill[1 Mark]\end{itemize}\end{document}%%% Local Variables:%%% mode: latex%%% TeX-master: t%%% End: