-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathking.cpp
More file actions
executable file
·22 lines (20 loc) · 641 Bytes
/
king.cpp
File metadata and controls
executable file
·22 lines (20 loc) · 641 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "king.h"
#include "utils.h"
#include "movedatabase.h"
#include "compassrose.h"
#include "board.h"
namespace Napoleon
{
BitBoard King::GetAllTargets(BitBoard king, Board& board)
{
BitBoard kingMoves = MoveDatabase::KingAttacks[(Utils::BitBoard::BitScanForward(king))];
return kingMoves & ~board.PlayerPieces();
}
BitBoard King::GetKingAttacks(BitBoard king)
{
BitBoard attacks = CompassRose::OneStepEast(king) | CompassRose::OneStepWest(king);
king |= attacks;
attacks |= CompassRose::OneStepNorth(king) | CompassRose::OneStepSouth(king);
return attacks;
}
}