- // sp_search() is used to search from a split point. This function is called
- // by each thread working at the split point. It is similar to the normal
- // search() function, but simpler. Because we have already probed the hash
- // table, done a null move search, and searched the first move before
- // splitting, we don't have to repeat all this work in sp_search(). 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.
-
- template <NodeType PvNode>
- void do_sp_search(SplitPoint* sp, int threadID) {
-
- assert(threadID >= 0 && threadID < ThreadsMgr.active_threads());
- assert(ThreadsMgr.active_threads() > 1);
-
- Position pos(*sp->pos, threadID);
- SearchStack* ss = sp->sstack[threadID] + 1;
- ss->sp = sp;
-
- sp_search<PvNode>(pos, ss, Value(threadID), sp->beta, sp->depth, sp->ply);
- }
-
- template <NodeType PvNode>
- void sp_search(Position& pos, SearchStack* ss, Value, Value beta, Depth depth, int ply) {
-
- StateInfo st;
- Move move;
- Depth ext, newDepth;
- Value value;
- Value futilityValueScaled; // NonPV specific
- bool isCheck, moveIsCheck, captureOrPromotion, dangerous;
- int moveCount;
- value = -VALUE_INFINITE;
- SplitPoint* sp = ss->sp;
- Move threatMove = sp->threatMove;
- MovePicker& mp = *sp->mp;
- int threadID = pos.thread();
-
- CheckInfo ci(pos);
- isCheck = pos.is_check();
-
- // Step 10. Loop through moves
- // Loop through all legal moves until no moves remain or a beta cutoff occurs
- lock_grab(&(sp->lock));