Answers.Body: <p>Of course, and in fact it's very common.</p>
  
  <p><strong>Stockfish</strong></p>
  
  <p>The code for the implementation:</p>
  
  <pre><code>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];
      }
  }
  </code></pre>
  
  <p>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 (<em>weakness</em> and <em>push</em> in the code).</p>
  
  <p><strong>SmallChess</strong></p>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-08T09:12:52.277Z
Answers.Text: Can a randomly bad moving chess program still have the ability to play very well, again at random times and in doing so play unpredictably?
Answers.UserDisplayName: 201044
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-08T09:20:45.583Z
Answers.Text: @201044 A bad random move is enough to lose the game, no matter how strong you are. I can easily beat Carlsen 1000-0 if he has to make some random moves in a game. I don't think playing randomly would work.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-08T09:23:49.447Z
Answers.Text: @201044 Remember, most of possible moves in chess are nonsense, like giving up the queen and pieces.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-08T09:25:02.587Z
Answers.Text: Well I should have said a randomly implemented poor yet not game-losing move. Mixed with randomly implemented brilliant moves.
Answers.UserDisplayName: 201044
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-08T09:08:24.260Z
Answers.LastActivityDate: 2015-12-08T09:08:24.260Z
Answers.UserDisplayName: SmallChess
Body: <p>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?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-08T08:10:56.507Z
Comments.Text: Nice question. A chess program that errs like a human ...
Comments.UserDisplayName: Sir Cornflakes
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-08T09:01:56.157Z
Comments.Text: Why would you want that? For learning it's better to play against decent players / AI.
Comments.UserDisplayName: Joshua Bakker
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-08T09:08:32.613Z
Comments.Text: The possibility of such programs is a fun diversion. Also it's a great opportunity to approximate how the mind works in beginner or amateur chess playing. We are not after all precisely programmable so learning  how a possibly disorganized imprecise cognitive system like human beings can manage to even beat some precisely programmed chess engines is very interesting.
Comments.UserDisplayName: 201044
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-08T12:02:41.220Z
Comments.Text: Find one that drops pieces on move 8. It will mimic me!
Comments.UserDisplayName: Tony Ennis
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-20T06:12:55.753Z
Comments.Text: Could a chess program be able to make random mistakes yet still be able to win even with a non-beginner?
Comments.UserDisplayName: 201044
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-05T11:54:23.003Z
Comments.Text: @JoshuaBakker: Your interesting comment has provoked a [question.](http://chess.stackexchange.com/q/14602/315)
Comments.UserDisplayName: thb
Tags: <engines><software><beginner>
Title: Chess programs that mimic some amateurs
ThreadText: # Chess programs that mimic some amateurs
  
  (Asked by: username_0 on 2015-12-08)
  
  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?
  
  **Tags:** engines, software, beginner
  
  > **Comments:**
  > **username_1**: Nice question. A chess program that errs like a human ...  
  > **username_2**: Why would you want that? For learning it's better to play against decent players / AI.  
  > **username_0**: The possibility of such programs is a fun diversion. Also it's a great opportunity to approximate how the mind works in beginner or amateur chess playing. We are not after all precisely programmable so learning  how a possibly disorganized imprecise cognitive system like human beings can manage to even beat some precisely programmed chess engines is very interesting.  
  > **username_3**: Find one that drops pieces on move 8. It will mimic me!  
  > **username_0**: Could a chess program be able to make random mistakes yet still be able to win even with a non-beginner?  
  > **username_4**: @username_2: Your interesting comment has provoked a [question.](http://chess.stackexchange.com/q/14602/315)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_5 on 2015-12-08. Score: 2
  
  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 < multiPV; ++i)
  {
      // This is our magic formula
      int push = (  weakness * int(topScore - rootMoves[i].score)
                  + delta * (rng.rand<unsigned>() % weakness)) / 128;
  
      if (rootMoves[i].score + push > 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).
  
  **username_5**
  
  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.
  
  > **Comments:**
  > **username_0**: Can a randomly bad moving chess program still have the ability to play very well, again at random times and in doing so play unpredictably?  
  > **username_5**: @username_0 A bad random move is enough to lose the game, no matter how strong you are. I can easily beat Carlsen 1000-0 if he has to make some random moves in a game. I don't think playing randomly would work.  
  > **username_5**: @username_0 Remember, most of possible moves in chess are nonsense, like giving up the queen and pieces.  
  > **username_0**: Well I should have said a randomly implemented poor yet not game-losing move. Mixed with randomly implemented brilliant moves.  
  
  ---
  
  