-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbitboard.hpp
More file actions
135 lines (102 loc) · 3.33 KB
/
bitboard.hpp
File metadata and controls
135 lines (102 loc) · 3.33 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#ifndef BITBOARD_HPP
#define BITBOARD_HPP
#include <iostream>
#include <cstdint>
#include <mutex>
#include <string>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <random>
#include <set>
#include <deque>
#include <bitset>
#include "constants.hpp"
#include "movearray.hpp"
#include "goback.hpp"
#include "magic.hpp"
class BitBoard {
public:
//Битовые маски горизонталей и вертикалей
uint64_t horizontal[8];
uint64_t vertical[8];
int hash_width;
uint64_t hash_cutter;
uint64_t ROOK_MAGIC[8][8];
uint64_t BISHOP_MAGIC[8][8];
uint64_t zobrist[32][BOARD_SIZE][BOARD_SIZE];
uint64_t wscZobrist, wlcZobrist, bscZobrist, blcZobrist;
uint64_t passantZobrist[8][8];
void preInit();
std::vector<std::string> splitter(std::string str, char sym);
uint64_t plus1[65], plus7[65], plus8[65], plus9[65], minus1[65], minus7[65], minus8[65], minus9[65]; //Битовые маски лучей
//Битовые таблицы полей
uint64_t vec2_cells[8][8];
uint64_t vec1_cells[64];
uint64_t bitboard[32][8][8];
uint64_t whitePawnAttacks[8][8];
uint64_t blackPawnAttacks[8][8];
double kingSecurityArray[64][64];
std::string startpos_fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; //Стартовая позиция
void zobristGenerator();
uint8_t popcount64(uint64_t value);
uint8_t firstOne(uint64_t mask);
uint8_t lastOne(uint64_t mask);
void clearCell(uint8_t y, uint8_t x);
void addFigure(uint8_t figure, uint8_t y, uint8_t x) ;
void printBitBoard(uint64_t bit_board);
void magicNumberGenerator();
void magicInit();
void magicConstantsSet(); //Константы Magic (предварительно вычислены, используются в генераторе ходов)
uint64_t magicGenerator();
uint64_t capturePawnMap[32][64];
BitMove getMove(uint8_t fromY, uint8_t fromX, uint8_t toY, uint8_t toX, bool replaced, uint8_t replacedFigure, bool& enable);
uint8_t metric[64][8][8];
std::vector<GoBack> history;
GoBack currentState;
int history_iterator = 0;
bool wsc();
bool wlc();
bool bsc();
bool blc();
Magic rookMagic[8][8];
Magic bishopMagic[8][8];
uint64_t rookMagicMask[8][8];
uint64_t bishopMagicMask[8][8];
uint64_t whiteCells, blackCells;
std::vector<int> third_repeat;
public:
BitBoard();
~BitBoard();
void setFen(std::string fen);
std::string getFen();
void clear();
size_t stress;
void bitBoardMoveGenerator(MoveArray& moveArray);
double bitBoardMobilityEval(bool clr, double stage_game);
void bitBoardAttackMoveGenerator(MoveArray& moveArray);
void move(BitMove& mv);
void goBack();
void pushHistory();
BitMove getRandomMove();
void makeNullMove();
void unMakeNullMove();
int64_t getEvaluate();
uint8_t getFigure(uint8_t pos);
int getFiguresCount();
bool inCheck(uint8_t color);
bool inCheck(uint8_t color, uint8_t y, uint8_t x);
void generateHash();
uint64_t getHash();
uint64_t getColorHash();
bool testOfDraw();
std::multiset<uint64_t> gameHash;
std::vector<uint8_t> isolated_pawn_map;
double newEvaluateAll();
MoveArray moveArray;
uint8_t compressVertical(uint64_t value);
uint64_t whitePawnCheckCells[64];
uint64_t blackPawnCheckCells[64];
};
#endif