Chess programs that mimic some amateurs Is there such a thing as a chess program that at random times can vary it's strength of play between say a beginner and an expert? Or maybe a program that a certain random times makes subtle or obvious mistakes?
Of course, and in fact it's very common.

Stockfish

The code for the implementation:

int weakness = 120 - 2 * level;

// Choose best move. For each move score we add two terms, both dependent on
// weakness. One deterministic and bigger for weaker levels, and one random,
// then we choose the move with the resulting highest score.
for (size_t i = 0; i &lt; multiPV; ++i)
{
    // This is our magic formula
    int push = (  weakness * int(topScore - rootMoves[i].score)
                + delta * (rng.rand&lt;unsigned&gt;() % weakness)) / 128;

    if (rootMoves[i].score + push &gt; maxScore)
    {
        maxScore = rootMoves[i].score + push;
        best = rootMoves[i].pv[0];
    }
}


If you ask Stockfish to play weaker chess, it'd randomly choose a weaker move. It does that by drawing from a uniform distribution and linearly relate the level you choose with the random noise (weakness and push in the code).

SmallChess

Other engines adopt other implementations. For example, I prefer a model where I draw a sudden large jump to simulate a gross blunder. The probability depends on the level, and it is related to the number of pieces on the board. When my engine feels it needs to make a blunder, it'd do a quick shallow search. My intention is try to simulate simple tactic errors.