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

Retire quietsSearched[]

Use MovePicker moves[] to access already tried
quiet moves. A bit of care shall be taken
to avoid calling stage_moves() when we are still
at ttMove stage, because moves are yet to be
generated. Actually our staging move generation
makes this code a bit more tricky than what I'd
like, but removing an ausiliary redundant
array like quietsSearched[] is a good thing.

Idea by DiscoCheck

bench: 9355734
This commit is contained in:
Marco Costalba 2013-11-17 09:12:19 +01:00
parent 9763c69fa5
commit d9c7cad630
3 changed files with 16 additions and 10 deletions

View file

@ -140,6 +140,15 @@ MovePicker::MovePicker(const Position& p, Move ttm, const HistoryStats& h, Piece
} }
/// stage_moves() returns a pointer to the beginning of moves array. It
/// is used to access already tried quiet moves when updating history.
const ExtMove* MovePicker::stage_moves() const {
assert(stage == KILLERS_S1 || stage == QUIETS_1_S1 || stage == QUIETS_2_S1);
return stage == KILLERS_S1 ? killers : moves;
}
/// score() assign a numerical move ordering score to each move in a move list. /// score() assign a numerical move ordering score to each move in a move list.
/// The moves with highest scores will be picked first. /// The moves with highest scores will be picked first.
template<> template<>

View file

@ -88,6 +88,7 @@ public:
MovePicker(const Position&, Move, const HistoryStats&, PieceType); MovePicker(const Position&, Move, const HistoryStats&, PieceType);
MovePicker(const Position&, Move, Depth, const HistoryStats&, Move*, Search::Stack*); MovePicker(const Position&, Move, Depth, const HistoryStats&, Move*, Search::Stack*);
const ExtMove* stage_moves() const;
template<bool SpNode> Move next_move(); template<bool SpNode> Move next_move();
private: private:

View file

@ -484,7 +484,6 @@ namespace {
assert(PvNode || (alpha == beta - 1)); assert(PvNode || (alpha == beta - 1));
assert(depth > DEPTH_ZERO); assert(depth > DEPTH_ZERO);
Move quietsSearched[64];
StateInfo st; StateInfo st;
const TTEntry *tte; const TTEntry *tte;
SplitPoint* splitPoint; SplitPoint* splitPoint;
@ -494,7 +493,7 @@ namespace {
Value bestValue, value, ttValue, eval, nullValue, futilityValue; Value bestValue, value, ttValue, eval, nullValue, futilityValue;
bool inCheck, givesCheck, pvMove, singularExtensionNode, improving; bool inCheck, givesCheck, pvMove, singularExtensionNode, improving;
bool captureOrPromotion, dangerous, doFullDepthSearch; bool captureOrPromotion, dangerous, doFullDepthSearch;
int moveCount, quietCount; int moveCount;
// Step 1. Initialize node // Step 1. Initialize node
Thread* thisThread = pos.this_thread(); Thread* thisThread = pos.this_thread();
@ -515,7 +514,7 @@ namespace {
goto moves_loop; goto moves_loop;
} }
moveCount = quietCount = 0; moveCount = 0;
bestValue = -VALUE_INFINITE; bestValue = -VALUE_INFINITE;
ss->currentMove = threatMove = (ss+1)->excludedMove = bestMove = MOVE_NONE; ss->currentMove = threatMove = (ss+1)->excludedMove = bestMove = MOVE_NONE;
ss->ply = (ss-1)->ply + 1; ss->ply = (ss-1)->ply + 1;
@ -901,8 +900,6 @@ moves_loop: // When in check and at SpNode search starts from here
pvMove = PvNode && moveCount == 1; pvMove = PvNode && moveCount == 1;
ss->currentMove = move; ss->currentMove = move;
if (!SpNode && !captureOrPromotion && quietCount < 64)
quietsSearched[quietCount++] = move;
// Step 14. Make the move // Step 14. Make the move
pos.do_move(move, st, ci, givesCheck); pos.do_move(move, st, ci, givesCheck);
@ -1077,11 +1074,10 @@ moves_loop: // When in check and at SpNode search starts from here
// played non-capture moves. // played non-capture moves.
Value bonus = Value(int(depth) * int(depth)); Value bonus = Value(int(depth) * int(depth));
History.update(pos.moved_piece(bestMove), to_sq(bestMove), bonus); History.update(pos.moved_piece(bestMove), to_sq(bestMove), bonus);
for (int i = 0; i < quietCount - 1; ++i)
{ if (bestMove != ttMove)
Move m = quietsSearched[i]; for (const ExtMove* em = mp.stage_moves(); em->move != bestMove; ++em)
History.update(pos.moved_piece(m), to_sq(m), -bonus); History.update(pos.moved_piece(em->move), to_sq(em->move), -bonus);
}
if (is_ok((ss-1)->currentMove)) if (is_ok((ss-1)->currentMove))
Countermoves.update(pos.piece_on(prevMoveSq), prevMoveSq, bestMove); Countermoves.update(pos.piece_on(prevMoveSq), prevMoveSq, bestMove);