mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Rename move_is_legal() in move_is_pl()
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>
This commit is contained in:
parent
bc86668ba4
commit
45ce92b89c
5 changed files with 18 additions and 15 deletions
|
@ -451,7 +451,7 @@ namespace {
|
|||
// 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)
|
||||
|
|
|
@ -275,7 +275,8 @@ Move MovePicker::get_next_move() {
|
|||
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))
|
||||
return move;
|
||||
break;
|
||||
|
||||
|
@ -300,7 +301,8 @@ Move MovePicker::get_next_move() {
|
|||
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))
|
||||
|
|
|
@ -628,14 +628,14 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
|
|||
/// 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)
|
||||
return pl_move_is_legal(m, pinned_pieces(sideToMove));
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -644,10 +644,9 @@ bool Position::move_is_legal(const Move m) const {
|
|||
/// 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(is_ok());
|
||||
assert(pinned == pinned_pieces(sideToMove));
|
||||
|
||||
Color us = sideToMove;
|
||||
Color them = opposite_color(sideToMove);
|
||||
|
@ -657,7 +656,7 @@ bool Position::move_is_legal(const Move m, Bitboard pinned) const {
|
|||
|
||||
// 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)
|
||||
|
@ -763,8 +762,7 @@ bool Position::move_is_legal(const Move m, Bitboard pinned) const {
|
|||
}
|
||||
}
|
||||
|
||||
// The move is pseudo-legal, check if it is also legal
|
||||
return pl_move_is_legal(m, pinned);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -186,8 +186,8 @@ public:
|
|||
|
||||
// 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;
|
||||
|
|
|
@ -1979,13 +1979,16 @@ split_point_start: // At split points actual search starts from here
|
|||
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++);
|
||||
|
||||
Bitboard pinned = pos.pinned_pieces(pos.side_to_move());
|
||||
|
||||
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))
|
||||
{
|
||||
|
@ -2009,7 +2012,7 @@ split_point_start: // At split points actual search starts from here
|
|||
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]));
|
||||
|
||||
do {
|
||||
k = pos.get_key();
|
||||
|
|
Loading…
Add table
Reference in a new issue