\SetAlgorithmName
requires three arguments:
\SetAlgorithmName{algorithmname}{algorithmautorefname}{list of algorithms name}
such as
\SetAlgorithmName{Heuristic}{heuristic}{List of Heuristics}
You could also directly redefine the macros of the algorithm2e
package:
\renewcommand*{\listalgorithmcfname}{List of Heuristics}
\renewcommand*{\algorithmcfname}{Heuristic}
\renewcommand*{\algorithmautorefname}{heuristic}
I missed the part in the algorithm2e manual when it is stated that the option H
makes the environment non-floatable, thus it could be put inside the tcolorbox environment.
This is the updated code:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[longend]{algorithm2e}
\usepackage{textgreek}
\usepackage{amssymb}
\usepackage{tcolorbox}
\begin{document}
\begin{tcolorbox}[fonttitle=\bfseries, title=Q-learning (off-policy TD control) for estimating $\pi \approx \pi_*$]
\begin{algorithm}[H]
Algorithm parameters: step size $\alpha \in (0, 1]$, small $epsilon > 0$\;
Initialize $Q(s, a)$, for all $s \in \mathcal{S}^+, a \in \mathcal{A}(s)$, arbitrarily except that $Q(\mathrm{terminal}, \cdot) = 0$\;
\ForEach{episode}{
Initialize S\;
\ForEach{step of episode}{
Choose $A$ from $S$ using policy derived from $Q$ (e.g., \textepsilon-greedy)\;
Take action $A$, observe $R$, $S'$\;
$Q(S, A) \leftarrow Q(S, A) + \alpha [R + \gamma \max_a Q(S', a) - Q(S, A)]$\;
$S \leftarrow S'$\;
}
}
\end{algorithm}
\end{tcolorbox}
\end{document}
This is the visual result:
Usually, I don't post self-answered questions. This was a genuine question but I found the answer five minutes after I posted it. Since it could be helpful to others I will leave it here.
Best Answer
Nothing very special here. You can do something like this (notice the use of
\SetKwFunction
to declare a function):