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:
parent
3346ccc9d9
commit
58c6e64069
1 changed files with 25 additions and 24 deletions
|
@ -129,32 +129,34 @@ namespace {
|
||||||
void set_pv(const Move newPv[]);
|
void set_pv(const Move newPv[]);
|
||||||
|
|
||||||
int64_t nodes;
|
int64_t nodes;
|
||||||
Value pv_score, non_pv_score;
|
Value pv_score;
|
||||||
Move move, pv[PLY_MAX_PLUS_2];
|
Value non_pv_score;
|
||||||
|
Move move;
|
||||||
|
Move pv[PLY_MAX_PLUS_2];
|
||||||
};
|
};
|
||||||
|
|
||||||
RootMove::RootMove() : nodes(0) {
|
RootMove::RootMove() {
|
||||||
|
|
||||||
pv_score = non_pv_score = -VALUE_INFINITE;
|
nodes = 0;
|
||||||
move = pv[0] = MOVE_NONE;
|
pv_score = non_pv_score = -VALUE_INFINITE;
|
||||||
|
move = pv[0] = MOVE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RootMove& RootMove::operator=(const RootMove& rm) {
|
RootMove& RootMove::operator=(const RootMove& rm) {
|
||||||
|
|
||||||
pv_score = rm.pv_score; non_pv_score = rm.non_pv_score;
|
nodes = rm.nodes;
|
||||||
nodes = rm.nodes; move = rm.move;
|
pv_score = rm.pv_score;
|
||||||
set_pv(rm.pv); // Skip costly full pv[] copy
|
non_pv_score = rm.non_pv_score;
|
||||||
return *this;
|
move = rm.move;
|
||||||
|
set_pv(rm.pv); // Skip costly full pv[] copy
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RootMove::set_pv(const Move newPv[]) {
|
void RootMove::set_pv(const Move newPv[]) {
|
||||||
|
|
||||||
Move* p = pv;
|
Move* p = pv;
|
||||||
|
|
||||||
while (*newPv != MOVE_NONE)
|
do *p++ = *newPv; while (*newPv++ != MOVE_NONE);
|
||||||
*p++ = *newPv++;
|
|
||||||
|
|
||||||
*p = MOVE_NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2657,14 +2659,12 @@ split_point_start: // At split points actual search starts from here
|
||||||
|
|
||||||
/// The RootMoveList class
|
/// The RootMoveList class
|
||||||
|
|
||||||
// RootMoveList c'tor
|
|
||||||
|
|
||||||
RootMoveList::RootMoveList(Position& pos, Move searchMoves[]) {
|
RootMoveList::RootMoveList(Position& pos, Move searchMoves[]) {
|
||||||
|
|
||||||
SearchStack ss[PLY_MAX_PLUS_2];
|
SearchStack ss[PLY_MAX_PLUS_2];
|
||||||
MoveStack mlist[MOVES_MAX];
|
MoveStack mlist[MOVES_MAX];
|
||||||
StateInfo st;
|
StateInfo st;
|
||||||
bool includeAllMoves = (searchMoves[0] == MOVE_NONE);
|
Move* sm;
|
||||||
|
|
||||||
// Initialize search stack
|
// Initialize search stack
|
||||||
init_ss_array(ss, PLY_MAX_PLUS_2);
|
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
|
// Generate all legal moves
|
||||||
MoveStack* last = generate_moves(pos, mlist);
|
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++)
|
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++)
|
if (searchMoves[0] && *sm != cur->move)
|
||||||
includeMove = (searchMoves[k] == cur->move);
|
|
||||||
|
|
||||||
if (!includeMove)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Find a quick score for the move and add to the list
|
// Find a quick score for the move and add to the list
|
||||||
|
pos.do_move(cur->move, st);
|
||||||
|
|
||||||
RootMove rm;
|
RootMove rm;
|
||||||
rm.move = ss[0].currentMove = rm.pv[0] = cur->move;
|
rm.move = ss[0].currentMove = rm.pv[0] = cur->move;
|
||||||
rm.pv[1] = MOVE_NONE;
|
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);
|
rm.pv_score = -qsearch<PV>(pos, ss+1, -VALUE_INFINITE, VALUE_INFINITE, DEPTH_ZERO, 1);
|
||||||
pos.undo_move(cur->move);
|
|
||||||
push_back(rm);
|
push_back(rm);
|
||||||
|
|
||||||
|
pos.undo_move(cur->move);
|
||||||
}
|
}
|
||||||
sort();
|
sort();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue