]> git.sesse.net Git - stockfish/commitdiff
Better interface to get the current move type
authorMarco Costalba <mcostalba@gmail.com>
Mon, 6 Oct 2008 04:32:09 +0000 (05:32 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 6 Oct 2008 03:44:23 +0000 (05:44 +0200)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/movepick.cpp
src/movepick.h
src/search.cpp

index fa911dfb350b348e2399a964d6262b9dcf7b443d..a18c46923b60742160816fddb3d9c8ff2734dc35 100644 (file)
@@ -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:
index 17f29daa93e353c83d955304e14388f43237eb64..10f0e8ef5c66a7ee30ddba345063b332c5de40db 100644 (file)
@@ -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;
 }
 
index 2a6ba30b8367e93a6d84869d31b2c7fa5ca01a4f..bb6ba9ac5ee84bebbf2aba40f18bff3766d2ae12 100644 (file)
@@ -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;