/// search captures, promotions and some checks) and about how important good
/// move ordering is at the current node.
-MovePicker::MovePicker(const Position& p, bool pv, Move ttm,
- const SearchStack& ss, Depth d) : pos(p) {
+MovePicker::MovePicker(const Position& p, bool pv, Move ttm, Depth d, SearchStack* ss) : pos(p) {
+
pvNode = pv;
ttMove = ttm;
- mateKiller = (ss.mateKiller == ttm)? MOVE_NONE : ss.mateKiller;
- killer1 = ss.killers[0];
- killer2 = ss.killers[1];
+ if (ss)
+ {
+ mateKiller = (ss->mateKiller == ttm)? MOVE_NONE : ss->mateKiller;
+ killer1 = ss->killers[0];
+ killer2 = ss->killers[1];
+ } else
+ mateKiller = killer1 = killer2 = MOVE_NONE;
+
depth = d;
movesPicked = 0;
numOfMoves = 0;
struct EvalInfo;
struct SearchStack;
-extern SearchStack EmptySearchStack;
-
/// MovePicker is a class which is used to pick one legal move at a time from
/// the current position. It is initialized with a Position object and a few
/// moves we have reason to believe are good. The most important method is
PH_STOP
};
- MovePicker(const Position& p, bool pvnode, Move ttm, const SearchStack& ss, Depth d);
+ MovePicker(const Position& p, bool pvnode, Move ttm, Depth d, SearchStack* ss = NULL);
Move get_next_move();
Move get_next_move(Lock& lock);
int number_of_moves() const;
assert(pos.is_ok());
- MovePicker mp = MovePicker(pos, false, MOVE_NONE, EmptySearchStack, OnePly);
+ MovePicker mp = MovePicker(pos, false, MOVE_NONE, OnePly);
// Castling moves
if (movestr == "O-O-O" || movestr == "O-O-O+")
if (type_of_piece(pc) == KING)
return AMBIGUITY_NONE;
- MovePicker mp = MovePicker(pos, false, MOVE_NONE, EmptySearchStack, OnePly);
+ MovePicker mp = MovePicker(pos, false, MOVE_NONE, OnePly);
Move mv, moveList[8];
int n = 0;
History H; // Should be made local?
-// The empty search stack
-SearchStack EmptySearchStack;
-
// SearchStack::init() initializes a search stack. Used at the beginning of a
// new search from the root.
// Wait until the thread has finished launching:
while (!Threads[i].running);
}
-
- // Init also the empty search stack
- EmptySearchStack.init(0);
- EmptySearchStack.initKillers();
}
// Initialize a MovePicker object for the current position, and prepare
// to search all moves
- MovePicker mp = MovePicker(pos, true, ttMove, ss[ply], depth);
+ MovePicker mp = MovePicker(pos, true, ttMove, depth, &ss[ply]);
Move move, movesSearched[256];
int moveCount = 0;
// Initialize a MovePicker object for the current position, and prepare
// to search all moves:
- MovePicker mp = MovePicker(pos, false, ttMove, ss[ply], depth);
+ MovePicker mp = MovePicker(pos, false, ttMove, depth, &ss[ply]);
Move move, movesSearched[256];
int moveCount = 0;
// Initialize a MovePicker object for the current position, and prepare
// to search the moves. Because the depth is <= 0 here, only captures,
// queen promotions and checks (only if depth == 0) will be generated.
- MovePicker mp = MovePicker(pos, pvNode, ttMove, EmptySearchStack, depth);
+ MovePicker mp = MovePicker(pos, pvNode, ttMove, depth);
Move move;
int moveCount = 0;
Bitboard dcCandidates = mp.discovered_check_candidates();
//// Global variables
////
-extern SearchStack EmptySearchStack;
extern TranspositionTable TT;
extern int ActiveThreads;
extern Lock SMPLock;