- /// RootMove and RootMoveList method's definitions
-
- void RootMoveList::init(Position& pos, Move rootMoves[]) {
-
- Move* sm;
- bestMoveChanges = 0;
- clear();
-
- // Generate all legal moves and add them to RootMoveList
- for (MoveList<MV_LEGAL> ml(pos); !ml.end(); ++ml)
- {
- // If we have a rootMoves[] list then verify the move
- // is in the list before to add it.
- for (sm = rootMoves; *sm && *sm != ml.move(); sm++) {}
-
- if (sm != rootMoves && *sm != ml.move())
- continue;
-
- RootMove rm;
- rm.pv.push_back(ml.move());
- rm.pv.push_back(MOVE_NONE);
- rm.score = rm.prevScore = -VALUE_INFINITE;
- rm.nodes = 0;
- push_back(rm);
- }
- }
-
- RootMove* RootMoveList::find(const Move& m, int startIndex) {
-
- for (size_t i = startIndex; i < size(); i++)
- if ((*this)[i].pv[0] == m)
- return &(*this)[i];
-
- return NULL;
- }
-
-
- // extract_pv_from_tt() builds a PV by adding moves from the transposition table.
- // We consider also failing high nodes and not only VALUE_TYPE_EXACT nodes. This
- // allow to always have a ponder move even when we fail high at root and also a
- // long PV to print that is important for position analysis.