読経 干物経典

...で、留意点をここにメモります。

投稿者: webMaster 投稿日時: 月, 05/11/2015 - 23:40 categories [ ]

コメントの表示オプション

お好みの表示方法を選択し、「設定の保存」をクリックすると、表示方法を変更することができます。

id_loop(...)の章

  // id_loop() is the main iterative deepening loop. It calls search() repeatedly
  // with increasing depth until the allocated thinking time has been consumed,
  // user stops the search, or the maximum search depth is reached.

  void id_loop(...) {

    // Do we have to play with skill handicap? In this case enable MultiPV search
    // that we will use behind the scenes to retrieve a set of possible moves.


    // Iterative deepening loop until requested to stop or target depth reached
    while (...)
    {
        // Age out PV variability metric

        // Save the last iteration's scores before first PV line is searched and
        // all the move scores except the (new) PV are set to -VALUE_INFINITE.

        // MultiPV loop. We perform a full root search for each PV line

        for (...)
        {
            // Reset aspiration window starting size

            // Start with a small aspiration window and, in the case of a fail
            // high/low, re-search with a bigger window until we're not failing
            // high/low anymore.

            while (true)
            {
                // Bring the best move to the front. It is critical that sorting
                // is done with a stable algorithm because all the values but the
                // first and eventually the new best one are set to -VALUE_INFINITE
                // and we want to keep the same order for all the moves except the
                // new PV that goes to the front. Note that in case of MultiPV
                // search the already searched PV lines are preserved.

                // Write PV back to transposition table in case the relevant
                // entries have been overwritten during the search.

                // If search has been stopped break immediately. Sorting and
                // writing PV back to TT is safe because RootMoves is still
                // valid, although it refers to previous iteration.

                // When failing high/low give some update (without cluttering
                // the UI) before a re-search.

                // In case of failing low/high increase aspiration window and
                // re-search, otherwise exit the loop.
            }

            // Sort the PV lines searched so far and update the GUI
        }

        // If skill levels are enabled and time is up, pick a sub-optimal best move

        // Have we found a "mate in x"?

        // Do we have time for the next iteration? Can we stop searching now?
        if (...)
        {
            // Take some extra time if the best move has changed

            // Stop the search if only one legal move is available or all
            // of the available time has been used.
            if (...)
            {
                // If we are allowed to ponder do not stop the search now but
                // keep pondering until the GUI sends "ponderhit" or "stop".
            }
        }
    }

qsearch(...)の章

// qsearch() is the quiescence search function, which is called by the main
// search function when the remaining depth is zero (or, to be more precise,
// less than ONE_PLY).

qsearch(...)
{
   // Check for an instant draw or if the maximum ply has been reached

   // Decide whether or not to include checks: this fixes also the type of
   // TT entry depth that we are going to use. Note that in qsearch we use
   // only two types of depth in TT: DEPTH_QS_CHECKS or DEPTH_QS_NO_CHECKS.

   // Transposition table lookup

   // Evaluate the position statically

   // Initialize a MovePicker object for the current position, and prepare
   // to search the moves. Because the depth is <= 0 here, only captures,
   // queen promotions and checks (only if depth >= DEPTH_QS_CHECKS) will
   // be generated.

   // Loop through the moves until no moves remain or a beta cutoff occurs

   while (...)
   {
      // Futility pruning

      // Detect non-capture evasions that are candidates to be pruned

      // Don't search moves with negative SEE values

      // Speculative prefetch as early as possible

      // Check for legality just before making the move

      // Make and search the move

      // Check for new best move
   }

   // All legal moves have been searched. A special case: If we're in check
   // and no legal moves were found, it is checkmate.
}

search(...)の章

// search<>() is the main search function for both PV and non-PV nodes and for
// normal and SplitPoint nodes. When called just after a split point the search
// is simpler because we have already probed the hash table, done a null move
// search, and searched the first move before splitting, so we don't have to
// repeat all this work again. We also don't need to store anything to the hash
// table here: This is taken care of after we return from the split point.


// Step 1. Initialize node

if (!RootNode)
{
   // Step 2. Check for aborted search and immediate draw

   // Step 3. Mate distance pruning. Even if we mate at the next move our score
   // would be at best mate_in(ss->ply+1), but if alpha is already bigger because
   // a shorter mate was found upward in the tree then there is no need to search
   // because we will never beat the current alpha. Same logic but with reversed
   // signs applies also in the opposite condition of being mated instead of giving
   // mate. In this case return a fail-high score.
}

// Step 4. Transposition table lookup
// We don't want the score of a partial search to overwrite a previous full search
// TT value, so we use a different position key in case of an excluded move.

// Step 4a. Tablebase probe

// Step 5. Evaluate the position statically and update parent's gain statistics

// Step 6. Razoring (skipped when in check)

// Step 7. Futility pruning: child node (skipped when in check)

// Step 8. Null move search with verification search (is omitted in PV nodes)

// Step 9. ProbCut (skipped when in check)
// If we have a very good capture (i.e. SEE > seeValues[captured_piece_type])
// and a reduced search returns a value much above beta, we can (almost) safely
// prune the previous move.

// Step 10. Internal iterative deepening (skipped when in check)

// Step 11. Loop through moves
// Loop through all pseudo-legal moves until no moves remain or a beta cutoff occurs

while(...)
{
   // Step 12. Extend checks

   // Step 13. Pruning at shallow depth

   // Step 14. Make the move

   // Step 15. Reduced depth search (LMR). If the move fails high it will be
   // re-searched at full depth.

   // Step 16. Full depth search, when LMR is skipped or fails high

   // Step 17. Undo move

   // Step 18. Check for new best move

   // Step 19. Check for splitting the search
}

// Step 20. Check for mate and stalemate
// All legal moves have been searched and if there are no legal moves, it
// must be mate or stalemate. If we are in a singular extension search then
// return a fail low score.

コメントの表示オプション

お好みの表示方法を選択し、「設定の保存」をクリックすると、表示方法を変更することができます。