From: Marco Costalba Date: Mon, 6 Oct 2008 04:32:09 +0000 (+0100) Subject: Better interface to get the current move type X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=bbf7a94d76339837a6e8925ded1ea231d51e773d Better interface to get the current move type Signed-off-by: Marco Costalba --- diff --git a/src/movepick.cpp b/src/movepick.cpp index fa911dfb..a18c4692 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -38,7 +38,6 @@ namespace { /// Variables - MovePicker::MovegenPhase PhaseTable[32]; int MainSearchPhaseIndex; int EvasionsPhaseIndex; int QsearchWithChecksPhaseIndex; @@ -46,6 +45,9 @@ namespace { } +// Static array definition +MovePicker::MovegenPhase MovePicker::PhaseTable[32]; + //// //// Functions @@ -92,7 +94,7 @@ MovePicker::MovePicker(Position &p, bool pvnode, Move ttm, Move mk, /// class. It returns a new legal move every time it is called, until there /// are no more moves left of the types we are interested in. -Move MovePicker::get_next_move(MovegenPhase* moveType) { +Move MovePicker::get_next_move() { Move move; while(true) { @@ -106,9 +108,6 @@ Move MovePicker::get_next_move(MovegenPhase* moveType) { // Next phase: phaseIndex++; - if (moveType) - *moveType = PhaseTable[phaseIndex]; - switch(PhaseTable[phaseIndex]) { case PH_TT_MOVE: diff --git a/src/movepick.h b/src/movepick.h index 17f29daa..10f0e8ef 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -61,11 +61,12 @@ public: MovePicker(Position &p, bool pvnode, Move ttm, Move mk, Move k1, Move k2, Depth dpth); - Move get_next_move(MovegenPhase* moveType = NULL); + Move get_next_move(); Move get_next_move(Lock &lock); int number_of_moves() const; int current_move_score() const; - Bitboard discovered_check_candidates(); + MovegenPhase current_move_type() const; + Bitboard discovered_check_candidates() const; static void init_phase_table(); @@ -80,6 +81,7 @@ private: Move ttMove, mateKiller, killer1, killer2; Bitboard pinned, dc; MoveStack moves[256], badCaptures[64]; + static MovegenPhase PhaseTable[32]; bool pvNode; Depth depth; int phaseIndex; @@ -97,7 +99,11 @@ private: /// all pieces which can possibly give discovered check. This bitboard is /// computed by the constructor function. -inline Bitboard MovePicker::discovered_check_candidates() { +inline MovePicker::MovegenPhase MovePicker::current_move_type() const { + return PhaseTable[phaseIndex]; +} + +inline Bitboard MovePicker::discovered_check_candidates() const { return dc; } diff --git a/src/search.cpp b/src/search.cpp index 2a6ba30b..bb6ba9ac 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1147,7 +1147,6 @@ namespace { Value value, bestValue = -VALUE_INFINITE; Bitboard dcCandidates = mp.discovered_check_candidates(); Value futilityValue = VALUE_NONE; - MovePicker::MovegenPhase moveType; bool isCheck = pos.is_check(); bool useFutilityPruning = UseFutilityPruning && depth < SelectiveDepth @@ -1156,14 +1155,14 @@ namespace { // Loop through all legal moves until no moves remain or a beta cutoff // occurs. while ( bestValue < beta - && (move = mp.get_next_move(&moveType)) != MOVE_NONE + && (move = mp.get_next_move()) != MOVE_NONE && !thread_should_stop(threadID)) { assert(move_is_ok(move)); bool singleReply = (isCheck && mp.number_of_moves() == 1); bool moveIsCheck = pos.move_is_check(move, dcCandidates); - bool moveIsGoodCapture = (moveType == MovePicker::PH_GOOD_CAPTURES); + bool moveIsGoodCapture = (mp.current_move_type() == MovePicker::PH_GOOD_CAPTURES); bool moveIsPassedPawnPush = pos.move_is_passed_pawn_push(move); movesSearched[moveCount++] = ss[ply].currentMove = move;