--- a/cws/main_cw04.tex Mon Nov 06 21:49:55 2023 +0000
+++ b/cws/main_cw04.tex Fri Dec 08 00:54:36 2023 +0000
@@ -130,7 +130,7 @@
energy of a piece from move to move---so a piece on one field can have
energy 2 and on a different field the same piece might have energy
3. There are some further constraints on legal moves, which are
-explained below. The point of this part is to implement functions
+explained below. The point of this coursework part is to implement functions
about moving pieces on the Shogun board.\medskip\medskip
%and testing for when a
@@ -162,9 +162,9 @@
\noindent
Like in chess, checkmate is determined when the king of a player cannot
-move anymore to a field that is not attacked, or a player cannot
+move anymore to a field that is not attacked, or cannot
capture or block the attacking piece, or the king is the only
-piece left for a player. A board that is checkmate is the following:
+piece 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}]
@@ -297,7 +297,7 @@
decrementing the x- and y-coordinates of positions of pieces.
A \emph{board} consists of a set of pieces. We always assume that we
-start with a consistent board and every move generates another
+start with a consistent board and every move only generates another
consistent board. In this way we do not need to check, for example,
whether pieces are stacked on top of each other or located outside the
board, or have an energy outside the permitted range. There are
@@ -351,7 +351,8 @@
\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.
+ 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.
@@ -359,7 +360,7 @@
\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}
+ recursively with the updated arguments. For example for \texttt{U} (up)
you need to increase the y-coordinate:
\begin{center}
@@ -367,7 +368,7 @@
\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. Similarly for the other simple moves: if
+ 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).
@@ -472,7 +473,7 @@
\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.\\
+ 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
@@ -548,7 +549,8 @@
\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.
+ 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]
@@ -556,7 +558,8 @@
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