Use pointers instead of array indices also for badCaptures
authorMarco Costalba <mcostalba@gmail.com>
Mon, 31 Aug 2009 10:33:44 +0000 (12:33 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 31 Aug 2009 10:33:44 +0000 (12:33 +0200)
To have uniformity with moves array handling.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/movepick.cpp
src/movepick.h

index 5c0f4f5b775c57f811a382746936b519043c9710..dedfee8a4baf6f809bd59313bd826a51314e8360 100644 (file)
@@ -73,7 +73,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d,
       ttMoves[1].move = killers[0].move = killers[1].move = MOVE_NONE;
 
   finished = false;
-  numOfBadCaptures = 0;
+  lastBadCapture = badCaptures;
 
   Color us = pos.side_to_move();
 
@@ -129,7 +129,7 @@ void MovePicker::go_next_phase() {
       // Bad captures SEE value is already calculated so just sort them
       // to get SEE move ordering.
       curMove = badCaptures;
-      lastMove = badCaptures + numOfBadCaptures;
+      lastMove = lastBadCapture;
       std::sort(badCaptures, lastMove);
       return;
 
@@ -278,9 +278,10 @@ Move MovePicker::get_next_move() {
 
                   // Losing capture, move it to the badCaptures[] array, note
                   // that move has now been already checked for legality.
-                  assert(numOfBadCaptures < 63);
-                  badCaptures[numOfBadCaptures].move = move;
-                  badCaptures[numOfBadCaptures++].score = seeValue;
+                  assert(int(lastBadCapture - badCaptures) < 63);
+                  lastBadCapture->move = move;
+                  lastBadCapture->score = seeValue;
+                  lastBadCapture++;
               }
               break;
 
index 147d5d0b0a666915031f687a82e0d858f7aad5ce..27adb101552160c5fe0613a691f8dce665aff43f 100644 (file)
@@ -80,9 +80,9 @@ private:
   const History& H;
   MoveStack ttMoves[2], killers[2];
   bool finished;
-  int numOfBadCaptures, phase;
+  int phase;
   const MovegenPhaseT* phasePtr;
-  MoveStack *curMove, *lastMove;
+  MoveStack *curMove, *lastMove, *lastBadCapture;
   Bitboard dc, pinned;
   MoveStack moves[256], badCaptures[64];
 };