/// Variables
- MovePicker::MovegenPhase PhaseTable[32];
+ MovePicker::MovegenPhase PhaseTable[32];
int MainSearchPhaseIndex;
int EvasionsPhaseIndex;
int QsearchWithChecksPhaseIndex;
/// move ordering is at the current node.
MovePicker::MovePicker(const Position& p, bool pvnode, Move ttm, Move mk,
- Move k1, Move k2, Depth d) : pos(p) {
+ Move k1, Move k2, Depth d) : pos(p) {
pvNode = pvnode;
ttMove = ttm;
mateKiller = (mk == ttm)? MOVE_NONE : mk;
break;
case PH_EVASIONS:
- assert(pos.is_check());
+ assert(pos.is_check());
numOfMoves = generate_evasions(pos, moves);
score_evasions();
movesPicked = 0;
break;
- case PH_QCAPTURES:
+ case PH_QCAPTURES:
numOfMoves = generate_captures(pos, moves);
score_qcaptures();
movesPicked = 0;
return MOVE_NONE;
}
}
- assert(false);
- return MOVE_NONE;
}
if (m == MOVE_NONE)
finished = true;
- lock_release(&lock);
+ lock_release(&lock);
return m;
}
}
-/// find_best_index() loops across the moves and returns index of\r
-/// the highest scored one.\r
-\r
-int MovePicker::find_best_index() {\r
-\r
- int bestScore = -10000000, bestIndex = -1;\r
-\r
- for (int i = movesPicked; i < numOfMoves; i++)\r
- if (moves[i].score > bestScore)\r
- {\r
- bestIndex = i;\r
- bestScore = moves[i].score;\r
- }\r
- return bestIndex;\r
+/// find_best_index() loops across the moves and returns index of
+/// the highest scored one.
+
+int MovePicker::find_best_index() {
+
+ int bestScore = -10000000, bestIndex = -1;
+
+ for (int i = movesPicked; i < numOfMoves; i++)
+ if (moves[i].score > bestScore)
+ {
+ bestIndex = i;
+ bestScore = moves[i].score;
+ }
+ return bestIndex;
}
}
-/// MovePicker::current_move_type() returns the type of the just\r
-/// picked next move. It can be used in search to further differentiate\r
+/// MovePicker::current_move_type() returns the type of the just
+/// picked next move. It can be used in search to further differentiate
/// according to the current move type: capture, non capture, escape, etc.
MovePicker::MovegenPhase MovePicker::current_move_type() const {
fen += (char)skip + '0';
skip = 0;
}
- fen += pieceLetters[piece_on(sq)];
+ fen += pieceLetters[piece_on(sq)];
}
if (skip > 0)
fen += (char)skip + '0';
Square s;
Bitboard sliders, result = EmptyBoardBB;
-
+
if (Piece == ROOK) // Resolved at compile time
sliders = rooks_and_queens(FindPinned ? opposite_color(c) : c) & RookPseudoAttacks[ksq];
else
// King blockers are candidate pinned pieces
Bitboard candidate_pinned = piece_attacks<Piece>(ksq) & pieces_of_color(c);
- // Pinners are sliders, not checkers, that give check when
+ // Pinners are sliders, not checkers, that give check when
// candidate pinned are removed.
Bitboard pinners = (FindPinned ? sliders & ~checkersBB : sliders);
case WR: case BR: return piece_attacks_square<ROOK>(f, t);
case WQ: case BQ: return piece_attacks_square<QUEEN>(f, t);
case WK: case BK: return piece_attacks_square<KING>(f, t);
- default: return false;
}
return false;
}
switch (type_of_piece_on(from))
{
case PAWN:
-
+
if (bit_is_set(pawn_attacks(them, ksq), to)) // Normal check?
return true;
-
+
if ( bit_is_set(dcCandidates, from) // Discovered check?
&& (direction_between_squares(from, ksq) != direction_between_squares(to, ksq)))
return true;
-
+
if (move_promotion(m)) // Promotion with check?
{
Bitboard b = occupied_squares();
}
return false;
- case KNIGHT:
+ case KNIGHT:
return bit_is_set(dcCandidates, from) // Discovered check?
|| bit_is_set(piece_attacks<KNIGHT>(ksq), to); // Normal check?
case QUEEN:
// Discovered checks are impossible!
- assert(!bit_is_set(dcCandidates, from));
+ assert(!bit_is_set(dcCandidates, from));
return bit_is_set(piece_attacks<QUEEN>(ksq), to); // Normal check?
case KING:
// Position::undo_move. In particular, the side to move has been switched,
// so the code below is correct.
Color us = side_to_move();
- Color them = opposite_color(us);
// Find source squares for king and rook
Square kfrom = move_from(m);
/// Position::do_move, is used to put back the captured piece (if any).
void Position::undo_promotion_move(Move m, const UndoInfo &u) {
-
+
Color us, them;
Square from, to;
PieceType capture, promotion;
{
if (mgValue != compute_mg_value())
return false;
-
+
if (egValue != compute_eg_value())
return false;
}