-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
bishop.h
executable file
·42 lines (33 loc) · 1.18 KB
/
bishop.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef BISHOP_H
#define BISHOP_H
#include "defines.h"
#include "board.h"
#include "utils.h"
#include "movedatabase.h"
namespace Napoleon
{
class Bishop
{
public:
static BitBoard GetAllTargets(BitBoard, Board&);
static BitBoard TargetsFrom(Square, Color, Board&);
};
INLINE BitBoard Bishop::GetAllTargets(BitBoard bishops, Board& board)
{
BitBoard occupiedSquares = board.OccupiedSquares;
BitBoard targets = Constants::Empty;
Square square = Utils::BitBoard::BitScanForward(bishops);
targets |= MoveDatabase::GetA1H8DiagonalAttacks(occupiedSquares, square);
targets |= MoveDatabase::GetH1A8DiagonalAttacks(occupiedSquares, square);
return targets & ~board.PlayerPieces();
}
INLINE BitBoard Bishop::TargetsFrom(Square square, Color color, Board& board)
{
BitBoard occupiedSquares = board.OccupiedSquares;
BitBoard targets = Constants::Empty;
targets |= MoveDatabase::GetA1H8DiagonalAttacks(occupiedSquares, square);
targets |= MoveDatabase::GetH1A8DiagonalAttacks(occupiedSquares, square);
return targets & ~board.Pieces(color);
}
}
#endif // BISHOP_H