答案1
该算法使用algorithm2e
:
\documentclass{article}
\usepackage[ruled,vlined,linesnumbered]{algorithm2e}
\newcommand{\funccall}{\textit}
\begin{document}
\begin{algorithm}
\caption{Basic BDI agent control loop}
\KwIn{$B_0$: Initial beliefs}
\KwIn{$I_0$: Initial intentions}
$B \gets B_0$\;
$I \gets I_0$\;
$\pi \gets \funccall{null}$\;
\While{\funccall{alive}}{
$p \gets \funccall{getPercept}()$\;
$B \gets \funccall{update}(B, p)$\;
$D \gets \funccall{wish}(B, I)$\;
$I \gets \funccall{focus}(B, D, I)$\;
$\pi \gets \funccall{plan}(B, I)$\;
$\funccall{execute}(\pi)$\;
}
\end{algorithm}
\end{document}