I have written the following pseudocode:
\begin{algorithm}
\caption{Check if any player has won.}
\begin{algorithmic}[1]
\Procedure{isWin}{$Game$}
\ForAll{$seq \in \Call{getWinSeqs}{Game}$}
\For{$i \gets 0, length(seq) - 1$}
\If{$\not seq[i] = seq[i + 1]$}
break
\EndIf
\EndFor
\If{$seq[i + 1] = `X'$}
\Return `X'
\ElsIf{$seq[i + 1] = `O'$}
\Return `O'
\EndIf
\EndFor
\Return null
\EndProcedure
\end{algorithmic}
\end{algorithm}
which renders to the following image:
As seen in the image, the final return
is placed directly after end for
. How can I force a newline after return
?
Best Answer
You're using
algpseudocode
rather thanalgorithmicx
; redefine\algorithmicreturn
to issue\State
I've also made some refinements to your code. Note, in particular, that the negation symbol is
\lnot
, while\not
is a different command.