Answers.Body: <blockquote>
    <p>play the game until six pieces</p>
  </blockquote>
  
  <p>Stockfish doesn't do that, that's not what tablebase is for. Briefly, tablebase boosts engine search well <strong>before</strong> six-men position reached on the board.</p>
  
  <p>Let's do an exercise, add the board 5 pieces. Now you have 10 pieces on the board, and it's not something you can find in any tablebase. However, during the engine search <strong>whenever Stockfish trades down to 6 pieces</strong>, it can instantly use the tablebase information. The tablebase information gives Stockfish whether's the position is a win/loss/drawn without ever going down to anything like 5 pieces. Therefore, the search is faster and more efficient.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The relevant code is <a href="https://github.com/official-stockfish/Stockfish/blob/master/src/search.cpp" rel="noreferrer">https://github.com/official-stockfish/Stockfish/blob/master/src/search.cpp</a>:</p>
  
  <pre><code>// Step 4a. Tablebase probe
  if (!rootNode &amp;&amp; TB::Cardinality)
  {
      int piecesCount = pos.count&lt;ALL_PIECES&gt;();
  
      if (    piecesCount &lt;= TB::Cardinality
          &amp;&amp; (piecesCount &lt;  TB::Cardinality || depth &gt;= TB::ProbeDepth)
          &amp;&amp;  pos.rule50_count() == 0
          &amp;&amp; !pos.can_castle(ANY_CASTLING))
      {
  </code></pre>
  
  <p><code>TB::Cardinality</code> is by default 6. Stockfish checks how many pieces, if it's no more than 6 it consults the tablebase information. Otherwise, regular search. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-24T08:21:26.123Z
Answers.Text: So does stockfish consult the tablebase prior to reaching a position with 6 pieces on the board?
Answers.UserDisplayName: Wais Kamal
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-24T08:26:03.477Z
Answers.Text: @WaisKamal I updated with relevant code. SF does the checking.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2017-11-24T08:19:15.957Z
Answers.LastActivityDate: 2019-08-24T19:59:23.213Z
Answers.LastEditDate: 2019-08-24T19:59:23.213Z
Answers.UserDisplayName: SmallChess
Body: <p>I use Arena GUI together with stockfish in engine games. I want to download a 6-piece tablebase but that is just a lot of work (and perhaps unnecessary). If I download the tablebase (syzygy), does stockfish work with it or just waits for the board to have 6-pieces and then the tablebase makes its moves?</p>
  
  <h1>Here is what I mean in more detail</h1>
  
  <h3>Stockfish working with the tablebase</h3>
  
  <p>I assume I have the following position:</p>
  
  <p>(Note: currently I am not talking about the best moves, just an example)</p>
  
  <pre><code>[Event "Computer Chess Game"]
  [White "Stockfish 8"]
  [Black "Wais Kamal"]
  [Result "1-0"]
  [SetUp "1"]
  [FEN "2k4b/3r4/8/8/1Q1q4/8/4R3/2KB4 w - - 0 1 "]
  
  1. Qxd4 Rxd4 1-0
  </code></pre>
  
  <p>Stockfish consults the tablebase about what happens after Qxd4 Rxd4 (without continuing to evaluate the rest of the line). If this line is winning it goes for it.</p>
  
  <h3>Stockfish working alone</h3>
  
  <p>Stockfish continues to play the game until six pieces are left on the board, then the tablebase makes the moves.</p>
  
  <p>Which one of these actually takes place?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-24T20:43:33.940Z
Comments.Text: The initial position is won for white, but capturing the black queen is a severe blunder. No idea why black would surrender that...
Comments.UserDisplayName: Deduplicator
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-24T22:33:46.407Z
Comments.Text: Currently I am not talking about the best moves, just an example.
Comments.UserDisplayName: Wais Kamal
Tags: <stockfish><tablebases>
Title: Do Stockfish and the tablebase work together or independently?
ThreadText: # Do Stockfish and the tablebase work together or independently?
  
  (Asked by: username_0 on 2017-11-24)
  
  I use Arena GUI together with stockfish in engine games. I want to download a 6-piece tablebase but that is just a lot of work (and perhaps unnecessary). If I download the tablebase (syzygy), does stockfish work with it or just waits for the board to have 6-pieces and then the tablebase makes its moves?
  
  # Here is what I mean in more detail
  
  ### Stockfish working with the tablebase
  
  I assume I have the following position:
  
  (Note: currently I am not talking about the best moves, just an example)
  
  ```
  [Event "Computer Chess Game"]
  [White "Stockfish 8"]
  [Black "username_0 username_0"]
  [Result "1-0"]
  [SetUp "1"]
  [FEN "2k4b/3r4/8/8/1Q1q4/8/4R3/2KB4 w - - 0 1 "]
  
  1. Qxd4 Rxd4 1-0
  
  ```
  
  Stockfish consults the tablebase about what happens after Qxd4 Rxd4 (without continuing to evaluate the rest of the line). If this line is winning it goes for it.
  
  ### Stockfish working alone
  
  Stockfish continues to play the game until six pieces are left on the board, then the tablebase makes the moves.
  
  Which one of these actually takes place?
  
  **Tags:** stockfish, tablebases
  
  > **Comments:**
  > **username_1**: The initial position is won for white, but capturing the black queen is a severe blunder. No idea why black would surrender that...  
  > **username_0**: Currently I am not talking about the best moves, just an example.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-11-24. Score: 19 | Accepted answer
  
  > play the game until six pieces
  
  Stockfish doesn't do that, that's not what tablebase is for. Briefly, tablebase boosts engine search well **before** six-men position reached on the board.
  
  Let's do an exercise, add the board 5 pieces. Now you have 10 pieces on the board, and it's not something you can find in any tablebase. However, during the engine search **whenever Stockfish trades down to 6 pieces**, it can instantly use the tablebase information. The tablebase information gives Stockfish whether's the position is a win/loss/drawn without ever going down to anything like 5 pieces. Therefore, the search is faster and more efficient.
  
  **EDIT:**
  
  The relevant code is <https://github.com/official-stockfish/Stockfish/blob/master/src/search.cpp>:
  
  ```
  // Step 4a. Tablebase probe
  if (!rootNode && TB::Cardinality)
  {
      int piecesCount = pos.count<ALL_PIECES>();
  
      if (    piecesCount <= TB::Cardinality
          && (piecesCount <  TB::Cardinality || depth >= TB::ProbeDepth)
          &&  pos.rule50_count() == 0
          && !pos.can_castle(ANY_CASTLING))
      {
  
  ```
  
  `TB::Cardinality` is by default 6. Stockfish checks how many pieces, if it's no more than 6 it consults the tablebase information. Otherwise, regular search.
  
  > **Comments:**
  > **username_0**: So does stockfish consult the tablebase prior to reaching a position with 6 pieces on the board?  
  > **username_2**: @username_0 I updated with relevant code. SF does the checking.  
  
  ---
  
  