pseudo_is_legal(): use sq_is_attacked() instead of sq_attackers()

This commit is contained in:
2024-04-13 06:50:15 +02:00
parent a6eedebc19
commit 0330696f87
3 changed files with 3 additions and 8 deletions

View File

@@ -101,7 +101,6 @@ bitboard_t sq_attackers(const pos_t *pos, const bitboard_t occ, const square_t s
{
bitboard_t attackers = 0, tmp;
bitboard_t sqbb = mask(sq);
//bitboard_t occ = pos_occ(pos);
bitboard_t to;
color_t opp = OPPONENT(c);

View File

@@ -148,12 +148,8 @@ pos_t *move_do(pos_t *pos, const move_t move) //, state_t *state)
*
* @return: pos.
*/
pos_t *move_undo(pos_t *pos, const move_t move)//, const state_t *state)
pos_t *move_undo(pos_t *pos, const move_t move)
{
//# ifdef DEBUG_MOVE
//log(1, "new move: ");
//move_print(0, move, M_PR_NL | M_PR_LONG);
//# endif
color_t them = pos->turn, us = OPPONENT(them);
square_t from = move_from(move), to = move_to(move);
piece_t piece = pos->board[to];

View File

@@ -53,10 +53,10 @@ bool pseudo_is_legal(const pos_t *pos, const move_t move)
if (unlikely(from == king)) {
if (unlikely(is_castle(move))) {
square_t dir = to > from? 1: -1;
if (sq_attackers(pos, occ, from + dir, them))
if (sq_is_attacked(pos, occ, from + dir, them))
return false;
}
return !sq_attackers(pos, occ ^ kingbb, to, them);
return !sq_is_attacked(pos, occ ^ kingbb, to, them);
}
/* (2) - King is in check