Grundy number (source code)

= Grundy number
{c}
{title2=$g(P)$}

= Nimber
{synonym}

= Grundy value
{c}
{synonym}

= Sprague-Grundy value
{c}
{synonym}

The value $g(P)=\operatorname{mex}\{g(Q):P\to Q\}$ of a game position, where <mex> is the smallest nonnegative <integer> missing from the values of its legal successors. Terminal positions have value zero. The <Sprague-Grundy theorem> explains why these values combine by <exclusive or>.