-
Notifications
You must be signed in to change notification settings - Fork 0
/
Board.h
89 lines (70 loc) · 2.57 KB
/
Board.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef BOARD_H
#define BOARD_H
#include <iostream>
#include <algorithm>
#include <vector>
#include <typeinfo>
#include <string>
#include <chrono>
#include <boost/algorithm/string.hpp>
#include "Move.h"
#include "Data.h"
#include "ZobristHash.h"
using namespace std;
using MoveList = vector<Move>;
// TODO: Test if these correctly influence move-making
enum moveGenType { QUIET_ONLY = 0x1, CAPTURES_ONLY = 0x2, ALL = 0x3};
class Board
{
friend class UnitTest;
private:
// Move making
void updateAttack(piece p);
// Init
void initHash(); // Used only for Init!, the hashkey is updated for each move
template <color> void pawnFill();
public:
Board();
Board(string fen);
// Init
void setupBoard(string FEN);
// Move making and move generation
template<moveGenType> void generateMoveList(MoveList&, color);
void playStringMoves(const vector<string>&, color side);
U64 inline rookAttacks(long pos, const U64 blockers) const;
U64 inline bishopAttacks(long pos, const U64 blockers) const;
template<moveGenType, color> void inline pawnMoves(MoveList&) const;
template<moveGenType, color> void inline knightMoves(MoveList&) const;
template<moveGenType, color, bool Q> void inline queen_and_bishopMoves(MoveList&) const;
template<moveGenType, color> void inline kingMoves(MoveList&) const;
template<moveGenType, color> void inline rookMoves(MoveList&) const;
template<makeMoveType mmt> void makeMove(const Move&, color side);
template<makeMoveType mmt> void unMakeMove(const Move&, color side);
void updateAllAttacks();
void updateAllAttacks(const Move&);
void updatePinnedPieces(color side);
bool isKingInCheck(color kingColor) const;
bool isKingLeftInCheck(color KingColor, const Move& lastMove, bool, U64 currentlyPinned);
// Evaluation
int evaluate(color side);
// Misc
void print() const;
// Raw data: (public for easy access)
vector<U64> pieces, attacks;
U8 castlingRights, // Castling rights
b_enpassant, // Possible e.p. squares for black
w_enpassant; // Possible e.p. squares for white
U64 wpMove, bpMove, // Squares pawns can move to (quietly)
wpDanger, bpDanger, // Empty squares, that are attacked by pawns
whitePos, blackPos, allPos, // Collective positional information
whiteAtt, blackAtt, // Collective attack information
hashKey, // Hashkey representing current board
pinned; // Squares containing absolute pinned pieces
bool wasInCheck;
vector<vector<U64>> randomSet;
U64 sideToMoveMask;
};
// Template definitions
#include "Makemove.h"
#include "Movegenerators.h"
#endif