1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 16:23:09 +00:00

Last small touches in RootMoveList

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2010-12-28 19:05:24 +01:00
parent 3346ccc9d9
commit 58c6e64069

View file

@ -129,20 +129,25 @@ namespace {
void set_pv(const Move newPv[]);
int64_t nodes;
Value pv_score, non_pv_score;
Move move, pv[PLY_MAX_PLUS_2];
Value pv_score;
Value non_pv_score;
Move move;
Move pv[PLY_MAX_PLUS_2];
};
RootMove::RootMove() : nodes(0) {
RootMove::RootMove() {
nodes = 0;
pv_score = non_pv_score = -VALUE_INFINITE;
move = pv[0] = MOVE_NONE;
}
RootMove& RootMove::operator=(const RootMove& rm) {
pv_score = rm.pv_score; non_pv_score = rm.non_pv_score;
nodes = rm.nodes; move = rm.move;
nodes = rm.nodes;
pv_score = rm.pv_score;
non_pv_score = rm.non_pv_score;
move = rm.move;
set_pv(rm.pv); // Skip costly full pv[] copy
return *this;
}
@ -151,10 +156,7 @@ namespace {
Move* p = pv;
while (*newPv != MOVE_NONE)
*p++ = *newPv++;
*p = MOVE_NONE;
do *p++ = *newPv; while (*newPv++ != MOVE_NONE);
}
@ -2657,14 +2659,12 @@ split_point_start: // At split points actual search starts from here
/// The RootMoveList class
// RootMoveList c'tor
RootMoveList::RootMoveList(Position& pos, Move searchMoves[]) {
SearchStack ss[PLY_MAX_PLUS_2];
MoveStack mlist[MOVES_MAX];
StateInfo st;
bool includeAllMoves = (searchMoves[0] == MOVE_NONE);
Move* sm;
// Initialize search stack
init_ss_array(ss, PLY_MAX_PLUS_2);
@ -2673,25 +2673,26 @@ split_point_start: // At split points actual search starts from here
// Generate all legal moves
MoveStack* last = generate_moves(pos, mlist);
// Add each move to the moves[] array
// Add each move to the RootMoveList's vector
for (MoveStack* cur = mlist; cur != last; cur++)
{
bool includeMove = includeAllMoves;
// If we have a searchMoves[] list then verify cur->move
// is in the list before to add it.
for (sm = searchMoves; *sm && *sm != cur->move; sm++) {}
for (int k = 0; !includeMove && searchMoves[k] != MOVE_NONE; k++)
includeMove = (searchMoves[k] == cur->move);
if (!includeMove)
if (searchMoves[0] && *sm != cur->move)
continue;
// Find a quick score for the move and add to the list
pos.do_move(cur->move, st);
RootMove rm;
rm.move = ss[0].currentMove = rm.pv[0] = cur->move;
rm.pv[1] = MOVE_NONE;
pos.do_move(cur->move, st);
rm.pv_score = -qsearch<PV>(pos, ss+1, -VALUE_INFINITE, VALUE_INFINITE, DEPTH_ZERO, 1);
pos.undo_move(cur->move);
push_back(rm);
pos.undo_move(cur->move);
}
sort();
}