/// Variables
- MovePicker::MovegenPhase PhaseTable[32];
+ MovePicker::MovegenPhase PhaseTable[32];
int MainSearchPhaseIndex;
int EvasionsPhaseIndex;
int QsearchWithChecksPhaseIndex;
}
+
////
//// Functions
////
/// 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) {
// Next phase:
phaseIndex++;
- if (moveType)
- *moveType = PhaseTable[phaseIndex];
-
switch(PhaseTable[phaseIndex]) {
case PH_TT_MOVE:
}
void MovePicker::score_noncaptures() {
- for(int i = 0; i < numOfMoves; i++) {
- Move m = moves[i].move;
- if(m == killer1)
- moves[i].score = HistoryMax + 2;
- else if(m == killer2)
- moves[i].score = HistoryMax + 1;
- else
- moves[i].score = H.move_ordering_score(pos->piece_on(move_from(m)), m);
+
+ for (int i = 0; i < numOfMoves; i++)
+ {
+ Move m = moves[i].move;
+ if (m == killer1)
+ moves[i].score = HistoryMax + 2;
+ else if (m == killer2)
+ moves[i].score = HistoryMax + 1;
+ else
+ moves[i].score = H.move_ordering_score(pos->piece_on(move_from(m)), m);
+
+ // Ensure moves in history are always sorted as first
+ if (moves[i].score > 0)
+ moves[i].score += 1000;
+
+ moves[i].score += pos->mg_pst_delta(moves[i].move);
}
}
return MOVE_NONE;
}
+MovePicker::MovegenPhase MovePicker::current_move_type() const {
+ return PhaseTable[phaseIndex];
+}
/// MovePicker::init_phase_table() initializes the PhaseTable[],
/// MainSearchPhaseIndex, EvasionPhaseIndex, QsearchWithChecksPhaseIndex