-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
rook.h
executable file
·40 lines (31 loc) · 969 Bytes
/
rook.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
#ifndef ROOK_H
#define ROOK_H
#include "defines.h"
#include "board.h"
#include "utils.h"
#include "movedatabase.h"
namespace Napoleon
{
class Rook
{
public:
static BitBoard GetAllTargets(BitBoard, Board&);
static BitBoard TargetsFrom(Square, Color, Board&);
};
INLINE BitBoard Rook::GetAllTargets(BitBoard rooks, Board& board)
{
BitBoard occupiedSquares = board.OccupiedSquares;
BitBoard targets;
Square square = Utils::BitBoard::BitScanForward(rooks);
targets = MoveDatabase::GetRookAttacks(occupiedSquares, square);
return targets & ~board.PlayerPieces();
}
INLINE BitBoard Rook::TargetsFrom(Square square, Color color, Board& board)
{
BitBoard occupiedSquares = board.OccupiedSquares;
BitBoard targets;
targets = MoveDatabase::GetRookAttacks(occupiedSquares, square);
return targets & ~board.Pieces(color);
}
}
#endif // ROOK_H