summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
bc86668)
We disjoint pseudo legal detection from full legal detection.
It will be used by future patches.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
// Single and double pawn pushes
if (Type != MV_CAPTURE)
{
// Single and double pawn pushes
if (Type != MV_CAPTURE)
{
- b1 = pawnPushes & emptySquares;
+ b1 = (Type != MV_EVASION ? pawnPushes : pawnPushes & emptySquares);
b2 = move_pawns<TDELTA_N>(pawnPushes & TRank3BB) & emptySquares;
if (Type == MV_CHECK)
b2 = move_pawns<TDELTA_N>(pawnPushes & TRank3BB) & emptySquares;
if (Type == MV_CHECK)
case PH_TT_MOVES:
move = (curMove++)->move;
if ( move != MOVE_NONE
case PH_TT_MOVES:
move = (curMove++)->move;
if ( move != MOVE_NONE
- && pos.move_is_legal(move, pinned))
+ && pos.move_is_pl(move)
+ && pos.pl_move_is_legal(move, pinned))
case PH_KILLERS:
move = (curMove++)->move;
if ( move != MOVE_NONE
case PH_KILLERS:
move = (curMove++)->move;
if ( move != MOVE_NONE
- && pos.move_is_legal(move, pinned)
+ && pos.move_is_pl(move)
+ && pos.pl_move_is_legal(move, pinned)
&& move != ttMoves[0].move
&& move != ttMoves[1].move
&& !pos.move_is_capture(move))
&& move != ttMoves[0].move
&& move != ttMoves[1].move
&& !pos.move_is_capture(move))
/// move and tests whether the move is legal. This version is not very fast and
/// should be used only in non time-critical paths.
/// move and tests whether the move is legal. This version is not very fast and
/// should be used only in non time-critical paths.
-bool Position::move_is_legal(const Move m) const {
+bool Position::move_is_pl_full(const Move m) const {
MoveStack mlist[MAX_MOVES];
MoveStack *cur, *last = generate<MV_PSEUDO_LEGAL>(*this, mlist);
for (cur = mlist; cur != last; cur++)
if (cur->move == m)
MoveStack mlist[MAX_MOVES];
MoveStack *cur, *last = generate<MV_PSEUDO_LEGAL>(*this, mlist);
for (cur = mlist; cur != last; cur++)
if (cur->move == m)
- return pl_move_is_legal(m, pinned_pieces(sideToMove));
/// Fast version of Position::move_is_legal() that takes a position a move and
/// a bitboard of pinned pieces as input, and tests whether the move is legal.
/// Fast version of Position::move_is_legal() that takes a position a move and
/// a bitboard of pinned pieces as input, and tests whether the move is legal.
-bool Position::move_is_legal(const Move m, Bitboard pinned) const {
+bool Position::move_is_pl(const Move m) const {
- assert(pinned == pinned_pieces(sideToMove));
Color us = sideToMove;
Color them = opposite_color(sideToMove);
Color us = sideToMove;
Color them = opposite_color(sideToMove);
// Use a slower but simpler function for uncommon cases
if (move_is_special(m))
// Use a slower but simpler function for uncommon cases
if (move_is_special(m))
- return move_is_legal(m);
+ return move_is_pl_full(m);
// Is not a promotion, so promotion piece must be empty
if (move_promotion_piece(m) - 2 != PIECE_TYPE_NONE)
// Is not a promotion, so promotion piece must be empty
if (move_promotion_piece(m) - 2 != PIECE_TYPE_NONE)
- // The move is pseudo-legal, check if it is also legal
- return pl_move_is_legal(m, pinned);
// Properties of moves
bool pl_move_is_legal(Move m, Bitboard pinned) const;
// Properties of moves
bool pl_move_is_legal(Move m, Bitboard pinned) const;
- bool move_is_legal(const Move m) const;
- bool move_is_legal(const Move m, Bitboard pinned) const;
+ bool move_is_pl_full(const Move m) const;
+ bool move_is_pl(const Move m) const;
bool move_gives_check(Move m) const;
bool move_gives_check(Move m, const CheckInfo& ci) const;
bool move_is_capture(Move m) const;
bool move_gives_check(Move m) const;
bool move_gives_check(Move m, const CheckInfo& ci) const;
bool move_is_capture(Move m) const;
TTEntry* tte;
int ply = 1;
TTEntry* tte;
int ply = 1;
- assert(pv[0] != MOVE_NONE && pos.move_is_legal(pv[0]));
+ assert(pv[0] != MOVE_NONE && pos.move_is_pl(pv[0]));
pos.do_move(pv[0], *st++);
pos.do_move(pv[0], *st++);
+ Bitboard pinned = pos.pinned_pieces(pos.side_to_move());
+
while ( (tte = TT.probe(pos.get_key())) != NULL
&& tte->move() != MOVE_NONE
while ( (tte = TT.probe(pos.get_key())) != NULL
&& tte->move() != MOVE_NONE
- && pos.move_is_legal(tte->move())
+ && pos.move_is_pl(tte->move())
+ && pos.pl_move_is_legal(tte->move(), pinned)
&& ply < PLY_MAX
&& (!pos.is_draw() || ply < 2))
{
&& ply < PLY_MAX
&& (!pos.is_draw() || ply < 2))
{
Value v, m = VALUE_NONE;
int ply = 0;
Value v, m = VALUE_NONE;
int ply = 0;
- assert(pv[0] != MOVE_NONE && pos.move_is_legal(pv[0]));
+ assert(pv[0] != MOVE_NONE && pos.move_is_pl(pv[0]));